diff options
author | Vivian McPhail <haskell.vivian.mcphail@gmail.com> | 2010-09-21 03:05:52 +0000 |
---|---|---|
committer | Vivian McPhail <haskell.vivian.mcphail@gmail.com> | 2010-09-21 03:05:52 +0000 |
commit | 7b8680256893a8624fab8d1d256773919df70068 (patch) | |
tree | b5efd7cec14fc0cb0c8843dd5f998de64d8eebb1 /lib/Data/Packed/Internal | |
parent | 44d228ad83e876d45d1511761d7cd61bb2cd5c79 (diff) |
move conjugate* to Container
The benefit of this patch is that Data.Packed.Internal.Matrix now has no numeric dependency.
There is no 'optimisation' class for conjugateD, instead, different instances are directly specified in each Container instance.
Unfortunately, an unsafeIO call now exists in Numeric.Container.
Diffstat (limited to 'lib/Data/Packed/Internal')
-rw-r--r-- | lib/Data/Packed/Internal/Matrix.hs | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs index f3bab76..7b823de 100644 --- a/lib/Data/Packed/Internal/Matrix.hs +++ b/lib/Data/Packed/Internal/Matrix.hs | |||
@@ -257,28 +257,30 @@ class (Storable a) => Element a where | |||
257 | transdata = transdataP -- transdata' | 257 | transdata = transdataP -- transdata' |
258 | constantD :: a -> Int -> Vector a | 258 | constantD :: a -> Int -> Vector a |
259 | constantD = constantP -- constant' | 259 | constantD = constantP -- constant' |
260 | {- | ||
260 | conjugateD :: Vector a -> Vector a | 261 | conjugateD :: Vector a -> Vector a |
261 | conjugateD = id | 262 | conjugateD = id |
263 | -} | ||
262 | 264 | ||
263 | instance Element Float where | 265 | instance Element Float where |
264 | transdata = transdataAux ctransF | 266 | transdata = transdataAux ctransF |
265 | constantD = constantAux cconstantF | 267 | constantD = constantAux cconstantF |
266 | conjugateD = id | 268 | -- conjugateD = id |
267 | 269 | ||
268 | instance Element Double where | 270 | instance Element Double where |
269 | transdata = transdataAux ctransR | 271 | transdata = transdataAux ctransR |
270 | constantD = constantAux cconstantR | 272 | constantD = constantAux cconstantR |
271 | conjugateD = id | 273 | -- conjugateD = id |
272 | 274 | ||
273 | instance Element (Complex Float) where | 275 | instance Element (Complex Float) where |
274 | transdata = transdataAux ctransQ | 276 | transdata = transdataAux ctransQ |
275 | constantD = constantAux cconstantQ | 277 | constantD = constantAux cconstantQ |
276 | conjugateD = conjugateQ | 278 | -- conjugateD = conjugateQ |
277 | 279 | ||
278 | instance Element (Complex Double) where | 280 | instance Element (Complex Double) where |
279 | transdata = transdataAux ctransC | 281 | transdata = transdataAux ctransC |
280 | constantD = constantAux cconstantC | 282 | constantD = constantAux cconstantC |
281 | conjugateD = conjugateC | 283 | -- conjugateD = conjugateC |
282 | 284 | ||
283 | ------------------------------------------------------------------- | 285 | ------------------------------------------------------------------- |
284 | 286 | ||
@@ -390,21 +392,6 @@ constantP a n = unsafePerformIO $ do | |||
390 | return v | 392 | return v |
391 | foreign import ccall "constantP" cconstantP :: Ptr () -> CInt -> Ptr () -> CInt -> IO CInt | 393 | foreign import ccall "constantP" cconstantP :: Ptr () -> CInt -> Ptr () -> CInt -> IO CInt |
392 | 394 | ||
393 | --------------------------------------- | ||
394 | |||
395 | conjugateAux fun x = unsafePerformIO $ do | ||
396 | v <- createVector (dim x) | ||
397 | app2 fun vec x vec v "conjugateAux" | ||
398 | return v | ||
399 | |||
400 | conjugateQ :: Vector (Complex Float) -> Vector (Complex Float) | ||
401 | conjugateQ = conjugateAux c_conjugateQ | ||
402 | foreign import ccall "conjugateQ" c_conjugateQ :: TQVQV | ||
403 | |||
404 | conjugateC :: Vector (Complex Double) -> Vector (Complex Double) | ||
405 | conjugateC = conjugateAux c_conjugateC | ||
406 | foreign import ccall "conjugateC" c_conjugateC :: TCVCV | ||
407 | |||
408 | ---------------------------------------------------------------------- | 395 | ---------------------------------------------------------------------- |
409 | 396 | ||
410 | -- | Extracts a submatrix from a matrix. | 397 | -- | Extracts a submatrix from a matrix. |