diff options
Diffstat (limited to 'lib/Data/Packed/Internal/Matrix.hs')
-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)) |