summaryrefslogtreecommitdiff
path: root/lib/Numeric/LinearAlgebra/LAPACK.hs
diff options
context:
space:
mode:
authorClark Gaebel <cgaebel@csclub.uwaterloo.ca>2012-03-10 18:26:56 -0500
committerClark Gaebel <cgaebel@csclub.uwaterloo.ca>2012-03-10 18:26:56 -0500
commitf8b7b3734fa6bb8d63914719e09d17940add27d4 (patch)
tree233c1c41ea8d5a0cf43bf9430cc2b60cff38a3e9 /lib/Numeric/LinearAlgebra/LAPACK.hs
parent13fe05779923baad386b0059ff6fbc7c6af405d9 (diff)
Removed foreign import safety.
Diffstat (limited to 'lib/Numeric/LinearAlgebra/LAPACK.hs')
-rw-r--r--lib/Numeric/LinearAlgebra/LAPACK.hs64
1 files changed, 32 insertions, 32 deletions
diff --git a/lib/Numeric/LinearAlgebra/LAPACK.hs b/lib/Numeric/LinearAlgebra/LAPACK.hs
index 7ad58e1..9bc6669 100644
--- a/lib/Numeric/LinearAlgebra/LAPACK.hs
+++ b/lib/Numeric/LinearAlgebra/LAPACK.hs
@@ -53,10 +53,10 @@ import System.IO.Unsafe(unsafePerformIO)
53 53
54----------------------------------------------------------------------------------- 54-----------------------------------------------------------------------------------
55 55
56foreign import ccall "multiplyR" dgemmc :: CInt -> CInt -> TMMM 56foreign import ccall unsafe "multiplyR" dgemmc :: CInt -> CInt -> TMMM
57foreign import ccall "multiplyC" zgemmc :: CInt -> CInt -> TCMCMCM 57foreign import ccall unsafe "multiplyC" zgemmc :: CInt -> CInt -> TCMCMCM
58foreign import ccall "multiplyF" sgemmc :: CInt -> CInt -> TFMFMFM 58foreign import ccall unsafe "multiplyF" sgemmc :: CInt -> CInt -> TFMFMFM
59foreign import ccall "multiplyQ" cgemmc :: CInt -> CInt -> TQMQMQM 59foreign import ccall unsafe "multiplyQ" cgemmc :: CInt -> CInt -> TQMQMQM
60 60
61isT Matrix{order = ColumnMajor} = 0 61isT Matrix{order = ColumnMajor} = 0
62isT Matrix{order = RowMajor} = 1 62isT Matrix{order = RowMajor} = 1
@@ -88,10 +88,10 @@ multiplyQ :: Matrix (Complex Float) -> Matrix (Complex Float) -> Matrix (Complex
88multiplyQ a b = multiplyAux cgemmc "cgemmc" a b 88multiplyQ a b = multiplyAux cgemmc "cgemmc" a b
89 89
90----------------------------------------------------------------------------- 90-----------------------------------------------------------------------------
91foreign import ccall "svd_l_R" dgesvd :: TMMVM 91foreign import ccall unsafe "svd_l_R" dgesvd :: TMMVM
92foreign import ccall "svd_l_C" zgesvd :: TCMCMVCM 92foreign import ccall unsafe "svd_l_C" zgesvd :: TCMCMVCM
93foreign import ccall "svd_l_Rdd" dgesdd :: TMMVM 93foreign import ccall unsafe "svd_l_Rdd" dgesdd :: TMMVM
94foreign import ccall "svd_l_Cdd" zgesdd :: TCMCMVCM 94foreign import ccall unsafe "svd_l_Cdd" zgesdd :: TCMCMVCM
95 95
96-- | Full SVD of a real matrix using LAPACK's /dgesvd/. 96-- | Full SVD of a real matrix using LAPACK's /dgesvd/.
97svdR :: Matrix Double -> (Matrix Double, Vector Double, Matrix Double) 97svdR :: Matrix Double -> (Matrix Double, Vector Double, Matrix Double)
@@ -211,10 +211,10 @@ leftSVAux f st x = unsafePerformIO $ do
211 211
212----------------------------------------------------------------------------- 212-----------------------------------------------------------------------------
213 213
214foreign import ccall "LAPACK/lapack-aux.h eig_l_R" dgeev :: TMMCVM 214foreign import ccall unsafe "LAPACK/lapack-aux.h eig_l_R" dgeev :: TMMCVM
215foreign import ccall "LAPACK/lapack-aux.h eig_l_C" zgeev :: TCMCMCVCM 215foreign import ccall unsafe "LAPACK/lapack-aux.h eig_l_C" zgeev :: TCMCMCVCM
216foreign import ccall "LAPACK/lapack-aux.h eig_l_S" dsyev :: CInt -> TMVM 216foreign import ccall unsafe "LAPACK/lapack-aux.h eig_l_S" dsyev :: CInt -> TMVM
217foreign import ccall "LAPACK/lapack-aux.h eig_l_H" zheev :: CInt -> TCMVCM 217foreign import ccall unsafe "LAPACK/lapack-aux.h eig_l_H" zheev :: CInt -> TCMVCM
218 218
219eigAux f st m = unsafePerformIO $ do 219eigAux f st m = unsafePerformIO $ do
220 l <- createVector r 220 l <- createVector r
@@ -325,10 +325,10 @@ eigOnlyH = vrev . fst. eigSHAux (zheev 1) "eigH'" . fmat
325vrev = flatten . flipud . reshape 1 325vrev = flatten . flipud . reshape 1
326 326
327----------------------------------------------------------------------------- 327-----------------------------------------------------------------------------
328foreign import ccall "linearSolveR_l" dgesv :: TMMM 328foreign import ccall unsafe "linearSolveR_l" dgesv :: TMMM
329foreign import ccall "linearSolveC_l" zgesv :: TCMCMCM 329foreign import ccall unsafe "linearSolveC_l" zgesv :: TCMCMCM
330foreign import ccall "cholSolveR_l" dpotrs :: TMMM 330foreign import ccall unsafe "cholSolveR_l" dpotrs :: TMMM
331foreign import ccall "cholSolveC_l" zpotrs :: TCMCMCM 331foreign import ccall unsafe "cholSolveC_l" zpotrs :: TCMCMCM
332 332
333linearSolveSQAux f st a b 333linearSolveSQAux f st a b
334 | n1==n2 && n1==r = unsafePerformIO $ do 334 | n1==n2 && n1==r = unsafePerformIO $ do
@@ -359,10 +359,10 @@ cholSolveC :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Comp
359cholSolveC a b = linearSolveSQAux zpotrs "cholSolveC" (fmat a) (fmat b) 359cholSolveC a b = linearSolveSQAux zpotrs "cholSolveC" (fmat a) (fmat b)
360 360
361----------------------------------------------------------------------------------- 361-----------------------------------------------------------------------------------
362foreign import ccall "LAPACK/lapack-aux.h linearSolveLSR_l" dgels :: TMMM 362foreign import ccall unsafe "LAPACK/lapack-aux.h linearSolveLSR_l" dgels :: TMMM
363foreign import ccall "LAPACK/lapack-aux.h linearSolveLSC_l" zgels :: TCMCMCM 363foreign import ccall unsafe "LAPACK/lapack-aux.h linearSolveLSC_l" zgels :: TCMCMCM
364foreign import ccall "LAPACK/lapack-aux.h linearSolveSVDR_l" dgelss :: Double -> TMMM 364foreign import ccall unsafe "LAPACK/lapack-aux.h linearSolveSVDR_l" dgelss :: Double -> TMMM
365foreign import ccall "LAPACK/lapack-aux.h linearSolveSVDC_l" zgelss :: Double -> TCMCMCM 365foreign import ccall unsafe "LAPACK/lapack-aux.h linearSolveSVDC_l" zgelss :: Double -> TCMCMCM
366 366
367linearSolveAux f st a b = unsafePerformIO $ do 367linearSolveAux f st a b = unsafePerformIO $ do
368 r <- createMatrix ColumnMajor (max m n) nrhs 368 r <- createMatrix ColumnMajor (max m n) nrhs
@@ -401,8 +401,8 @@ linearSolveSVDC (Just rcond) a b = subMatrix (0,0) (cols a, cols b) $
401linearSolveSVDC Nothing a b = linearSolveSVDC (Just (-1)) (fmat a) (fmat b) 401linearSolveSVDC Nothing a b = linearSolveSVDC (Just (-1)) (fmat a) (fmat b)
402 402
403----------------------------------------------------------------------------------- 403-----------------------------------------------------------------------------------
404foreign import ccall "LAPACK/lapack-aux.h chol_l_H" zpotrf :: TCMCM 404foreign import ccall unsafe "LAPACK/lapack-aux.h chol_l_H" zpotrf :: TCMCM
405foreign import ccall "LAPACK/lapack-aux.h chol_l_S" dpotrf :: TMM 405foreign import ccall unsafe "LAPACK/lapack-aux.h chol_l_S" dpotrf :: TMM
406 406
407cholAux f st a = do 407cholAux f st a = do
408 r <- createMatrix ColumnMajor n n 408 r <- createMatrix ColumnMajor n n
@@ -427,8 +427,8 @@ mbCholS :: Matrix Double -> Maybe (Matrix Double)
427mbCholS = unsafePerformIO . mbCatch . cholAux dpotrf "cholS" . fmat 427mbCholS = unsafePerformIO . mbCatch . cholAux dpotrf "cholS" . fmat
428 428
429----------------------------------------------------------------------------------- 429-----------------------------------------------------------------------------------
430foreign import ccall "LAPACK/lapack-aux.h qr_l_R" dgeqr2 :: TMVM 430foreign import ccall unsafe "LAPACK/lapack-aux.h qr_l_R" dgeqr2 :: TMVM
431foreign import ccall "LAPACK/lapack-aux.h qr_l_C" zgeqr2 :: TCMCVCM 431foreign import ccall unsafe "LAPACK/lapack-aux.h qr_l_C" zgeqr2 :: TCMCVCM
432 432
433-- | QR factorization of a real matrix, using LAPACK's /dgeqr2/. 433-- | QR factorization of a real matrix, using LAPACK's /dgeqr2/.
434qrR :: Matrix Double -> (Matrix Double, Vector Double) 434qrR :: Matrix Double -> (Matrix Double, Vector Double)
@@ -448,8 +448,8 @@ qrAux f st a = unsafePerformIO $ do
448 mn = min m n 448 mn = min m n
449 449
450----------------------------------------------------------------------------------- 450-----------------------------------------------------------------------------------
451foreign import ccall "LAPACK/lapack-aux.h hess_l_R" dgehrd :: TMVM 451foreign import ccall unsafe "LAPACK/lapack-aux.h hess_l_R" dgehrd :: TMVM
452foreign import ccall "LAPACK/lapack-aux.h hess_l_C" zgehrd :: TCMCVCM 452foreign import ccall unsafe "LAPACK/lapack-aux.h hess_l_C" zgehrd :: TCMCVCM
453 453
454-- | Hessenberg factorization of a square real matrix, using LAPACK's /dgehrd/. 454-- | Hessenberg factorization of a square real matrix, using LAPACK's /dgehrd/.
455hessR :: Matrix Double -> (Matrix Double, Vector Double) 455hessR :: Matrix Double -> (Matrix Double, Vector Double)
@@ -469,8 +469,8 @@ hessAux f st a = unsafePerformIO $ do
469 mn = min m n 469 mn = min m n
470 470
471----------------------------------------------------------------------------------- 471-----------------------------------------------------------------------------------
472foreign import ccall "LAPACK/lapack-aux.h schur_l_R" dgees :: TMMM 472foreign import ccall unsafe "LAPACK/lapack-aux.h schur_l_R" dgees :: TMMM
473foreign import ccall "LAPACK/lapack-aux.h schur_l_C" zgees :: TCMCMCM 473foreign import ccall unsafe "LAPACK/lapack-aux.h schur_l_C" zgees :: TCMCMCM
474 474
475-- | Schur factorization of a square real matrix, using LAPACK's /dgees/. 475-- | Schur factorization of a square real matrix, using LAPACK's /dgees/.
476schurR :: Matrix Double -> (Matrix Double, Matrix Double) 476schurR :: Matrix Double -> (Matrix Double, Matrix Double)
@@ -488,8 +488,8 @@ schurAux f st a = unsafePerformIO $ do
488 where n = rows a 488 where n = rows a
489 489
490----------------------------------------------------------------------------------- 490-----------------------------------------------------------------------------------
491foreign import ccall "LAPACK/lapack-aux.h lu_l_R" dgetrf :: TMVM 491foreign import ccall unsafe "LAPACK/lapack-aux.h lu_l_R" dgetrf :: TMVM
492foreign import ccall "LAPACK/lapack-aux.h lu_l_C" zgetrf :: TCMVCM 492foreign import ccall unsafe "LAPACK/lapack-aux.h lu_l_C" zgetrf :: TCMVCM
493 493
494-- | LU factorization of a general real matrix, using LAPACK's /dgetrf/. 494-- | LU factorization of a general real matrix, using LAPACK's /dgetrf/.
495luR :: Matrix Double -> (Matrix Double, [Int]) 495luR :: Matrix Double -> (Matrix Double, [Int])
@@ -511,8 +511,8 @@ luAux f st a = unsafePerformIO $ do
511type TW a = CInt -> PD -> a 511type TW a = CInt -> PD -> a
512type TQ a = CInt -> CInt -> PC -> a 512type TQ a = CInt -> CInt -> PC -> a
513 513
514foreign import ccall "LAPACK/lapack-aux.h luS_l_R" dgetrs :: TMVMM 514foreign import ccall unsafe "LAPACK/lapack-aux.h luS_l_R" dgetrs :: TMVMM
515foreign import ccall "LAPACK/lapack-aux.h luS_l_C" zgetrs :: TQ (TW (TQ (TQ (IO CInt)))) 515foreign import ccall unsafe "LAPACK/lapack-aux.h luS_l_C" zgetrs :: TQ (TW (TQ (TQ (IO CInt))))
516 516
517-- | Solve a real linear system from a precomputed LU decomposition ('luR'), using LAPACK's /dgetrs/. 517-- | Solve a real linear system from a precomputed LU decomposition ('luR'), using LAPACK's /dgetrs/.
518lusR :: Matrix Double -> [Int] -> Matrix Double -> Matrix Double 518lusR :: Matrix Double -> [Int] -> Matrix Double -> Matrix Double