Permalink
Browse files

Immutable API for symmetric matrix-vector multiplication

  • Loading branch information...
1 parent 4e9b47f commit 66d98d074a08acef421f325481840e3ab2e01a55 @Shimuuar committed Aug 27, 2012
Showing with 19 additions and 1 deletion.
  1. +10 −1 Numeric/BLAS.hs
  2. +9 −0 Numeric/BLAS/Expression.hs
View
@@ -46,7 +46,8 @@ import qualified Data.Matrix.Generic as Mat
import qualified Data.Vector.Storable as S
import qualified Data.Vector.Storable.Strided as V
-- Concrete matrices
-import Data.Matrix.Dense (Matrix)
+import Data.Matrix.Dense (Matrix)
+import Data.Matrix.Symmetric (Symmetric)
import qualified Numeric.BLAS.Mutable as M
@@ -253,6 +254,14 @@ instance (BLAS2 a, a ~ a') => Mul (Conjugated Matrix a) (S.Vector a') where
{-# INLINE (.*.) #-}
+instance (BLAS2 a, a ~ a') => Mul (Symmetric a) (S.Vector a') where
+ type MulRes (Symmetric a)
+ (S.Vector a')
+ = S.Vector a
+ m .*. v = eval $ MulMV () (Lit m) (Lit v)
+ {-# INLINE (.*.) #-}
+
+
----------------------------------------------------------------
-- Matrix x Matrix for dense matrices
@@ -38,6 +38,8 @@ import qualified Data.Matrix.Generic as Mat
import qualified Data.Matrix.Generic.Mutable as MMat
import qualified Data.Matrix.Dense as MatD
import qualified Data.Matrix.Dense.Mutable as MMatD
+import qualified Data.Matrix.Symmetric as MatS
+import qualified Data.Matrix.Symmetric.Mutable as MMatS
import Numeric.BLAS.Mutable
@@ -458,6 +460,13 @@ instance Storable a => Freeze MatD.Matrix a where
unsafeFreeze = Mat.unsafeFreeze
unsafeThaw = Mat.unsafeThaw
+instance Storable a => Clonable MMatS.MSymmetric a where
+ cloneShape = MMat.cloneShape
+ clone = MMat.clone
+instance Storable a => Freeze MatS.Symmetric a where
+ unsafeFreeze = Mat.unsafeFreeze
+ unsafeThaw = Mat.unsafeThaw
+
instance BLAS1 a => Scalable MV.MVector a where
scale = scaleVector

0 comments on commit 66d98d0

Please sign in to comment.