summaryrefslogtreecommitdiff
path: root/examples/multiply.hs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/multiply.hs')
-rw-r--r--examples/multiply.hs22
1 files changed, 11 insertions, 11 deletions
diff --git a/examples/multiply.hs b/examples/multiply.hs
index 572961c..be8fa73 100644
--- a/examples/multiply.hs
+++ b/examples/multiply.hs
@@ -22,10 +22,10 @@ instance Container Vector t => Scaling t (Vector t) (Vector t) where
22instance Container Vector t => Scaling (Vector t) t (Vector t) where 22instance Container Vector t => Scaling (Vector t) t (Vector t) where
23 (⋅) = flip scale 23 (⋅) = flip scale
24 24
25instance Container Vector t => Scaling t (Matrix t) (Matrix t) where 25instance (Num t, Container Vector t) => Scaling t (Matrix t) (Matrix t) where
26 (⋅) = scale 26 (⋅) = scale
27 27
28instance Container Vector t => Scaling (Matrix t) t (Matrix t) where 28instance (Num t, Container Vector t) => Scaling (Matrix t) t (Matrix t) where
29 (⋅) = flip scale 29 (⋅) = flip scale
30 30
31 31
@@ -42,14 +42,14 @@ class Mul a b c | a b -> c, a c -> b, b c -> a where
42instance Product t => Mul (Vector t) (Vector t) t where 42instance Product t => Mul (Vector t) (Vector t) t where
43 (×) = udot 43 (×) = udot
44 44
45instance Product t => Mul (Matrix t) (Vector t) (Vector t) where 45instance (Numeric t, Product t) => Mul (Matrix t) (Vector t) (Vector t) where
46 (×) = mXv 46 (×) = (#>)
47 47
48instance Product t => Mul (Vector t) (Matrix t) (Vector t) where 48instance (Numeric t, Product t) => Mul (Vector t) (Matrix t) (Vector t) where
49 (×) = vXm 49 (×) = (<#)
50 50
51instance Product t => Mul (Matrix t) (Matrix t) (Matrix t) where 51instance (Numeric t, Product t) => Mul (Matrix t) (Matrix t) (Matrix t) where
52 (×) = mXm 52 (×) = (<>)
53 53
54 54
55--instance Scaling a b c => Contraction a b c where 55--instance Scaling a b c => Contraction a b c where
@@ -92,9 +92,9 @@ u = fromList [3,0,5]
92w = konst 1 (2,3) :: Matrix Double 92w = konst 1 (2,3) :: Matrix Double
93 93
94main = do 94main = do
95 print $ (scale s v <> m) `udot` v 95 print $ (scale s v <# m) `udot` v
96 print $ scale s v `udot` (m <> v) 96 print $ scale s v `udot` (m #> v)
97 print $ s * ((v <> m) `udot` v) 97 print $ s * ((v <# m) `udot` v)
98 print $ s ⋅ v × m × v 98 print $ s ⋅ v × m × v
99 print a 99 print a
100-- print (b == c) 100-- print (b == c)