diff options
author | Alberto Ruiz <aruiz@um.es> | 2014-05-27 20:24:12 +0200 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2014-05-27 20:24:12 +0200 |
commit | 3c1c5e59e3d699f3e17519f19d47f7dab2403879 (patch) | |
tree | a749e0a3fb515ad1a904ce7387fbd3afd2ee0ed3 /packages/sparse/src/Numeric/LinearAlgebra/Sparse.hs | |
parent | 53559833d2166010eed754027484fb8d5525e710 (diff) |
initial interface to MKL sparse solver
Diffstat (limited to 'packages/sparse/src/Numeric/LinearAlgebra/Sparse.hs')
-rw-r--r-- | packages/sparse/src/Numeric/LinearAlgebra/Sparse.hs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/packages/sparse/src/Numeric/LinearAlgebra/Sparse.hs b/packages/sparse/src/Numeric/LinearAlgebra/Sparse.hs new file mode 100644 index 0000000..ccf28b7 --- /dev/null +++ b/packages/sparse/src/Numeric/LinearAlgebra/Sparse.hs | |||
@@ -0,0 +1,32 @@ | |||
1 | {-# LANGUAGE ForeignFunctionInterface #-} | ||
2 | {-# LANGUAGE RecordWildCards #-} | ||
3 | |||
4 | |||
5 | |||
6 | module Numeric.LinearAlgebra.Sparse ( | ||
7 | dss | ||
8 | ) where | ||
9 | |||
10 | import Foreign.C.Types(CInt(..)) | ||
11 | import Data.Packed.Development | ||
12 | import System.IO.Unsafe(unsafePerformIO) | ||
13 | import Foreign(Ptr) | ||
14 | import Numeric.HMatrix | ||
15 | import Text.Printf | ||
16 | import Numeric.LinearAlgebra.Util((~!~)) | ||
17 | |||
18 | |||
19 | type IV t = CInt -> Ptr CInt -> t | ||
20 | type V t = CInt -> Ptr Double -> t | ||
21 | type SMxV = V (IV (IV (V (V (IO CInt))))) | ||
22 | |||
23 | dss :: CSR -> Vector Double -> Vector Double | ||
24 | dss CSR{..} b = unsafePerformIO $ do | ||
25 | size b /= csrNRows ~!~ printf "dss: incorrect sizes: (%d,%d) x %d" csrNRows csrNCols (size b) | ||
26 | r <- createVector csrNCols | ||
27 | app5 c_dss vec csrVals vec csrCols vec csrRows vec b vec r "dss" | ||
28 | return r | ||
29 | |||
30 | foreign import ccall unsafe "dss" | ||
31 | c_dss :: SMxV | ||
32 | |||