Skip to content
Browse files

Fix instances for scaling

  • Loading branch information...
1 parent d2cab6e commit e96008bec1cb9dd4b2e16e22f2d7a3f8636062dc @Shimuuar committed Aug 31, 2012
Showing with 7 additions and 1 deletion.
  1. +6 −0 Numeric/BLAS.hs
  2. +1 −1 Numeric/BLAS/Expression.hs
View
6 Numeric/BLAS.hs
@@ -70,10 +70,16 @@ instance (AddM (Mutable m) a, Freeze m a) => Add (m a) where
x .-. y = eval $ Sub () (Lit x) (Lit y)
{-# INLINE (.-.) #-}
+
-- | Multiplication by scalar.
class Scale v a where
(*.) :: a -> v a -> v a
+instance (Num a, Scalable (Mutable m) a, Freeze m a) => Scale m a where
+ α *. v = eval $ Scale () α (Lit v)
+ {-# INLINE (*.) #-}
+
+
-- | Very overloaded operator for matrix and vector multiplication.
class Mul v u where
type MulRes v u :: *
View
2 Numeric/BLAS/Expression.hs
@@ -146,7 +146,7 @@ data Expr m a where
Sub :: (Freeze m a, AddM (Mutable m) a)
=> () -> Expr m a -> Expr m a -> Expr m a
-- Scalar-X multiplication
- Scale :: (Freeze m a, BLAS1 a, Scalable (Mutable m) a)
+ Scale :: (Freeze m a, Num a, Scalable (Mutable m) a)
=> () -> a -> Expr m a -> Expr m a
-- vector x transposed vector => matrix
VecT :: (Freeze v a, MVectorBLAS (Mutable v), BLAS2 a)

0 comments on commit e96008b

Please sign in to comment.
Something went wrong with that request. Please try again.