diff options
author | Alberto Ruiz <aruiz@um.es> | 2007-06-08 23:07:45 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2007-06-08 23:07:45 +0000 |
commit | e21f42f742959ec9452add9b6c6e08d30d9584ed (patch) | |
tree | 25b0fe2e085a021b3d05305c759aa15ab1b17bff /lib/LAPACK | |
parent | 8050c64f706c027e0446b892ca64814a174013a4 (diff) |
diagRect, svdC
Diffstat (limited to 'lib/LAPACK')
-rw-r--r-- | lib/LAPACK/Internal.hs | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/LAPACK/Internal.hs b/lib/LAPACK/Internal.hs index 2569215..e39dd10 100644 --- a/lib/LAPACK/Internal.hs +++ b/lib/LAPACK/Internal.hs | |||
@@ -31,12 +31,7 @@ foreign import ccall "lapack-aux.h svd_l_R" | |||
31 | -- | 31 | -- |
32 | -- @(u,s,v)=svdR m@ so that @m=u \<\> s \<\> 'trans' v@. | 32 | -- @(u,s,v)=svdR m@ so that @m=u \<\> s \<\> 'trans' v@. |
33 | svdR :: Matrix Double -> (Matrix Double, Matrix Double , Matrix Double) | 33 | svdR :: Matrix Double -> (Matrix Double, Matrix Double , Matrix Double) |
34 | svdR x@M {rows = r, cols = c} = (u, s, v) | 34 | svdR x@M {rows = r, cols = c} = (u, diagRect s r c, v) where (u,s,v) = svdR' x |
35 | where (u,s',v) = svdR' x | ||
36 | s | r == c = diag s' | ||
37 | | r < c = joinHoriz [diag s' , zeros (r,c-r)] | ||
38 | | otherwise = joinVert [diag s' , zeros (r-c,c)] | ||
39 | zeros (r,c) = reshape c $ constant (r*c) 0 | ||
40 | 35 | ||
41 | svdR' x@M {rows = r, cols = c} = unsafePerformIO $ do | 36 | svdR' x@M {rows = r, cols = c} = unsafePerformIO $ do |
42 | u <- createMatrix ColumnMajor r r | 37 | u <- createMatrix ColumnMajor r r |
@@ -55,6 +50,20 @@ foreign import ccall "lapack-aux.h svd_l_Rdd" | |||
55 | foreign import ccall "lapack-aux.h svd_l_C" | 50 | foreign import ccall "lapack-aux.h svd_l_C" |
56 | zgesvd :: (Complex Double) ::> (Complex Double) ::> (Double :> (Complex Double) ::> IO Int) | 51 | zgesvd :: (Complex Double) ::> (Complex Double) ::> (Double :> (Complex Double) ::> IO Int) |
57 | 52 | ||
53 | -- | Wrapper for LAPACK's /zgesvd/, which computes the full svd decomposition of a complex matrix. | ||
54 | -- | ||
55 | -- @(u,s,v)=svdC m@ so that @m=u \<\> s \<\> 'trans' v@. | ||
56 | svdC :: Matrix (Complex Double) | ||
57 | -> (Matrix (Complex Double), Matrix Double, Matrix (Complex Double)) | ||
58 | svdC x@M {rows = r, cols = c} = (u, diagRect s r c, v) where (u,s,v) = svdC' x | ||
59 | |||
60 | svdC' x@M {rows = r, cols = c} = unsafePerformIO $ do | ||
61 | u <- createMatrix ColumnMajor r r | ||
62 | s <- createVector (min r c) | ||
63 | v <- createMatrix ColumnMajor c c | ||
64 | zgesvd // mat fdat x // mat dat u // vec s // mat dat v // check "svdC" [fdat x] | ||
65 | return (u,s,trans v) | ||
66 | |||
58 | ----------------------------------------------------------------------------- | 67 | ----------------------------------------------------------------------------- |
59 | -- zgeev | 68 | -- zgeev |
60 | foreign import ccall "lapack-aux.h eig_l_C" | 69 | foreign import ccall "lapack-aux.h eig_l_C" |