diff options
Diffstat (limited to 'lib/LAPACK.hs')
-rw-r--r-- | lib/LAPACK.hs | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/lib/LAPACK.hs b/lib/LAPACK.hs index e84647b..43a313b 100644 --- a/lib/LAPACK.hs +++ b/lib/LAPACK.hs | |||
@@ -19,7 +19,8 @@ module LAPACK ( | |||
19 | linearSolveR, linearSolveC, | 19 | linearSolveR, linearSolveC, |
20 | linearSolveLSR, linearSolveLSC, | 20 | linearSolveLSR, linearSolveLSC, |
21 | linearSolveSVDR, linearSolveSVDC, | 21 | linearSolveSVDR, linearSolveSVDC, |
22 | cholS, cholH | 22 | cholS, cholH, |
23 | qrR, qrC | ||
23 | ) where | 24 | ) where |
24 | 25 | ||
25 | import Data.Packed.Internal | 26 | import Data.Packed.Internal |
@@ -304,3 +305,31 @@ cholS a = unsafePerformIO $ do | |||
304 | return r | 305 | return r |
305 | where n = rows a | 306 | where n = rows a |
306 | 307 | ||
308 | ----------------------------------------------------------------------------------- | ||
309 | foreign import ccall "LAPACK/lapack-aux.h qr_l_R" dgeqr2 :: TMVM | ||
310 | |||
311 | -- | Wrapper for LAPACK's /dgeqr2/,which computes a QR factorization of a real matrix. | ||
312 | qrR :: Matrix Double -> (Matrix Double, Vector Double) | ||
313 | qrR a = unsafePerformIO $ do | ||
314 | r <- createMatrix ColumnMajor m n | ||
315 | tau <- createVector mn | ||
316 | dgeqr2 // mat fdat a // vec tau // mat dat r // check "qrR" [fdat a] | ||
317 | return (r,tau) | ||
318 | where m = rows a | ||
319 | n = cols a | ||
320 | mn = min m n | ||
321 | |||
322 | ----------------------------------------------------------------------------------- | ||
323 | foreign import ccall "LAPACK/lapack-aux.h qr_l_C" zgeqr2 :: TCMCVCM | ||
324 | |||
325 | -- | Wrapper for LAPACK's /zgeqr2/,which computes a QR factorization of a complex matrix. | ||
326 | qrC :: Matrix (Complex Double) -> (Matrix (Complex Double), Vector (Complex Double)) | ||
327 | qrC a = unsafePerformIO $ do | ||
328 | r <- createMatrix ColumnMajor m n | ||
329 | tau <- createVector mn | ||
330 | zgeqr2 // mat fdat a // vec tau // mat dat r // check "qrC" [fdat a] | ||
331 | return (r,tau) | ||
332 | where m = rows a | ||
333 | n = cols a | ||
334 | mn = min m n | ||
335 | |||