diff options
author | Alberto Ruiz <aruiz@um.es> | 2007-09-14 18:23:20 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2007-09-14 18:23:20 +0000 |
commit | d14515a4a50d5b5335f9c1525432b68ab67fa7c8 (patch) | |
tree | fb07b2e27b4b5cebc32a3c7ee064ef376344d7e7 /lib/Data/Packed/Internal | |
parent | 9e2f7fb0ca902665b430a96f77959522976a97f9 (diff) |
more refactoring
Diffstat (limited to 'lib/Data/Packed/Internal')
-rw-r--r-- | lib/Data/Packed/Internal/Matrix.hs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs index 89a162a..58b325c 100644 --- a/lib/Data/Packed/Internal/Matrix.hs +++ b/lib/Data/Packed/Internal/Matrix.hs | |||
@@ -348,7 +348,7 @@ foreign import ccall safe "aux.h constantC" | |||
348 | @> constant 2 7 | 348 | @> constant 2 7 |
349 | 7 |> [2.0,2.0,2.0,2.0,2.0,2.0,2.0]@ | 349 | 7 |> [2.0,2.0,2.0,2.0,2.0,2.0,2.0]@ |
350 | -} | 350 | -} |
351 | constant :: Field a => a -> Int -> Vector a | 351 | constant :: Double -> Int -> Vector Double |
352 | constant = constantD | 352 | constant = constantD |
353 | 353 | ||
354 | -------------------------------------------------------------------------- | 354 | -------------------------------------------------------------------------- |
@@ -361,6 +361,11 @@ conj v = asComplex $ cdat $ reshape 2 (asReal v) `multiply` diag (fromList [1,-1 | |||
361 | toComplex :: (Vector Double, Vector Double) -> Vector (Complex Double) | 361 | toComplex :: (Vector Double, Vector Double) -> Vector (Complex Double) |
362 | toComplex (r,i) = asComplex $ cdat $ fromColumns [r,i] | 362 | toComplex (r,i) = asComplex $ cdat $ fromColumns [r,i] |
363 | 363 | ||
364 | -- | the inverse of 'toComplex' | ||
365 | fromComplex :: Vector (Complex Double) -> (Vector Double, Vector Double) | ||
366 | fromComplex z = (r,i) where | ||
367 | [r,i] = toColumns $ reshape 2 $ asReal z | ||
368 | |||
364 | -- | converts a real vector into a complex representation (with zero imaginary parts) | 369 | -- | converts a real vector into a complex representation (with zero imaginary parts) |
365 | comp :: Vector Double -> Vector (Complex Double) | 370 | comp :: Vector Double -> Vector (Complex Double) |
366 | comp v = toComplex (v,constant 0 (dim v)) | 371 | comp v = toComplex (v,constant 0 (dim v)) |