summaryrefslogtreecommitdiff
path: root/packages/base/src/Numeric/LinearAlgebra
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2014-05-27 20:21:47 +0200
committerAlberto Ruiz <aruiz@um.es>2014-05-27 20:21:47 +0200
commit53559833d2166010eed754027484fb8d5525e710 (patch)
treed1cd40e45e6062ef6bece255b20424f90091a910 /packages/base/src/Numeric/LinearAlgebra
parentcf3c788f0c44577ac1a5365e8154200b53a36409 (diff)
expose CSR
Diffstat (limited to 'packages/base/src/Numeric/LinearAlgebra')
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Data.hs6
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Real.hs10
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Util.hs7
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Util/CG.hs2
4 files changed, 21 insertions, 4 deletions
diff --git a/packages/base/src/Numeric/LinearAlgebra/Data.hs b/packages/base/src/Numeric/LinearAlgebra/Data.hs
index 3417a5e..33a2c9a 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Data.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Data.hs
@@ -49,8 +49,8 @@ module Numeric.LinearAlgebra.Data(
49 find, maxIndex, minIndex, maxElement, minElement, atIndex, 49 find, maxIndex, minIndex, maxElement, minElement, atIndex,
50 50
51 -- * Sparse 51 -- * Sparse
52 GMatrix, AssocMatrix, mkSparse, toDense, 52 AssocMatrix, toDense,
53 mkDiagR, dense, 53 mkSparse, mkDiagR, mkDense,
54 54
55 -- * IO 55 -- * IO
56 disp, 56 disp,
@@ -68,7 +68,7 @@ module Numeric.LinearAlgebra.Data(
68 68
69 module Data.Complex, 69 module Data.Complex,
70 70
71 Vector, Matrix 71 Vector, Matrix, GMatrix, CSR(..), mkCSR
72 72
73) where 73) where
74 74
diff --git a/packages/base/src/Numeric/LinearAlgebra/Real.hs b/packages/base/src/Numeric/LinearAlgebra/Real.hs
index db15705..1e8b544 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Real.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Real.hs
@@ -141,6 +141,16 @@ instance (Num (Matrix t), Numeric t) => Num (Dim m (Dim n (Matrix t)))
141 negate = (lift1F . lift1F) negate 141 negate = (lift1F . lift1F) negate
142 fromInteger x = Dim (Dim (fromInteger x)) 142 fromInteger x = Dim (Dim (fromInteger x))
143 143
144instance Fractional (Dim n (Vector Double))
145 where
146 fromRational x = Dim (fromRational x)
147 (/) = lift2F (/)
148
149instance Fractional (Dim m (Dim n (Matrix Double)))
150 where
151 fromRational x = Dim (Dim (fromRational x))
152 (/) = (lift2F.lift2F) (/)
153
144-------------------------------------------------------------------------------- 154--------------------------------------------------------------------------------
145 155
146class Konst t 156class Konst t
diff --git a/packages/base/src/Numeric/LinearAlgebra/Util.hs b/packages/base/src/Numeric/LinearAlgebra/Util.hs
index 47b1090..aee21b8 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Util.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Util.hs
@@ -37,6 +37,7 @@ module Numeric.LinearAlgebra.Util(
37 mnorm_1, mnorm_2, mnorm_0, mnorm_Inf, 37 mnorm_1, mnorm_2, mnorm_0, mnorm_Inf,
38 unitary, 38 unitary,
39 mt, 39 mt,
40 (~!~),
40 pairwiseD2, 41 pairwiseD2,
41 rowOuters, 42 rowOuters,
42 null1, 43 null1,
@@ -65,6 +66,7 @@ import Numeric.Matrix()
65import Numeric.Vector() 66import Numeric.Vector()
66import Numeric.LinearAlgebra.Random 67import Numeric.LinearAlgebra.Random
67import Numeric.LinearAlgebra.Util.Convolution 68import Numeric.LinearAlgebra.Util.Convolution
69import Control.Monad(when)
68 70
69type ℝ = Double 71type ℝ = Double
70type ℕ = Int 72type ℕ = Int
@@ -385,3 +387,8 @@ vtrans p m | r == 0 = fromBlocks . map (map asColumn . takesV (replicate q p)) .
385 where 387 where
386 (q,r) = divMod (rows m) p 388 (q,r) = divMod (rows m) p
387 389
390--------------------------------------------------------------------------------
391
392infixl 0 ~!~
393c ~!~ msg = when c (error msg)
394
diff --git a/packages/base/src/Numeric/LinearAlgebra/Util/CG.hs b/packages/base/src/Numeric/LinearAlgebra/Util/CG.hs
index 50372f1..f821b57 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Util/CG.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Util/CG.hs
@@ -115,7 +115,7 @@ instance Testable GMatrix
115 sma = convo2 20 3 115 sma = convo2 20 3
116 x1 = vect [1..20] 116 x1 = vect [1..20]
117 x2 = vect [1..40] 117 x2 = vect [1..40]
118 sm = mkSparse sma 118 sm = (mkSparse . mkCSR) sma
119 dm = toDense sma 119 dm = toDense sma
120 120
121 s1 = sm !#> x1 121 s1 = sm !#> x1