diff options
author | Alberto Ruiz <aruiz@um.es> | 2007-06-23 20:21:03 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2007-06-23 20:21:03 +0000 |
commit | 3d5d6f06598aac00906c93ac5358e68697c47fc7 (patch) | |
tree | 77a76afcd561b8beee33c39b4eafe72b4fa10b86 /lib/LAPACK.hs | |
parent | 978e6d038239af50d70bae2c303f4e45b1879b7a (diff) |
more refactoring
Diffstat (limited to 'lib/LAPACK.hs')
-rw-r--r-- | lib/LAPACK.hs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/LAPACK.hs b/lib/LAPACK.hs index 602f5df..ff8889f 100644 --- a/lib/LAPACK.hs +++ b/lib/LAPACK.hs | |||
@@ -36,9 +36,10 @@ foreign import ccall "LAPACK/lapack-aux.h svd_l_R" dgesvd :: TMMVM | |||
36 | -- | Wrapper for LAPACK's /dgesvd/, which computes the full svd decomposition of a real matrix. | 36 | -- | Wrapper for LAPACK's /dgesvd/, which computes the full svd decomposition of a real matrix. |
37 | -- | 37 | -- |
38 | -- @(u,s,v)=svdR m@ so that @m=u \<\> s \<\> 'trans' v@. | 38 | -- @(u,s,v)=svdR m@ so that @m=u \<\> s \<\> 'trans' v@. |
39 | svdR :: Matrix Double -> (Matrix Double, Matrix Double , Matrix Double) | 39 | svdR :: Matrix Double -> (Matrix Double, Matrix Double, Matrix Double) |
40 | svdR x@M {rows = r, cols = c} = (u, diagRect s r c, v) where (u,s,v) = svdR' x | 40 | svdR x@M {rows = r, cols = c} = (u, diagRect s r c, v) where (u,s,v) = svdR' x |
41 | 41 | ||
42 | svdR' :: Matrix Double -> (Matrix Double, Vector Double, Matrix Double) | ||
42 | svdR' x@M {rows = r, cols = c} = unsafePerformIO $ do | 43 | svdR' x@M {rows = r, cols = c} = unsafePerformIO $ do |
43 | u <- createMatrix ColumnMajor r r | 44 | u <- createMatrix ColumnMajor r r |
44 | s <- createVector (min r c) | 45 | s <- createVector (min r c) |
@@ -55,6 +56,7 @@ foreign import ccall "LAPACK/lapack-aux.h svd_l_Rdd" dgesdd :: TMMVM | |||
55 | svdRdd :: Matrix Double -> (Matrix Double, Matrix Double , Matrix Double) | 56 | svdRdd :: Matrix Double -> (Matrix Double, Matrix Double , Matrix Double) |
56 | svdRdd x@M {rows = r, cols = c} = (u, diagRect s r c, v) where (u,s,v) = svdRdd' x | 57 | svdRdd x@M {rows = r, cols = c} = (u, diagRect s r c, v) where (u,s,v) = svdRdd' x |
57 | 58 | ||
59 | svdRdd' :: Matrix Double -> (Matrix Double, Vector Double, Matrix Double) | ||
58 | svdRdd' x@M {rows = r, cols = c} = unsafePerformIO $ do | 60 | svdRdd' x@M {rows = r, cols = c} = unsafePerformIO $ do |
59 | u <- createMatrix ColumnMajor r r | 61 | u <- createMatrix ColumnMajor r r |
60 | s <- createVector (min r c) | 62 | s <- createVector (min r c) |
@@ -68,10 +70,10 @@ foreign import ccall "LAPACK/lapack-aux.h svd_l_C" zgesvd :: TCMCMVCM | |||
68 | -- | Wrapper for LAPACK's /zgesvd/, which computes the full svd decomposition of a complex matrix. | 70 | -- | Wrapper for LAPACK's /zgesvd/, which computes the full svd decomposition of a complex matrix. |
69 | -- | 71 | -- |
70 | -- @(u,s,v)=svdC m@ so that @m=u \<\> s \<\> 'trans' v@. | 72 | -- @(u,s,v)=svdC m@ so that @m=u \<\> s \<\> 'trans' v@. |
71 | svdC :: Matrix (Complex Double) | 73 | svdC :: Matrix (Complex Double) -> (Matrix (Complex Double), Matrix Double, Matrix (Complex Double)) |
72 | -> (Matrix (Complex Double), Matrix Double, Matrix (Complex Double)) | ||
73 | svdC x@M {rows = r, cols = c} = (u, diagRect s r c, v) where (u,s,v) = svdC' x | 74 | svdC x@M {rows = r, cols = c} = (u, diagRect s r c, v) where (u,s,v) = svdC' x |
74 | 75 | ||
76 | svdC' :: Matrix (Complex Double) -> (Matrix (Complex Double), Vector Double, Matrix (Complex Double)) | ||
75 | svdC' x@M {rows = r, cols = c} = unsafePerformIO $ do | 77 | svdC' x@M {rows = r, cols = c} = unsafePerformIO $ do |
76 | u <- createMatrix ColumnMajor r r | 78 | u <- createMatrix ColumnMajor r r |
77 | s <- createVector (min r c) | 79 | s <- createVector (min r c) |