summaryrefslogtreecommitdiff
path: root/lib/Data/Packed/Internal/Vector.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-06-22 17:33:17 +0000
committerAlberto Ruiz <aruiz@um.es>2007-06-22 17:33:17 +0000
commit978e6d038239af50d70bae2c303f4e45b1879b7a (patch)
tree571b2060f388d0693820f808b40089acb100a5d9 /lib/Data/Packed/Internal/Vector.hs
parent989bdf7e88c13500bd1986dcde36f6cc4f467efb (diff)
refactoring
Diffstat (limited to 'lib/Data/Packed/Internal/Vector.hs')
-rw-r--r--lib/Data/Packed/Internal/Vector.hs16
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)
103asComplex v = V { dim = dim v `div` 2, fptr = castForeignPtr (fptr v), ptr = castPtr (ptr v) } 103asComplex v = V { dim = dim v `div` 2, fptr = castForeignPtr (fptr v), ptr = castPtr (ptr v) }
104 104
105 105
106constantG n x = fromList (replicate n x) 106constantG x n = fromList (replicate n x)
107 107
108constantR :: Int -> Double -> Vector Double 108constantR :: Double -> Int -> Vector Double
109constantR = constantAux cconstantR 109constantR = constantAux cconstantR
110 110
111constantC :: Int -> Complex Double -> Vector (Complex Double) 111constantC :: Complex Double -> Int -> Vector (Complex Double)
112constantC = constantAux cconstantC 112constantC = constantAux cconstantC
113 113
114constantAux fun n x = unsafePerformIO $ do 114constantAux 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"
124foreign import ccall safe "aux.h constantC" 124foreign 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
127constant :: Field a => Int -> a -> Vector a 127constant :: Field a => a -> Int -> Vector a
128constant n x | isReal id x = scast $ constantR n (scast x) 128constant 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