diff options
author | Alberto Ruiz <aruiz@um.es> | 2008-06-10 08:31:27 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2008-06-10 08:31:27 +0000 |
commit | 53b361e5b9840273ccfd50e5b256002498a97469 (patch) | |
tree | c96ae1a373cd6884821f4b74b9e6cabd5e6f2204 /lib/Data/Packed/Internal/Matrix.hs | |
parent | 9cb72979acc7bcd9df2fa8eab05169d9c5ca84f5 (diff) |
added examples/benchmarks.hs
Diffstat (limited to 'lib/Data/Packed/Internal/Matrix.hs')
-rw-r--r-- | lib/Data/Packed/Internal/Matrix.hs | 27 |
1 files changed, 0 insertions, 27 deletions
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs index 7a35a61..caf3699 100644 --- a/lib/Data/Packed/Internal/Matrix.hs +++ b/lib/Data/Packed/Internal/Matrix.hs | |||
@@ -394,30 +394,3 @@ fromFile filename (r,c) = do | |||
394 | --free charname -- TO DO: free the auxiliary CString | 394 | --free charname -- TO DO: free the auxiliary CString |
395 | return res | 395 | return res |
396 | foreign import ccall "auxi.h matrix_fscanf" c_gslReadMatrix:: Ptr CChar -> TM | 396 | foreign import ccall "auxi.h matrix_fscanf" c_gslReadMatrix:: Ptr CChar -> TM |
397 | |||
398 | ---------------------------------------------------------------------------- | ||
399 | |||
400 | {- | creates a new matrix with the given position updated with a modification function | ||
401 | |||
402 | @> updateMatrix (0,2) (const 57) (ident 3 :: Matrix Double) | ||
403 | (3><3) | ||
404 | [ 1.0, 0.0, 57.0 | ||
405 | , 0.0, 1.0, 0.0 | ||
406 | , 0.0, 0.0, 1.0 ]@ | ||
407 | |||
408 | -} | ||
409 | updateMatrix :: Storable t | ||
410 | => (Int,Int) -- ^ position (row,column) | ||
411 | -> (t -> t) -- ^ modification function | ||
412 | -> Matrix t -- ^ source matrix | ||
413 | -> Matrix t -- ^ result | ||
414 | |||
415 | updateMatrix (i,j) f (m@MC {rows = r, cols = c, cdat = v}) | ||
416 | | i<0 || i>=r || j<0 || j>=c = error $ "updateMatrix out of range(size="++show (r,c)++", pos="++show (i,j)++")" | ||
417 | | otherwise = let pos = i*c+j | ||
418 | in m { cdat = updateVector pos f v } | ||
419 | |||
420 | updateMatrix (i,j) f (m@MF {rows = r, cols = c, fdat = v}) | ||
421 | | i<0 || i>=r || j<0 || j>=c = error $ "updateMatrix out of range(size="++show (r,c)++", pos="++show (i,j)++")" | ||
422 | | otherwise = let pos = j*r+i | ||
423 | in m { fdat = updateVector pos f v } | ||