summaryrefslogtreecommitdiff
path: root/lib/LAPACK
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-06-08 23:07:45 +0000
committerAlberto Ruiz <aruiz@um.es>2007-06-08 23:07:45 +0000
commite21f42f742959ec9452add9b6c6e08d30d9584ed (patch)
tree25b0fe2e085a021b3d05305c759aa15ab1b17bff /lib/LAPACK
parent8050c64f706c027e0446b892ca64814a174013a4 (diff)
diagRect, svdC
Diffstat (limited to 'lib/LAPACK')
-rw-r--r--lib/LAPACK/Internal.hs21
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@.
33svdR :: Matrix Double -> (Matrix Double, Matrix Double , Matrix Double) 33svdR :: Matrix Double -> (Matrix Double, Matrix Double , Matrix Double)
34svdR x@M {rows = r, cols = c} = (u, s, v) 34svdR 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
41svdR' x@M {rows = r, cols = c} = unsafePerformIO $ do 36svdR' 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"
55foreign import ccall "lapack-aux.h svd_l_C" 50foreign 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@.
56svdC :: Matrix (Complex Double)
57 -> (Matrix (Complex Double), Matrix Double, Matrix (Complex Double))
58svdC x@M {rows = r, cols = c} = (u, diagRect s r c, v) where (u,s,v) = svdC' x
59
60svdC' 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
60foreign import ccall "lapack-aux.h eig_l_C" 69foreign import ccall "lapack-aux.h eig_l_C"