diff options
Diffstat (limited to 'lib/Data/Packed/Internal/Matrix.hs')
-rw-r--r-- | lib/Data/Packed/Internal/Matrix.hs | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs index 51fb6f8..477b453 100644 --- a/lib/Data/Packed/Internal/Matrix.hs +++ b/lib/Data/Packed/Internal/Matrix.hs | |||
@@ -208,19 +208,16 @@ compat m1 m2 = rows m1 == rows m2 && cols m1 == cols m2 | |||
208 | 208 | ||
209 | -- | Optimized matrix computations are provided for elements in the Element class. | 209 | -- | Optimized matrix computations are provided for elements in the Element class. |
210 | class (Storable a, Floating a) => Element a where | 210 | class (Storable a, Floating a) => Element a where |
211 | constantD :: a -> Int -> Vector a | ||
212 | transdata :: Int -> Vector a -> Int -> Vector a | 211 | transdata :: Int -> Vector a -> Int -> Vector a |
213 | subMatrixD :: (Int,Int) -- ^ (r0,c0) starting position | 212 | subMatrixD :: (Int,Int) -- ^ (r0,c0) starting position |
214 | -> (Int,Int) -- ^ (rt,ct) dimensions of submatrix | 213 | -> (Int,Int) -- ^ (rt,ct) dimensions of submatrix |
215 | -> Matrix a -> Matrix a | 214 | -> Matrix a -> Matrix a |
216 | 215 | ||
217 | instance Element Double where | 216 | instance Element Double where |
218 | constantD = constantR | ||
219 | transdata = transdataR | 217 | transdata = transdataR |
220 | subMatrixD = subMatrixR | 218 | subMatrixD = subMatrixR |
221 | 219 | ||
222 | instance Element (Complex Double) where | 220 | instance Element (Complex Double) where |
223 | constantD = constantC | ||
224 | transdata = transdataC | 221 | transdata = transdataC |
225 | subMatrixD = subMatrixC | 222 | subMatrixD = subMatrixC |
226 | 223 | ||
@@ -284,31 +281,6 @@ subMatrix :: Element a | |||
284 | -> Matrix a -- ^ result | 281 | -> Matrix a -- ^ result |
285 | subMatrix = subMatrixD | 282 | subMatrix = subMatrixD |
286 | 283 | ||
287 | ------------------------------------------------------------------------ | ||
288 | |||
289 | constantAux fun x n = unsafePerformIO $ do | ||
290 | v <- createVector n | ||
291 | px <- newArray [x] | ||
292 | app1 (fun px) vec v "constantAux" | ||
293 | free px | ||
294 | return v | ||
295 | |||
296 | constantR :: Double -> Int -> Vector Double | ||
297 | constantR = constantAux cconstantR | ||
298 | foreign import ccall "auxi.h constantR" cconstantR :: Ptr Double -> TV | ||
299 | |||
300 | constantC :: Complex Double -> Int -> Vector (Complex Double) | ||
301 | constantC = constantAux cconstantC | ||
302 | foreign import ccall "auxi.h constantC" cconstantC :: Ptr (Complex Double) -> TCV | ||
303 | |||
304 | {- | creates a vector with a given number of equal components: | ||
305 | |||
306 | @> constant 2 7 | ||
307 | 7 |> [2.0,2.0,2.0,2.0,2.0,2.0,2.0]@ | ||
308 | -} | ||
309 | constant :: Element a => a -> Int -> Vector a | ||
310 | constant = constantD | ||
311 | |||
312 | -------------------------------------------------------------------------- | 284 | -------------------------------------------------------------------------- |
313 | 285 | ||
314 | -- | obtains the complex conjugate of a complex vector | 286 | -- | obtains the complex conjugate of a complex vector |
@@ -329,10 +301,6 @@ fromComplex :: Vector (Complex Double) -> (Vector Double, Vector Double) | |||
329 | fromComplex z = (r,i) where | 301 | fromComplex z = (r,i) where |
330 | [r,i] = toColumns $ reshape 2 $ asReal z | 302 | [r,i] = toColumns $ reshape 2 $ asReal z |
331 | 303 | ||
332 | -- | converts a real vector into a complex representation (with zero imaginary parts) | ||
333 | comp :: Vector Double -> Vector (Complex Double) | ||
334 | comp v = toComplex (v,constant 0 (dim v)) | ||
335 | |||
336 | -- | loads a matrix efficiently from formatted ASCII text file (the number of rows and columns must be known in advance). | 304 | -- | loads a matrix efficiently from formatted ASCII text file (the number of rows and columns must be known in advance). |
337 | fromFile :: FilePath -> (Int,Int) -> IO (Matrix Double) | 305 | fromFile :: FilePath -> (Int,Int) -> IO (Matrix Double) |
338 | fromFile filename (r,c) = do | 306 | fromFile filename (r,c) = do |