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.hs28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/Numeric/LinearAlgebra/LAPACK.hs b/lib/Numeric/LinearAlgebra/LAPACK.hs
index 8bc2492..56945d7 100644
--- a/lib/Numeric/LinearAlgebra/LAPACK.hs
+++ b/lib/Numeric/LinearAlgebra/LAPACK.hs
@@ -14,6 +14,7 @@
14----------------------------------------------------------------------------- 14-----------------------------------------------------------------------------
15 15
16module Numeric.LinearAlgebra.LAPACK ( 16module Numeric.LinearAlgebra.LAPACK (
17 multiplyR, multiplyC,
17 svdR, svdRdd, svdC, 18 svdR, svdRdd, svdC,
18 eigC, eigR, eigS, eigH, eigS', eigH', 19 eigC, eigR, eigS, eigH, eigS', eigH',
19 linearSolveR, linearSolveC, 20 linearSolveR, linearSolveC,
@@ -35,6 +36,33 @@ import Numeric.GSL.Vector(vectorMapValR, FunCodeSV(Scale))
35import Complex 36import Complex
36import Foreign 37import Foreign
37import Foreign.C.Types (CInt) 38import Foreign.C.Types (CInt)
39import Control.Monad(when)
40
41-----------------------------------------------------------------------------------
42
43foreign import ccall "LAPACK/lapack-aux.h multiplyR" dgemmc :: CInt -> CInt -> TMMM
44foreign import ccall "LAPACK/lapack-aux.h multiplyC" zgemmc :: CInt -> CInt -> TCMCMCM
45
46isT MF{} = 0
47isT MC{} = 1
48
49tt x@MF{} = x
50tt x@MC{} = trans x
51
52multiplyAux f st a b = unsafePerformIO $ do
53 when (cols a /= rows b) $ error $ "inconsistent dimensions in matrix product "++
54 show (rows a,cols a) ++ " x " ++ show (rows b, cols b)
55 s <- createMatrix ColumnMajor (rows a) (cols b)
56 app3 (f (isT a) (isT b)) mat (tt a) mat (tt b) mat s st
57 return s
58
59-- | Matrix product based on BLAS's /dgemm/.
60multiplyR :: Matrix Double -> Matrix Double -> Matrix Double
61multiplyR a b = multiplyAux dgemmc "dgemmc" a b
62
63-- | Matrix product based on BLAS's /zgemm/.
64multiplyC :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double)
65multiplyC a b = multiplyAux zgemmc "zgemmc" a b
38 66
39----------------------------------------------------------------------------- 67-----------------------------------------------------------------------------
40foreign import ccall "LAPACK/lapack-aux.h svd_l_R" dgesvd :: TMMVM 68foreign import ccall "LAPACK/lapack-aux.h svd_l_R" dgesvd :: TMMVM