diff options
author | Alberto Ruiz <aruiz@um.es> | 2014-06-04 14:14:31 +0200 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2014-06-04 14:14:31 +0200 |
commit | 0476c58d0b9da4fdcbbcb05ea055f6d14097e116 (patch) | |
tree | 65cc2d7a0388820153038518554e27f67e359cf9 /packages/base/src/Numeric/LinearAlgebra/Static.hs | |
parent | 9a17969ad0ea9f940db6201a37b9aed19ad605df (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.hs | 19 |
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 | ||
77 | instance (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 | |||
77 | instance (Num (Matrix t), Numeric t) => Num (Dim m (Dim n (Matrix t))) | 83 | instance (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 | ||
87 | instance (Num (Vector t), Num (Matrix t), Numeric t) => Fractional (Dim n (Vector t)) | ||
88 | where | ||
89 | fromRational x = Dim (fromRational x) | ||
90 | (/) = lift2F (/) | ||
91 | |||
92 | instance (Num (Vector t), Num (Matrix t), Numeric t) => Fractional (Dim m (Dim n (Matrix t))) | 93 | instance (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 | ||
107 | type M m n t = Dim m (Dim n (Matrix t)) | 108 | type M m n t = Dim m (Dim n (Matrix t)) |
108 | 109 | ||
109 | ud2 :: Dim m (Dim n (Matrix t)) -> Matrix t | 110 | --ud2 :: Dim m (Dim n (Matrix t)) -> Matrix t |
110 | ud2 (Dim (Dim m)) = m | 111 | --ud2 (Dim (Dim m)) = m |
111 | 112 | ||
112 | mkM :: forall (m :: Nat) (n :: Nat) t . t -> Dim m (Dim n t) | 113 | mkM :: forall (m :: Nat) (n :: Nat) t . t -> Dim m (Dim n t) |
113 | mkM = Dim . Dim | 114 | mkM = Dim . Dim |
@@ -184,9 +185,9 @@ gmat st xs' | |||
184 | class Num t => Sized t s d | s -> t, s -> d | 185 | class 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 | ||
191 | singleV v = size v == 1 | 192 | singleV v = size v == 1 |
192 | singleM m = rows m == 1 && cols m == 1 | 193 | singleM m = rows m == 1 && cols m == 1 |