diff options
Diffstat (limited to 'lib/Numeric/LinearAlgebra/LAPACK.hs')
-rw-r--r-- | lib/Numeric/LinearAlgebra/LAPACK.hs | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/lib/Numeric/LinearAlgebra/LAPACK.hs b/lib/Numeric/LinearAlgebra/LAPACK.hs index 648e59f..a84a17e 100644 --- a/lib/Numeric/LinearAlgebra/LAPACK.hs +++ b/lib/Numeric/LinearAlgebra/LAPACK.hs | |||
@@ -20,7 +20,8 @@ module Numeric.LinearAlgebra.LAPACK ( | |||
20 | linearSolveLSR, linearSolveLSC, | 20 | linearSolveLSR, linearSolveLSC, |
21 | linearSolveSVDR, linearSolveSVDC, | 21 | linearSolveSVDR, linearSolveSVDC, |
22 | cholS, cholH, | 22 | cholS, cholH, |
23 | qrR, qrC | 23 | qrR, qrC, |
24 | hessR, hessC | ||
24 | ) where | 25 | ) where |
25 | 26 | ||
26 | import Data.Packed.Internal | 27 | import Data.Packed.Internal |
@@ -284,7 +285,7 @@ linearSolveSVDC_l rcond a b = unsafePerformIO $ do | |||
284 | ----------------------------------------------------------------------------------- | 285 | ----------------------------------------------------------------------------------- |
285 | foreign import ccall "LAPACK/lapack-aux.h chol_l_H" zpotrf :: TCMCM | 286 | foreign import ccall "LAPACK/lapack-aux.h chol_l_H" zpotrf :: TCMCM |
286 | 287 | ||
287 | -- | Wrapper for LAPACK's /zpotrf/,which computes the Cholesky factorization of a | 288 | -- | Wrapper for LAPACK's /zpotrf/, which computes the Cholesky factorization of a |
288 | -- complex Hermitian positive definite matrix. | 289 | -- complex Hermitian positive definite matrix. |
289 | cholH :: Matrix (Complex Double) -> Matrix (Complex Double) | 290 | cholH :: Matrix (Complex Double) -> Matrix (Complex Double) |
290 | cholH a = unsafePerformIO $ do | 291 | cholH a = unsafePerformIO $ do |
@@ -296,7 +297,7 @@ cholH a = unsafePerformIO $ do | |||
296 | ----------------------------------------------------------------------------------- | 297 | ----------------------------------------------------------------------------------- |
297 | foreign import ccall "LAPACK/lapack-aux.h chol_l_S" dpotrf :: TMM | 298 | foreign import ccall "LAPACK/lapack-aux.h chol_l_S" dpotrf :: TMM |
298 | 299 | ||
299 | -- | Wrapper for LAPACK's /dpotrf/,which computes the Cholesky factorization of a | 300 | -- | Wrapper for LAPACK's /dpotrf/, which computes the Cholesky factorization of a |
300 | -- real symmetric positive definite matrix. | 301 | -- real symmetric positive definite matrix. |
301 | cholS :: Matrix Double -> Matrix Double | 302 | cholS :: Matrix Double -> Matrix Double |
302 | cholS a = unsafePerformIO $ do | 303 | cholS a = unsafePerformIO $ do |
@@ -308,7 +309,7 @@ cholS a = unsafePerformIO $ do | |||
308 | ----------------------------------------------------------------------------------- | 309 | ----------------------------------------------------------------------------------- |
309 | foreign import ccall "LAPACK/lapack-aux.h qr_l_R" dgeqr2 :: TMVM | 310 | foreign import ccall "LAPACK/lapack-aux.h qr_l_R" dgeqr2 :: TMVM |
310 | 311 | ||
311 | -- | Wrapper for LAPACK's /dgeqr2/,which computes a QR factorization of a real matrix. | 312 | -- | Wrapper for LAPACK's /dgeqr2/, which computes a QR factorization of a real matrix. |
312 | qrR :: Matrix Double -> (Matrix Double, Vector Double) | 313 | qrR :: Matrix Double -> (Matrix Double, Vector Double) |
313 | qrR a = unsafePerformIO $ do | 314 | qrR a = unsafePerformIO $ do |
314 | r <- createMatrix ColumnMajor m n | 315 | r <- createMatrix ColumnMajor m n |
@@ -322,7 +323,7 @@ qrR a = unsafePerformIO $ do | |||
322 | ----------------------------------------------------------------------------------- | 323 | ----------------------------------------------------------------------------------- |
323 | foreign import ccall "LAPACK/lapack-aux.h qr_l_C" zgeqr2 :: TCMCVCM | 324 | foreign import ccall "LAPACK/lapack-aux.h qr_l_C" zgeqr2 :: TCMCVCM |
324 | 325 | ||
325 | -- | Wrapper for LAPACK's /zgeqr2/,which computes a QR factorization of a complex matrix. | 326 | -- | 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 :: Matrix (Complex Double) -> (Matrix (Complex Double), Vector (Complex Double)) |
327 | qrC a = unsafePerformIO $ do | 328 | qrC a = unsafePerformIO $ do |
328 | r <- createMatrix ColumnMajor m n | 329 | r <- createMatrix ColumnMajor m n |
@@ -333,3 +334,31 @@ qrC a = unsafePerformIO $ do | |||
333 | n = cols a | 334 | n = cols a |
334 | mn = min m n | 335 | mn = min m n |
335 | 336 | ||
337 | ----------------------------------------------------------------------------------- | ||
338 | foreign import ccall "LAPACK/lapack-aux.h hess_l_R" dgehrd :: TMVM | ||
339 | |||
340 | -- | Wrapper for LAPACK's /dgehrd/, which computes a Hessenberg factorization of a square real matrix. | ||
341 | hessR :: Matrix Double -> (Matrix Double, Vector Double) | ||
342 | hessR a = unsafePerformIO $ do | ||
343 | r <- createMatrix ColumnMajor m n | ||
344 | tau <- createVector (mn-1) | ||
345 | dgehrd // mat fdat a // vec tau // mat dat r // check "hessR" [fdat a] | ||
346 | return (r,tau) | ||
347 | where m = rows a | ||
348 | n = cols a | ||
349 | mn = min m n | ||
350 | |||
351 | ----------------------------------------------------------------------------------- | ||
352 | foreign import ccall "LAPACK/lapack-aux.h hess_l_C" zgehrd :: TCMCVCM | ||
353 | |||
354 | -- | Wrapper for LAPACK's /zgeqr2/, which computes a Hessenberg factorization of a square complex matrix. | ||
355 | hessC :: Matrix (Complex Double) -> (Matrix (Complex Double), Vector (Complex Double)) | ||
356 | hessC a = unsafePerformIO $ do | ||
357 | r <- createMatrix ColumnMajor m n | ||
358 | tau <- createVector (mn-1) | ||
359 | zgehrd // mat fdat a // vec tau // mat dat r // check "hessC" [fdat a] | ||
360 | return (r,tau) | ||
361 | where m = rows a | ||
362 | n = cols a | ||
363 | mn = min m n | ||
364 | |||