diff options
author | Alberto Ruiz <aruiz@um.es> | 2007-12-03 10:43:52 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2007-12-03 10:43:52 +0000 |
commit | c520939e33cc895febed271d5c3218457317bba9 (patch) | |
tree | 8661410a5cb946a3ae40e0c0fbacccccd0fd5ada /lib/Numeric/LinearAlgebra/LAPACK.hs | |
parent | d7d3b731c037fca41bd9128c3da2a582189cb4d9 (diff) |
lapack lu
Diffstat (limited to 'lib/Numeric/LinearAlgebra/LAPACK.hs')
-rw-r--r-- | lib/Numeric/LinearAlgebra/LAPACK.hs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/Numeric/LinearAlgebra/LAPACK.hs b/lib/Numeric/LinearAlgebra/LAPACK.hs index cacad87..83db901 100644 --- a/lib/Numeric/LinearAlgebra/LAPACK.hs +++ b/lib/Numeric/LinearAlgebra/LAPACK.hs | |||
@@ -19,6 +19,7 @@ module Numeric.LinearAlgebra.LAPACK ( | |||
19 | linearSolveR, linearSolveC, | 19 | linearSolveR, linearSolveC, |
20 | linearSolveLSR, linearSolveLSC, | 20 | linearSolveLSR, linearSolveLSC, |
21 | linearSolveSVDR, linearSolveSVDC, | 21 | linearSolveSVDR, linearSolveSVDC, |
22 | luR, luC, | ||
22 | cholS, cholH, | 23 | cholS, cholH, |
23 | qrR, qrC, | 24 | qrR, qrC, |
24 | hessR, hessC, | 25 | hessR, hessC, |
@@ -299,7 +300,7 @@ hessAux f st a = unsafePerformIO $ do | |||
299 | mn = min m n | 300 | mn = min m n |
300 | 301 | ||
301 | ----------------------------------------------------------------------------------- | 302 | ----------------------------------------------------------------------------------- |
302 | foreign import ccall safe "LAPACK/lapack-aux.h schur_l_R" dgees :: TMMM | 303 | foreign import ccall "LAPACK/lapack-aux.h schur_l_R" dgees :: TMMM |
303 | foreign import ccall "LAPACK/lapack-aux.h schur_l_C" zgees :: TCMCMCM | 304 | foreign import ccall "LAPACK/lapack-aux.h schur_l_C" zgees :: TCMCMCM |
304 | 305 | ||
305 | -- | Wrapper for LAPACK's /dgees/, which computes a Schur factorization of a square real matrix. | 306 | -- | Wrapper for LAPACK's /dgees/, which computes a Schur factorization of a square real matrix. |
@@ -318,3 +319,21 @@ schurAux f st a = unsafePerformIO $ do | |||
318 | where n = rows a | 319 | where n = rows a |
319 | 320 | ||
320 | ----------------------------------------------------------------------------------- | 321 | ----------------------------------------------------------------------------------- |
322 | foreign import ccall "LAPACK/lapack-aux.h lu_l_R" dgetrf :: TMVM | ||
323 | foreign import ccall "LAPACK/lapack-aux.h lu_l_C" zgetrf :: TCMVCM | ||
324 | |||
325 | -- | Wrapper for LAPACK's /dgetrf/, which computes a LU factorization of a general real matrix. | ||
326 | luR :: Matrix Double -> (Matrix Double, [Int]) | ||
327 | luR = luAux dgetrf "luR" . fmat | ||
328 | |||
329 | -- | Wrapper for LAPACK's /zgees/, which computes a Schur factorization of a square complex matrix. | ||
330 | luC :: Matrix (Complex Double) -> (Matrix (Complex Double), [Int]) | ||
331 | luC = luAux zgetrf "luC" . fmat | ||
332 | |||
333 | luAux f st a = unsafePerformIO $ do | ||
334 | lu <- createMatrix ColumnMajor n m | ||
335 | piv <- createVector (min n m) | ||
336 | app3 f mat a vec piv mat lu st | ||
337 | return (lu, map (pred.round) (toList piv)) | ||
338 | where n = rows a | ||
339 | m = cols a | ||