diff options
author | Vivian McPhail <haskell.vivian.mcphail@gmail.com> | 2010-07-09 20:12:19 +0000 |
---|---|---|
committer | Vivian McPhail <haskell.vivian.mcphail@gmail.com> | 2010-07-09 20:12:19 +0000 |
commit | 07bd78f10f2bcce8a5e9838d73754ab4d27f6d1c (patch) | |
tree | ac49b4c6eb3331c27ae8efa04ecbc9c553160eec /lib/Data/Packed/Internal | |
parent | 238a01e0c3b51569c28ede4259cdf33bf18eb94f (diff) |
type signatures for use with vector package
Diffstat (limited to 'lib/Data/Packed/Internal')
-rw-r--r-- | lib/Data/Packed/Internal/Matrix.hs | 4 | ||||
-rw-r--r-- | lib/Data/Packed/Internal/Vector.hs | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs index 861c72a..100b8ea 100644 --- a/lib/Data/Packed/Internal/Matrix.hs +++ b/lib/Data/Packed/Internal/Matrix.hs | |||
@@ -391,11 +391,11 @@ conjV :: (Storable a, RealFloat a) => Vector (Complex a) -> Vector (Complex a) | |||
391 | conjV = mapVector conjugate | 391 | conjV = mapVector conjugate |
392 | 392 | ||
393 | -- | creates a complex vector from vectors with real and imaginary parts | 393 | -- | creates a complex vector from vectors with real and imaginary parts |
394 | toComplexV :: Element a => (Vector a, Vector a) -> Vector (Complex a) | 394 | toComplexV :: (RealFloat a, Element a) => (Vector a, Vector a) -> Vector (Complex a) |
395 | toComplexV (r,i) = asComplex $ flatten $ fromColumns [r,i] | 395 | toComplexV (r,i) = asComplex $ flatten $ fromColumns [r,i] |
396 | 396 | ||
397 | -- | the inverse of 'toComplex' | 397 | -- | the inverse of 'toComplex' |
398 | fromComplexV :: Element a => Vector (Complex a) -> (Vector a, Vector a) | 398 | fromComplexV :: (RealFloat a, Element a) => Vector (Complex a) -> (Vector a, Vector a) |
399 | fromComplexV z = (r,i) where | 399 | fromComplexV z = (r,i) where |
400 | [r,i] = toColumns $ reshape 2 $ asReal z | 400 | [r,i] = toColumns $ reshape 2 $ asReal z |
401 | 401 | ||
diff --git a/lib/Data/Packed/Internal/Vector.hs b/lib/Data/Packed/Internal/Vector.hs index 6d39c6e..dfa2e86 100644 --- a/lib/Data/Packed/Internal/Vector.hs +++ b/lib/Data/Packed/Internal/Vector.hs | |||
@@ -266,13 +266,13 @@ takesV ms w | sum ms > dim w = error $ "takesV " ++ show ms ++ " on dim = " ++ ( | |||
266 | --------------------------------------------------------------- | 266 | --------------------------------------------------------------- |
267 | 267 | ||
268 | -- | transforms a complex vector into a real vector with alternating real and imaginary parts | 268 | -- | transforms a complex vector into a real vector with alternating real and imaginary parts |
269 | asReal :: Vector (Complex a) -> Vector a | 269 | asReal :: (RealFloat a, Storable a) => Vector (Complex a) -> Vector a |
270 | --asReal v = V { ioff = 2*ioff v, idim = 2*dim v, fptr = castForeignPtr (fptr v) } | 270 | --asReal v = V { ioff = 2*ioff v, idim = 2*dim v, fptr = castForeignPtr (fptr v) } |
271 | asReal v = unsafeFromForeignPtr (castForeignPtr fp) (2*i) (2*n) | 271 | asReal v = unsafeFromForeignPtr (castForeignPtr fp) (2*i) (2*n) |
272 | where (fp,i,n) = unsafeToForeignPtr v | 272 | where (fp,i,n) = unsafeToForeignPtr v |
273 | 273 | ||
274 | -- | transforms a real vector into a complex vector with alternating real and imaginary parts | 274 | -- | transforms a real vector into a complex vector with alternating real and imaginary parts |
275 | asComplex :: Vector a -> Vector (Complex a) | 275 | asComplex :: (RealFloat a, Storable a) => Vector a -> Vector (Complex a) |
276 | --asComplex v = V { ioff = ioff v `div` 2, idim = dim v `div` 2, fptr = castForeignPtr (fptr v) } | 276 | --asComplex v = V { ioff = ioff v `div` 2, idim = dim v `div` 2, fptr = castForeignPtr (fptr v) } |
277 | asComplex v = unsafeFromForeignPtr (castForeignPtr fp) (i `div` 2) (n `div` 2) | 277 | asComplex v = unsafeFromForeignPtr (castForeignPtr fp) (i `div` 2) (n `div` 2) |
278 | where (fp,i,n) = unsafeToForeignPtr v | 278 | where (fp,i,n) = unsafeToForeignPtr v |