summaryrefslogtreecommitdiff
path: root/packages/base/src/Numeric/LinearAlgebra/Static.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2014-06-04 14:14:31 +0200
committerAlberto Ruiz <aruiz@um.es>2014-06-04 14:14:31 +0200
commit0476c58d0b9da4fdcbbcb05ea055f6d14097e116 (patch)
tree65cc2d7a0388820153038518554e27f67e359cf9 /packages/base/src/Numeric/LinearAlgebra/Static.hs
parent9a17969ad0ea9f940db6201a37b9aed19ad605df (diff)
operations with nonexpanded constant and diagonal matrices
Diffstat (limited to 'packages/base/src/Numeric/LinearAlgebra/Static.hs')
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Static.hs19
1 files changed, 10 insertions, 9 deletions
diff --git a/packages/base/src/Numeric/LinearAlgebra/Static.hs b/packages/base/src/Numeric/LinearAlgebra/Static.hs
index f9e935d..5caf6f8 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Static.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Static.hs
@@ -74,6 +74,12 @@ instance forall n t . (Num (Vector t), Numeric t )=> Num (Dim n (Vector t))
74 negate = lift1F negate 74 negate = lift1F negate
75 fromInteger x = Dim (fromInteger x) 75 fromInteger x = Dim (fromInteger x)
76 76
77instance (Num (Vector t), Num (Matrix t), Numeric t) => Fractional (Dim n (Vector t))
78 where
79 fromRational x = Dim (fromRational x)
80 (/) = lift2F (/)
81
82
77instance (Num (Matrix t), Numeric t) => Num (Dim m (Dim n (Matrix t))) 83instance (Num (Matrix t), Numeric t) => Num (Dim m (Dim n (Matrix t)))
78 where 84 where
79 (+) = (lift2F . lift2F) (+) 85 (+) = (lift2F . lift2F) (+)
@@ -84,11 +90,6 @@ instance (Num (Matrix t), Numeric t) => Num (Dim m (Dim n (Matrix t)))
84 negate = (lift1F . lift1F) negate 90 negate = (lift1F . lift1F) negate
85 fromInteger x = Dim (Dim (fromInteger x)) 91 fromInteger x = Dim (Dim (fromInteger x))
86 92
87instance (Num (Vector t), Num (Matrix t), Numeric t) => Fractional (Dim n (Vector t))
88 where
89 fromRational x = Dim (fromRational x)
90 (/) = lift2F (/)
91
92instance (Num (Vector t), Num (Matrix t), Numeric t) => Fractional (Dim m (Dim n (Matrix t))) 93instance (Num (Vector t), Num (Matrix t), Numeric t) => Fractional (Dim m (Dim n (Matrix t)))
93 where 94 where
94 fromRational x = Dim (Dim (fromRational x)) 95 fromRational x = Dim (Dim (fromRational x))
@@ -106,8 +107,8 @@ mkV = Dim
106 107
107type M m n t = Dim m (Dim n (Matrix t)) 108type M m n t = Dim m (Dim n (Matrix t))
108 109
109ud2 :: Dim m (Dim n (Matrix t)) -> Matrix t 110--ud2 :: Dim m (Dim n (Matrix t)) -> Matrix t
110ud2 (Dim (Dim m)) = m 111--ud2 (Dim (Dim m)) = m
111 112
112mkM :: forall (m :: Nat) (n :: Nat) t . t -> Dim m (Dim n t) 113mkM :: forall (m :: Nat) (n :: Nat) t . t -> Dim m (Dim n t)
113mkM = Dim . Dim 114mkM = Dim . Dim
@@ -184,9 +185,9 @@ gmat st xs'
184class Num t => Sized t s d | s -> t, s -> d 185class Num t => Sized t s d | s -> t, s -> d
185 where 186 where
186 konst :: t -> s 187 konst :: t -> s
187 extract :: s -> d 188 unwrap :: s -> d
188 fromList :: [t] -> s 189 fromList :: [t] -> s
189 expand :: s -> d 190 extract :: s -> d
190 191
191singleV v = size v == 1 192singleV v = size v == 1
192singleM m = rows m == 1 && cols m == 1 193singleM m = rows m == 1 && cols m == 1