diff options
-rw-r--r-- | lib/Numeric/Container.hs | 2 | ||||
-rw-r--r-- | lib/Numeric/ContainerBoot.hs | 8 |
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/Numeric/Container.hs b/lib/Numeric/Container.hs index b3f46de..bad941c 100644 --- a/lib/Numeric/Container.hs +++ b/lib/Numeric/Container.hs | |||
@@ -128,3 +128,5 @@ instance Mul Vector Matrix Vector where | |||
128 | (<\>) :: (Field a) => Matrix a -> Vector a -> Vector a | 128 | (<\>) :: (Field a) => Matrix a -> Vector a -> Vector a |
129 | infixl 7 <\> | 129 | infixl 7 <\> |
130 | m <\> v = flatten (linearSolveSVD m (reshape 1 v)) | 130 | m <\> v = flatten (linearSolveSVD m (reshape 1 v)) |
131 | |||
132 | -------------------------------------------------------- | ||
diff --git a/lib/Numeric/ContainerBoot.hs b/lib/Numeric/ContainerBoot.hs index 1284639..f628e10 100644 --- a/lib/Numeric/ContainerBoot.hs +++ b/lib/Numeric/ContainerBoot.hs | |||
@@ -91,6 +91,9 @@ class (Complexable c, Fractional e, Element e) => Container c e where | |||
91 | divide :: c e -> c e -> c e | 91 | divide :: c e -> c e -> c e |
92 | equal :: c e -> c e -> Bool | 92 | equal :: c e -> c e -> Bool |
93 | -- | 93 | -- |
94 | -- element by element inverse tangent | ||
95 | arctan :: c e -> c e -> c e | ||
96 | -- | ||
94 | -- | cannot implement instance Functor because of Element class constraint | 97 | -- | cannot implement instance Functor because of Element class constraint |
95 | cmap :: (Element a, Element b) => (a -> b) -> c a -> c b | 98 | cmap :: (Element a, Element b) => (a -> b) -> c a -> c b |
96 | -- | constant structure of given size | 99 | -- | constant structure of given size |
@@ -130,6 +133,7 @@ instance Container Vector Float where | |||
130 | mul = vectorZipF Mul | 133 | mul = vectorZipF Mul |
131 | divide = vectorZipF Div | 134 | divide = vectorZipF Div |
132 | equal u v = dim u == dim v && maxElement (vectorMapF Abs (sub u v)) == 0.0 | 135 | equal u v = dim u == dim v && maxElement (vectorMapF Abs (sub u v)) == 0.0 |
136 | arctan = vectorZipF ATan2 | ||
133 | scalar x = fromList [x] | 137 | scalar x = fromList [x] |
134 | konst = constantD | 138 | konst = constantD |
135 | build = buildV | 139 | build = buildV |
@@ -152,6 +156,7 @@ instance Container Vector Double where | |||
152 | mul = vectorZipR Mul | 156 | mul = vectorZipR Mul |
153 | divide = vectorZipR Div | 157 | divide = vectorZipR Div |
154 | equal u v = dim u == dim v && maxElement (vectorMapR Abs (sub u v)) == 0.0 | 158 | equal u v = dim u == dim v && maxElement (vectorMapR Abs (sub u v)) == 0.0 |
159 | arctan = vectorZipR ATan2 | ||
155 | scalar x = fromList [x] | 160 | scalar x = fromList [x] |
156 | konst = constantD | 161 | konst = constantD |
157 | build = buildV | 162 | build = buildV |
@@ -174,6 +179,7 @@ instance Container Vector (Complex Double) where | |||
174 | mul = vectorZipC Mul | 179 | mul = vectorZipC Mul |
175 | divide = vectorZipC Div | 180 | divide = vectorZipC Div |
176 | equal u v = dim u == dim v && maxElement (mapVector magnitude (sub u v)) == 0.0 | 181 | equal u v = dim u == dim v && maxElement (mapVector magnitude (sub u v)) == 0.0 |
182 | arctan = vectorZipC ATan2 | ||
177 | scalar x = fromList [x] | 183 | scalar x = fromList [x] |
178 | konst = constantD | 184 | konst = constantD |
179 | build = buildV | 185 | build = buildV |
@@ -196,6 +202,7 @@ instance Container Vector (Complex Float) where | |||
196 | mul = vectorZipQ Mul | 202 | mul = vectorZipQ Mul |
197 | divide = vectorZipQ Div | 203 | divide = vectorZipQ Div |
198 | equal u v = dim u == dim v && maxElement (mapVector magnitude (sub u v)) == 0.0 | 204 | equal u v = dim u == dim v && maxElement (mapVector magnitude (sub u v)) == 0.0 |
205 | arctan = vectorZipQ ATan2 | ||
199 | scalar x = fromList [x] | 206 | scalar x = fromList [x] |
200 | konst = constantD | 207 | konst = constantD |
201 | build = buildV | 208 | build = buildV |
@@ -220,6 +227,7 @@ instance (Container Vector a) => Container Matrix a where | |||
220 | mul = liftMatrix2 mul | 227 | mul = liftMatrix2 mul |
221 | divide = liftMatrix2 divide | 228 | divide = liftMatrix2 divide |
222 | equal a b = cols a == cols b && flatten a `equal` flatten b | 229 | equal a b = cols a == cols b && flatten a `equal` flatten b |
230 | arctan = liftMatrix2 arctan | ||
223 | scalar x = (1><1) [x] | 231 | scalar x = (1><1) [x] |
224 | konst v (r,c) = reshape c (konst v (r*c)) | 232 | konst v (r,c) = reshape c (konst v (r*c)) |
225 | build = buildM | 233 | build = buildM |