summaryrefslogtreecommitdiff
path: root/lib/Data/Packed/Internal/Matrix.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2008-11-14 11:01:14 +0000
committerAlberto Ruiz <aruiz@um.es>2008-11-14 11:01:14 +0000
commite1b4cc06a5f98e576524b37ad0d9132f0678d722 (patch)
tree8c07f44ea5b138a131eea68348698822239ab5a8 /lib/Data/Packed/Internal/Matrix.hs
parent52305f136a2ea232e354cb2b55c387c2f8930fbc (diff)
constantD
Diffstat (limited to 'lib/Data/Packed/Internal/Matrix.hs')
-rw-r--r--lib/Data/Packed/Internal/Matrix.hs13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs
index 9def473..09f081a 100644
--- a/lib/Data/Packed/Internal/Matrix.hs
+++ b/lib/Data/Packed/Internal/Matrix.hs
@@ -217,14 +217,17 @@ class (Storable a, Floating a) => Element a where
217 -> (Int,Int) -- ^ (rt,ct) dimensions of submatrix 217 -> (Int,Int) -- ^ (rt,ct) dimensions of submatrix
218 -> Matrix a -> Matrix a 218 -> Matrix a -> Matrix a
219 transdata :: Int -> Vector a -> Int -> Vector a 219 transdata :: Int -> Vector a -> Int -> Vector a
220 constantD :: a -> Int -> Vector a
220 221
221instance Element Double where 222instance Element Double where
222 subMatrixD = subMatrixR 223 subMatrixD = subMatrixR
223 transdata = transdata' 224 transdata = transdata'
225 constantD = constant'
224 226
225instance Element (Complex Double) where 227instance Element (Complex Double) where
226 subMatrixD = subMatrixC 228 subMatrixD = subMatrixC
227 transdata = transdata' 229 transdata = transdata'
230 constantD = constant'
228 231
229------------------------------------------------------------------- 232-------------------------------------------------------------------
230 233
@@ -256,6 +259,16 @@ transdata' c1 v c2 =
256 259
257---------------------------------------------------------------------- 260----------------------------------------------------------------------
258 261
262constant' v n = unsafePerformIO $ do
263 w <- createVector n
264 withForeignPtr (fptr w) $ \p -> do
265 let go (-1) = return ()
266 go !k = pokeElemOff p k v >> go (k-1)
267 go (n-1)
268 return w
269
270----------------------------------------------------------------------
271
259-- | extraction of a submatrix from a real matrix 272-- | extraction of a submatrix from a real matrix
260subMatrixR :: (Int,Int) -> (Int,Int) -> Matrix Double -> Matrix Double 273subMatrixR :: (Int,Int) -> (Int,Int) -> Matrix Double -> Matrix Double
261subMatrixR (r0,c0) (rt,ct) x' = unsafePerformIO $ do 274subMatrixR (r0,c0) (rt,ct) x' = unsafePerformIO $ do