summaryrefslogtreecommitdiff
path: root/lib/Data/Packed/Internal/Matrix.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Data/Packed/Internal/Matrix.hs')
-rw-r--r--lib/Data/Packed/Internal/Matrix.hs25
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs
index 5892f1c..d39481d 100644
--- a/lib/Data/Packed/Internal/Matrix.hs
+++ b/lib/Data/Packed/Internal/Matrix.hs
@@ -255,27 +255,27 @@ class (Storable a, Floating a) => Element a where
255 transdata = transdata' 255 transdata = transdata'
256 constantD :: a -> Int -> Vector a 256 constantD :: a -> Int -> Vector a
257 constantD = constant' 257 constantD = constant'
258 ctrans' :: Matrix a -> Matrix a 258 conjugateD :: Vector a -> Vector a
259 259
260instance Element Float where 260instance Element Float where
261 transdata = transdataAux ctransF 261 transdata = transdataAux ctransF
262 constantD = constantAux cconstantF 262 constantD = constantAux cconstantF
263 ctrans' = trans 263 conjugateD = id
264 264
265instance Element Double where 265instance Element Double where
266 transdata = transdataAux ctransR 266 transdata = transdataAux ctransR
267 constantD = constantAux cconstantR 267 constantD = constantAux cconstantR
268 ctrans' = trans 268 conjugateD = id
269 269
270instance Element (Complex Float) where 270instance Element (Complex Float) where
271 transdata = transdataAux ctransQ 271 transdata = transdataAux ctransQ
272 constantD = constantAux cconstantQ 272 constantD = constantAux cconstantQ
273 ctrans' = liftMatrix (mapVector conjugate) . trans 273 conjugateD = conjugateQ
274 274
275instance Element (Complex Double) where 275instance Element (Complex Double) where
276 transdata = transdataAux ctransC 276 transdata = transdataAux ctransC
277 constantD = constantAux cconstantC 277 constantD = constantAux cconstantC
278 ctrans' = liftMatrix (mapVector conjugate) . trans 278 conjugateD = conjugateC
279 279
280------------------------------------------------------------------- 280-------------------------------------------------------------------
281 281
@@ -359,6 +359,21 @@ constantC :: Complex Double -> Int -> Vector (Complex Double)
359constantC = constantAux cconstantC 359constantC = constantAux cconstantC
360foreign import ccall "constantC" cconstantC :: Ptr (Complex Double) -> TCV 360foreign import ccall "constantC" cconstantC :: Ptr (Complex Double) -> TCV
361 361
362---------------------------------------
363
364conjugateAux fun x = unsafePerformIO $ do
365 v <- createVector (dim x)
366 app2 fun vec x vec v "conjugateAux"
367 return v
368
369conjugateQ :: Vector (Complex Float) -> Vector (Complex Float)
370conjugateQ = conjugateAux c_conjugateQ
371foreign import ccall "conjugateQ" c_conjugateQ :: TQVQV
372
373conjugateC :: Vector (Complex Double) -> Vector (Complex Double)
374conjugateC = conjugateAux c_conjugateC
375foreign import ccall "conjugateC" c_conjugateC :: TCVCV
376
362---------------------------------------------------------------------- 377----------------------------------------------------------------------
363 378
364-- | Extracts a submatrix from a matrix. 379-- | Extracts a submatrix from a matrix.