diff options
author | Alberto Ruiz <aruiz@um.es> | 2007-06-22 17:33:17 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2007-06-22 17:33:17 +0000 |
commit | 978e6d038239af50d70bae2c303f4e45b1879b7a (patch) | |
tree | 571b2060f388d0693820f808b40089acb100a5d9 /lib/Data/Packed/Internal/Vector.hs | |
parent | 989bdf7e88c13500bd1986dcde36f6cc4f467efb (diff) |
refactoring
Diffstat (limited to 'lib/Data/Packed/Internal/Vector.hs')
-rw-r--r-- | lib/Data/Packed/Internal/Vector.hs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/Data/Packed/Internal/Vector.hs b/lib/Data/Packed/Internal/Vector.hs index 8848062..25e848d 100644 --- a/lib/Data/Packed/Internal/Vector.hs +++ b/lib/Data/Packed/Internal/Vector.hs | |||
@@ -103,15 +103,15 @@ asComplex :: Vector Double -> Vector (Complex Double) | |||
103 | asComplex v = V { dim = dim v `div` 2, fptr = castForeignPtr (fptr v), ptr = castPtr (ptr v) } | 103 | asComplex v = V { dim = dim v `div` 2, fptr = castForeignPtr (fptr v), ptr = castPtr (ptr v) } |
104 | 104 | ||
105 | 105 | ||
106 | constantG n x = fromList (replicate n x) | 106 | constantG x n = fromList (replicate n x) |
107 | 107 | ||
108 | constantR :: Int -> Double -> Vector Double | 108 | constantR :: Double -> Int -> Vector Double |
109 | constantR = constantAux cconstantR | 109 | constantR = constantAux cconstantR |
110 | 110 | ||
111 | constantC :: Int -> Complex Double -> Vector (Complex Double) | 111 | constantC :: Complex Double -> Int -> Vector (Complex Double) |
112 | constantC = constantAux cconstantC | 112 | constantC = constantAux cconstantC |
113 | 113 | ||
114 | constantAux fun n x = unsafePerformIO $ do | 114 | constantAux fun x n = unsafePerformIO $ do |
115 | v <- createVector n | 115 | v <- createVector n |
116 | px <- newArray [x] | 116 | px <- newArray [x] |
117 | fun px // vec v // check "constantAux" [] | 117 | fun px // vec v // check "constantAux" [] |
@@ -124,8 +124,8 @@ foreign import ccall safe "aux.h constantR" | |||
124 | foreign import ccall safe "aux.h constantC" | 124 | foreign import ccall safe "aux.h constantC" |
125 | cconstantC :: Ptr (Complex Double) -> TCV -- Complex Double :> IO Int | 125 | cconstantC :: Ptr (Complex Double) -> TCV -- Complex Double :> IO Int |
126 | 126 | ||
127 | constant :: Field a => Int -> a -> Vector a | 127 | constant :: Field a => a -> Int -> Vector a |
128 | constant n x | isReal id x = scast $ constantR n (scast x) | 128 | constant x n | isReal id x = scast $ constantR (scast x) n |
129 | | isComp id x = scast $ constantC n (scast x) | 129 | | isComp id x = scast $ constantC (scast x) n |
130 | | otherwise = constantG n x | 130 | | otherwise = constantG x n |
131 | 131 | ||