summaryrefslogtreecommitdiff
path: root/packages/sparse/src/Numeric/LinearAlgebra/Sparse.hs
blob: 8608394e636ad6a1eb56da63fa016cb0779a69ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE RecordWildCards #-}



module Numeric.LinearAlgebra.Sparse (
    dss
) where

import Foreign.C.Types(CInt(..))
import Numeric.LinearAlgebra.Devel
import System.IO.Unsafe(unsafePerformIO)
import Foreign(Ptr)
import Numeric.LinearAlgebra.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