summaryrefslogtreecommitdiff
path: root/packages/base/src/Numeric/Sparse.hs
diff options
context:
space:
mode:
Diffstat (limited to 'packages/base/src/Numeric/Sparse.hs')
-rw-r--r--packages/base/src/Numeric/Sparse.hs29
1 files changed, 27 insertions, 2 deletions
diff --git a/packages/base/src/Numeric/Sparse.hs b/packages/base/src/Numeric/Sparse.hs
index 1b8a7b3..f495e3a 100644
--- a/packages/base/src/Numeric/Sparse.hs
+++ b/packages/base/src/Numeric/Sparse.hs
@@ -62,7 +62,26 @@ mkCSR sm' = CSR{..}
62 csrNRows = dim csrRows - 1 62 csrNRows = dim csrRows - 1
63 csrNCols = fromIntegral (V.maximum csrCols) 63 csrNCols = fromIntegral (V.maximum csrCols)
64 64
65 65{- | General matrix with specialized internal representations for
66 dense, sparse, diagonal, banded, and constant elements.
67
68>>> let m = mkSparse [((0,999),1.0),((1,1999),2.0)]
69>>> m
70SparseR {gmCSR = CSR {csrVals = fromList [1.0,2.0],
71 csrCols = fromList [1000,2000],
72 csrRows = fromList [1,2,3],
73 csrNRows = 2,
74 csrNCols = 2000},
75 nRows = 2,
76 nCols = 2000}
77
78>>> let m = mkDense (mat 2 [1..4])
79>>> m
80Dense {gmDense = (2><2)
81 [ 1.0, 2.0
82 , 3.0, 4.0 ], nRows = 2, nCols = 2}
83
84-}
66data GMatrix 85data GMatrix
67 = SparseR 86 = SparseR
68 { gmCSR :: CSR 87 { gmCSR :: CSR
@@ -146,7 +165,13 @@ gmXv Dense{..} v
146 nRows nCols (dim v) 165 nRows nCols (dim v)
147 166
148 167
149-- | general matrix - vector product 168{- | general matrix - vector product
169
170>>> let m = mkSparse [((0,999),1.0),((1,1999),2.0)]
171>>> m !#> vect[1..2000]
172fromList [1000.0,4000.0]
173
174-}
150infixr 8 !#> 175infixr 8 !#>
151(!#>) :: GMatrix -> Vector Double -> Vector Double 176(!#>) :: GMatrix -> Vector Double -> Vector Double
152(!#>) = gmXv 177(!#>) = gmXv