diff options
author | Alberto Ruiz <aruiz@um.es> | 2008-11-11 09:31:47 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2008-11-11 09:31:47 +0000 |
commit | 52305f136a2ea232e354cb2b55c387c2f8930fbc (patch) | |
tree | 479f5e77cef7ba34ba5882f1c613bd9d10a68d1d /lib/Data | |
parent | cbf4fdb7600949d61433623bfbd63a6ef5fe696f (diff) |
fix transdata
Diffstat (limited to 'lib/Data')
-rw-r--r-- | lib/Data/Packed/Internal/Matrix.hs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs index a32a782..9def473 100644 --- a/lib/Data/Packed/Internal/Matrix.hs +++ b/lib/Data/Packed/Internal/Matrix.hs | |||
@@ -234,21 +234,19 @@ transdata' c1 v c2 = | |||
234 | then v | 234 | then v |
235 | else unsafePerformIO $ do | 235 | else unsafePerformIO $ do |
236 | w <- createVector (r2*c2) | 236 | w <- createVector (r2*c2) |
237 | let p = unsafeForeignPtrToPtr (fptr v) | 237 | withForeignPtr (fptr v) $ \p -> |
238 | q = unsafeForeignPtrToPtr (fptr w) | 238 | withForeignPtr (fptr w) $ \q -> do |
239 | go (-1) _ = return () | 239 | let go (-1) _ = return () |
240 | go !i (-1) = go (i-1) (c1-1) | 240 | go !i (-1) = go (i-1) (c1-1) |
241 | go !i !j = do x <- peekElemOff p (i*c1+j) | 241 | go !i !j = do x <- peekElemOff p (i*c1+j) |
242 | pokeElemOff q (j*c2+i) x | 242 | pokeElemOff q (j*c2+i) x |
243 | go i (j-1) | 243 | go i (j-1) |
244 | go (r1-1) (c1-1) | 244 | go (r1-1) (c1-1) |
245 | touchForeignPtr (fptr w) | ||
246 | return w | 245 | return w |
247 | where r1 = dim v `div` c1 | 246 | where r1 = dim v `div` c1 |
248 | r2 = dim v `div` c2 | 247 | r2 = dim v `div` c2 |
249 | noneed = r1 == 1 || c1 == 1 | 248 | noneed = r1 == 1 || c1 == 1 |
250 | 249 | ||
251 | |||
252 | -- {-# SPECIALIZE transdata' :: Int -> Vector Double -> Int -> Vector Double #-} | 250 | -- {-# SPECIALIZE transdata' :: Int -> Vector Double -> Int -> Vector Double #-} |
253 | -- {-# SPECIALIZE transdata' :: Int -> Vector (Complex Double) -> Int -> Vector (Complex Double) #-} | 251 | -- {-# SPECIALIZE transdata' :: Int -> Vector (Complex Double) -> Int -> Vector (Complex Double) #-} |
254 | 252 | ||