summaryrefslogtreecommitdiff
path: root/lib/Numeric/LinearAlgebra/LAPACK.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Numeric/LinearAlgebra/LAPACK.hs')
-rw-r--r--lib/Numeric/LinearAlgebra/LAPACK.hs39
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
26import Data.Packed.Internal 27import Data.Packed.Internal
@@ -284,7 +285,7 @@ linearSolveSVDC_l rcond a b = unsafePerformIO $ do
284----------------------------------------------------------------------------------- 285-----------------------------------------------------------------------------------
285foreign import ccall "LAPACK/lapack-aux.h chol_l_H" zpotrf :: TCMCM 286foreign 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.
289cholH :: Matrix (Complex Double) -> Matrix (Complex Double) 290cholH :: Matrix (Complex Double) -> Matrix (Complex Double)
290cholH a = unsafePerformIO $ do 291cholH a = unsafePerformIO $ do
@@ -296,7 +297,7 @@ cholH a = unsafePerformIO $ do
296----------------------------------------------------------------------------------- 297-----------------------------------------------------------------------------------
297foreign import ccall "LAPACK/lapack-aux.h chol_l_S" dpotrf :: TMM 298foreign 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.
301cholS :: Matrix Double -> Matrix Double 302cholS :: Matrix Double -> Matrix Double
302cholS a = unsafePerformIO $ do 303cholS a = unsafePerformIO $ do
@@ -308,7 +309,7 @@ cholS a = unsafePerformIO $ do
308----------------------------------------------------------------------------------- 309-----------------------------------------------------------------------------------
309foreign import ccall "LAPACK/lapack-aux.h qr_l_R" dgeqr2 :: TMVM 310foreign 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.
312qrR :: Matrix Double -> (Matrix Double, Vector Double) 313qrR :: Matrix Double -> (Matrix Double, Vector Double)
313qrR a = unsafePerformIO $ do 314qrR 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-----------------------------------------------------------------------------------
323foreign import ccall "LAPACK/lapack-aux.h qr_l_C" zgeqr2 :: TCMCVCM 324foreign 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.
326qrC :: Matrix (Complex Double) -> (Matrix (Complex Double), Vector (Complex Double)) 327qrC :: Matrix (Complex Double) -> (Matrix (Complex Double), Vector (Complex Double))
327qrC a = unsafePerformIO $ do 328qrC 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-----------------------------------------------------------------------------------
338foreign 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.
341hessR :: Matrix Double -> (Matrix Double, Vector Double)
342hessR 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-----------------------------------------------------------------------------------
352foreign 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.
355hessC :: Matrix (Complex Double) -> (Matrix (Complex Double), Vector (Complex Double))
356hessC 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