diff options
author | Clark Gaebel <cgaebel@csclub.uwaterloo.ca> | 2012-03-10 18:26:56 -0500 |
---|---|---|
committer | Clark Gaebel <cgaebel@csclub.uwaterloo.ca> | 2012-03-10 18:26:56 -0500 |
commit | f8b7b3734fa6bb8d63914719e09d17940add27d4 (patch) | |
tree | 233c1c41ea8d5a0cf43bf9430cc2b60cff38a3e9 /lib/Numeric/LinearAlgebra/LAPACK.hs | |
parent | 13fe05779923baad386b0059ff6fbc7c6af405d9 (diff) |
Removed foreign import safety.
Diffstat (limited to 'lib/Numeric/LinearAlgebra/LAPACK.hs')
-rw-r--r-- | lib/Numeric/LinearAlgebra/LAPACK.hs | 64 |
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 | ||
56 | foreign import ccall "multiplyR" dgemmc :: CInt -> CInt -> TMMM | 56 | foreign import ccall unsafe "multiplyR" dgemmc :: CInt -> CInt -> TMMM |
57 | foreign import ccall "multiplyC" zgemmc :: CInt -> CInt -> TCMCMCM | 57 | foreign import ccall unsafe "multiplyC" zgemmc :: CInt -> CInt -> TCMCMCM |
58 | foreign import ccall "multiplyF" sgemmc :: CInt -> CInt -> TFMFMFM | 58 | foreign import ccall unsafe "multiplyF" sgemmc :: CInt -> CInt -> TFMFMFM |
59 | foreign import ccall "multiplyQ" cgemmc :: CInt -> CInt -> TQMQMQM | 59 | foreign import ccall unsafe "multiplyQ" cgemmc :: CInt -> CInt -> TQMQMQM |
60 | 60 | ||
61 | isT Matrix{order = ColumnMajor} = 0 | 61 | isT Matrix{order = ColumnMajor} = 0 |
62 | isT Matrix{order = RowMajor} = 1 | 62 | isT Matrix{order = RowMajor} = 1 |
@@ -88,10 +88,10 @@ multiplyQ :: Matrix (Complex Float) -> Matrix (Complex Float) -> Matrix (Complex | |||
88 | multiplyQ a b = multiplyAux cgemmc "cgemmc" a b | 88 | multiplyQ a b = multiplyAux cgemmc "cgemmc" a b |
89 | 89 | ||
90 | ----------------------------------------------------------------------------- | 90 | ----------------------------------------------------------------------------- |
91 | foreign import ccall "svd_l_R" dgesvd :: TMMVM | 91 | foreign import ccall unsafe "svd_l_R" dgesvd :: TMMVM |
92 | foreign import ccall "svd_l_C" zgesvd :: TCMCMVCM | 92 | foreign import ccall unsafe "svd_l_C" zgesvd :: TCMCMVCM |
93 | foreign import ccall "svd_l_Rdd" dgesdd :: TMMVM | 93 | foreign import ccall unsafe "svd_l_Rdd" dgesdd :: TMMVM |
94 | foreign import ccall "svd_l_Cdd" zgesdd :: TCMCMVCM | 94 | foreign 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/. |
97 | svdR :: Matrix Double -> (Matrix Double, Vector Double, Matrix Double) | 97 | svdR :: Matrix Double -> (Matrix Double, Vector Double, Matrix Double) |
@@ -211,10 +211,10 @@ leftSVAux f st x = unsafePerformIO $ do | |||
211 | 211 | ||
212 | ----------------------------------------------------------------------------- | 212 | ----------------------------------------------------------------------------- |
213 | 213 | ||
214 | foreign import ccall "LAPACK/lapack-aux.h eig_l_R" dgeev :: TMMCVM | 214 | foreign import ccall unsafe "LAPACK/lapack-aux.h eig_l_R" dgeev :: TMMCVM |
215 | foreign import ccall "LAPACK/lapack-aux.h eig_l_C" zgeev :: TCMCMCVCM | 215 | foreign import ccall unsafe "LAPACK/lapack-aux.h eig_l_C" zgeev :: TCMCMCVCM |
216 | foreign import ccall "LAPACK/lapack-aux.h eig_l_S" dsyev :: CInt -> TMVM | 216 | foreign import ccall unsafe "LAPACK/lapack-aux.h eig_l_S" dsyev :: CInt -> TMVM |
217 | foreign import ccall "LAPACK/lapack-aux.h eig_l_H" zheev :: CInt -> TCMVCM | 217 | foreign import ccall unsafe "LAPACK/lapack-aux.h eig_l_H" zheev :: CInt -> TCMVCM |
218 | 218 | ||
219 | eigAux f st m = unsafePerformIO $ do | 219 | eigAux 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 | |||
325 | vrev = flatten . flipud . reshape 1 | 325 | vrev = flatten . flipud . reshape 1 |
326 | 326 | ||
327 | ----------------------------------------------------------------------------- | 327 | ----------------------------------------------------------------------------- |
328 | foreign import ccall "linearSolveR_l" dgesv :: TMMM | 328 | foreign import ccall unsafe "linearSolveR_l" dgesv :: TMMM |
329 | foreign import ccall "linearSolveC_l" zgesv :: TCMCMCM | 329 | foreign import ccall unsafe "linearSolveC_l" zgesv :: TCMCMCM |
330 | foreign import ccall "cholSolveR_l" dpotrs :: TMMM | 330 | foreign import ccall unsafe "cholSolveR_l" dpotrs :: TMMM |
331 | foreign import ccall "cholSolveC_l" zpotrs :: TCMCMCM | 331 | foreign import ccall unsafe "cholSolveC_l" zpotrs :: TCMCMCM |
332 | 332 | ||
333 | linearSolveSQAux f st a b | 333 | linearSolveSQAux 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 | |||
359 | cholSolveC a b = linearSolveSQAux zpotrs "cholSolveC" (fmat a) (fmat b) | 359 | cholSolveC a b = linearSolveSQAux zpotrs "cholSolveC" (fmat a) (fmat b) |
360 | 360 | ||
361 | ----------------------------------------------------------------------------------- | 361 | ----------------------------------------------------------------------------------- |
362 | foreign import ccall "LAPACK/lapack-aux.h linearSolveLSR_l" dgels :: TMMM | 362 | foreign import ccall unsafe "LAPACK/lapack-aux.h linearSolveLSR_l" dgels :: TMMM |
363 | foreign import ccall "LAPACK/lapack-aux.h linearSolveLSC_l" zgels :: TCMCMCM | 363 | foreign import ccall unsafe "LAPACK/lapack-aux.h linearSolveLSC_l" zgels :: TCMCMCM |
364 | foreign import ccall "LAPACK/lapack-aux.h linearSolveSVDR_l" dgelss :: Double -> TMMM | 364 | foreign import ccall unsafe "LAPACK/lapack-aux.h linearSolveSVDR_l" dgelss :: Double -> TMMM |
365 | foreign import ccall "LAPACK/lapack-aux.h linearSolveSVDC_l" zgelss :: Double -> TCMCMCM | 365 | foreign import ccall unsafe "LAPACK/lapack-aux.h linearSolveSVDC_l" zgelss :: Double -> TCMCMCM |
366 | 366 | ||
367 | linearSolveAux f st a b = unsafePerformIO $ do | 367 | linearSolveAux 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) $ | |||
401 | linearSolveSVDC Nothing a b = linearSolveSVDC (Just (-1)) (fmat a) (fmat b) | 401 | linearSolveSVDC Nothing a b = linearSolveSVDC (Just (-1)) (fmat a) (fmat b) |
402 | 402 | ||
403 | ----------------------------------------------------------------------------------- | 403 | ----------------------------------------------------------------------------------- |
404 | foreign import ccall "LAPACK/lapack-aux.h chol_l_H" zpotrf :: TCMCM | 404 | foreign import ccall unsafe "LAPACK/lapack-aux.h chol_l_H" zpotrf :: TCMCM |
405 | foreign import ccall "LAPACK/lapack-aux.h chol_l_S" dpotrf :: TMM | 405 | foreign import ccall unsafe "LAPACK/lapack-aux.h chol_l_S" dpotrf :: TMM |
406 | 406 | ||
407 | cholAux f st a = do | 407 | cholAux 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) | |||
427 | mbCholS = unsafePerformIO . mbCatch . cholAux dpotrf "cholS" . fmat | 427 | mbCholS = unsafePerformIO . mbCatch . cholAux dpotrf "cholS" . fmat |
428 | 428 | ||
429 | ----------------------------------------------------------------------------------- | 429 | ----------------------------------------------------------------------------------- |
430 | foreign import ccall "LAPACK/lapack-aux.h qr_l_R" dgeqr2 :: TMVM | 430 | foreign import ccall unsafe "LAPACK/lapack-aux.h qr_l_R" dgeqr2 :: TMVM |
431 | foreign import ccall "LAPACK/lapack-aux.h qr_l_C" zgeqr2 :: TCMCVCM | 431 | foreign 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/. |
434 | qrR :: Matrix Double -> (Matrix Double, Vector Double) | 434 | qrR :: 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 | ----------------------------------------------------------------------------------- |
451 | foreign import ccall "LAPACK/lapack-aux.h hess_l_R" dgehrd :: TMVM | 451 | foreign import ccall unsafe "LAPACK/lapack-aux.h hess_l_R" dgehrd :: TMVM |
452 | foreign import ccall "LAPACK/lapack-aux.h hess_l_C" zgehrd :: TCMCVCM | 452 | foreign 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/. |
455 | hessR :: Matrix Double -> (Matrix Double, Vector Double) | 455 | hessR :: 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 | ----------------------------------------------------------------------------------- |
472 | foreign import ccall "LAPACK/lapack-aux.h schur_l_R" dgees :: TMMM | 472 | foreign import ccall unsafe "LAPACK/lapack-aux.h schur_l_R" dgees :: TMMM |
473 | foreign import ccall "LAPACK/lapack-aux.h schur_l_C" zgees :: TCMCMCM | 473 | foreign 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/. |
476 | schurR :: Matrix Double -> (Matrix Double, Matrix Double) | 476 | schurR :: 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 | ----------------------------------------------------------------------------------- |
491 | foreign import ccall "LAPACK/lapack-aux.h lu_l_R" dgetrf :: TMVM | 491 | foreign import ccall unsafe "LAPACK/lapack-aux.h lu_l_R" dgetrf :: TMVM |
492 | foreign import ccall "LAPACK/lapack-aux.h lu_l_C" zgetrf :: TCMVCM | 492 | foreign 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/. |
495 | luR :: Matrix Double -> (Matrix Double, [Int]) | 495 | luR :: Matrix Double -> (Matrix Double, [Int]) |
@@ -511,8 +511,8 @@ luAux f st a = unsafePerformIO $ do | |||
511 | type TW a = CInt -> PD -> a | 511 | type TW a = CInt -> PD -> a |
512 | type TQ a = CInt -> CInt -> PC -> a | 512 | type TQ a = CInt -> CInt -> PC -> a |
513 | 513 | ||
514 | foreign import ccall "LAPACK/lapack-aux.h luS_l_R" dgetrs :: TMVMM | 514 | foreign import ccall unsafe "LAPACK/lapack-aux.h luS_l_R" dgetrs :: TMVMM |
515 | foreign import ccall "LAPACK/lapack-aux.h luS_l_C" zgetrs :: TQ (TW (TQ (TQ (IO CInt)))) | 515 | foreign 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/. |
518 | lusR :: Matrix Double -> [Int] -> Matrix Double -> Matrix Double | 518 | lusR :: Matrix Double -> [Int] -> Matrix Double -> Matrix Double |