diff options
Diffstat (limited to 'examples/multiply.hs')
-rw-r--r-- | examples/multiply.hs | 22 |
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 | |||
22 | instance Container Vector t => Scaling (Vector t) t (Vector t) where | 22 | instance Container Vector t => Scaling (Vector t) t (Vector t) where |
23 | (⋅) = flip scale | 23 | (⋅) = flip scale |
24 | 24 | ||
25 | instance Container Vector t => Scaling t (Matrix t) (Matrix t) where | 25 | instance (Num t, Container Vector t) => Scaling t (Matrix t) (Matrix t) where |
26 | (⋅) = scale | 26 | (⋅) = scale |
27 | 27 | ||
28 | instance Container Vector t => Scaling (Matrix t) t (Matrix t) where | 28 | instance (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 | |||
42 | instance Product t => Mul (Vector t) (Vector t) t where | 42 | instance Product t => Mul (Vector t) (Vector t) t where |
43 | (×) = udot | 43 | (×) = udot |
44 | 44 | ||
45 | instance Product t => Mul (Matrix t) (Vector t) (Vector t) where | 45 | instance (Numeric t, Product t) => Mul (Matrix t) (Vector t) (Vector t) where |
46 | (×) = mXv | 46 | (×) = (#>) |
47 | 47 | ||
48 | instance Product t => Mul (Vector t) (Matrix t) (Vector t) where | 48 | instance (Numeric t, Product t) => Mul (Vector t) (Matrix t) (Vector t) where |
49 | (×) = vXm | 49 | (×) = (<#) |
50 | 50 | ||
51 | instance Product t => Mul (Matrix t) (Matrix t) (Matrix t) where | 51 | instance (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] | |||
92 | w = konst 1 (2,3) :: Matrix Double | 92 | w = konst 1 (2,3) :: Matrix Double |
93 | 93 | ||
94 | main = do | 94 | main = 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) |