From 97e8a48be58fd53afccc7ae01ee6ec5805d5c1cd Mon Sep 17 00:00:00 2001 From: Vivian McPhail Date: Thu, 8 Jul 2010 23:03:48 +0000 Subject: Linear and Floating (Complex Float) --- lib/Data/Packed/Internal/Matrix.hs | 10 ++++++++++ lib/Data/Packed/Internal/Signatures.hs | 2 ++ lib/Data/Packed/Matrix.hs | 9 +++++++++ 3 files changed, 21 insertions(+) (limited to 'lib/Data') diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs index 7b3b305..861c72a 100644 --- a/lib/Data/Packed/Internal/Matrix.hs +++ b/lib/Data/Packed/Internal/Matrix.hs @@ -265,6 +265,10 @@ instance Element Double where transdata = transdataAux ctransR constantD = constantAux cconstantR +instance Element (Complex Float) where + transdata = transdataAux ctransQ + constantD = constantAux cconstantQ + instance Element (Complex Double) where transdata = transdataAux ctransC constantD = constantAux cconstantC @@ -314,6 +318,7 @@ transdataAux fun c1 d c2 = foreign import ccall "transF" ctransF :: TFMFM foreign import ccall "transR" ctransR :: TMM +foreign import ccall "transQ" ctransQ :: TQMQM foreign import ccall "transC" ctransC :: TCMCM ---------------------------------------------------------------------- @@ -342,9 +347,14 @@ constantR :: Double -> Int -> Vector Double constantR = constantAux cconstantR foreign import ccall "constantR" cconstantR :: Ptr Double -> TV +constantQ :: Complex Float -> Int -> Vector (Complex Float) +constantQ = constantAux cconstantQ +foreign import ccall "constantQ" cconstantQ :: Ptr (Complex Float) -> TQV + constantC :: Complex Double -> Int -> Vector (Complex Double) constantC = constantAux cconstantC foreign import ccall "constantC" cconstantC :: Ptr (Complex Double) -> TCV + ---------------------------------------------------------------------- -- | Extracts a submatrix from a matrix. diff --git a/lib/Data/Packed/Internal/Signatures.hs b/lib/Data/Packed/Internal/Signatures.hs index 78d00fa..8c1c5f6 100644 --- a/lib/Data/Packed/Internal/Signatures.hs +++ b/lib/Data/Packed/Internal/Signatures.hs @@ -59,6 +59,8 @@ type TQV = CInt -> PQ -> IO CInt -- type TQVQV = CInt -> PQ -> TQV -- type TQVQVQV = CInt -> PQ -> TQVQV -- type TQVF = CInt -> PQ -> TF -- +type TQM = CInt -> CInt -> PQ -> IO CInt -- +type TQMQM = CInt -> CInt -> PQ -> TQM -- type TCMCV = CInt -> CInt -> PC -> TCV -- type TVCV = CInt -> PD -> TCV -- type TCVM = CInt -> PC -> TM -- diff --git a/lib/Data/Packed/Matrix.hs b/lib/Data/Packed/Matrix.hs index c6d8a90..e7ee781 100644 --- a/lib/Data/Packed/Matrix.hs +++ b/lib/Data/Packed/Matrix.hs @@ -452,6 +452,7 @@ class (Element e) => Container c e where fromComplex :: RealFloat e => c (Complex e) -> (c e, c e) comp :: RealFloat e => c e -> c (Complex e) conj :: RealFloat e => c (Complex e) -> c (Complex e) + -- these next two are now weird given we have Floats as well real :: c Double -> c e complex :: c e -> c (Complex Double) @@ -471,6 +472,14 @@ instance Container Vector Double where real = id complex = comp +instance Container Vector (Complex Float) where + toComplex = undefined -- can't match + fromComplex = undefined + comp = undefined + conj = undefined + real = comp . mapVector realToFrac + complex = mapVector (\(r :+ i) -> realToFrac r :+ realToFrac i) + instance Container Vector (Complex Double) where toComplex = undefined -- can't match fromComplex = undefined -- cgit v1.2.3