From 3c1c5e59e3d699f3e17519f19d47f7dab2403879 Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Tue, 27 May 2014 20:24:12 +0200 Subject: initial interface to MKL sparse solver --- .../sparse/src/Numeric/LinearAlgebra/Sparse.hs | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 packages/sparse/src/Numeric/LinearAlgebra/Sparse.hs (limited to 'packages/sparse/src/Numeric/LinearAlgebra/Sparse.hs') 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 @@ +{-# LANGUAGE ForeignFunctionInterface #-} +{-# LANGUAGE RecordWildCards #-} + + + +module Numeric.LinearAlgebra.Sparse ( + dss +) where + +import Foreign.C.Types(CInt(..)) +import Data.Packed.Development +import System.IO.Unsafe(unsafePerformIO) +import Foreign(Ptr) +import Numeric.HMatrix +import Text.Printf +import Numeric.LinearAlgebra.Util((~!~)) + + +type IV t = CInt -> Ptr CInt -> t +type V t = CInt -> Ptr Double -> t +type SMxV = V (IV (IV (V (V (IO CInt))))) + +dss :: CSR -> Vector Double -> Vector Double +dss CSR{..} b = unsafePerformIO $ do + size b /= csrNRows ~!~ printf "dss: incorrect sizes: (%d,%d) x %d" csrNRows csrNCols (size b) + r <- createVector csrNCols + app5 c_dss vec csrVals vec csrCols vec csrRows vec b vec r "dss" + return r + +foreign import ccall unsafe "dss" + c_dss :: SMxV + -- cgit v1.2.3