diff options
-rw-r--r-- | packages/base/src/Internal/Algorithms.hs | 5 | ||||
-rw-r--r-- | packages/base/src/Internal/Container.hs | 41 | ||||
-rw-r--r-- | packages/base/src/Internal/Numeric.hs | 42 | ||||
-rw-r--r-- | packages/base/src/Internal/Sparse.hs | 1 |
4 files changed, 43 insertions, 46 deletions
diff --git a/packages/base/src/Internal/Algorithms.hs b/packages/base/src/Internal/Algorithms.hs index 99c90aa..3d25491 100644 --- a/packages/base/src/Internal/Algorithms.hs +++ b/packages/base/src/Internal/Algorithms.hs | |||
@@ -38,14 +38,11 @@ import Internal.Vectorized(range) | |||
38 | (Single precision data can be converted using 'single' and 'double'). | 38 | (Single precision data can be converted using 'single' and 'double'). |
39 | 39 | ||
40 | -} | 40 | -} |
41 | class (Product t, | 41 | class (Numeric t, |
42 | Convert t, | 42 | Convert t, |
43 | Container Vector t, | ||
44 | Container Matrix t, | ||
45 | Normed Matrix t, | 43 | Normed Matrix t, |
46 | Normed Vector t, | 44 | Normed Vector t, |
47 | Floating t, | 45 | Floating t, |
48 | CTrans t, | ||
49 | RealOf t ~ Double) => Field t where | 46 | RealOf t ~ Double) => Field t where |
50 | svd' :: Matrix t -> (Matrix t, Vector Double, Matrix t) | 47 | svd' :: Matrix t -> (Matrix t, Vector Double, Matrix t) |
51 | thinSVD' :: Matrix t -> (Matrix t, Vector Double, Matrix t) | 48 | thinSVD' :: Matrix t -> (Matrix t, Vector Double, Matrix t) |
diff --git a/packages/base/src/Internal/Container.hs b/packages/base/src/Internal/Container.hs index 307c6a8..b08f892 100644 --- a/packages/base/src/Internal/Container.hs +++ b/packages/base/src/Internal/Container.hs | |||
@@ -28,7 +28,6 @@ import Internal.Vector | |||
28 | import Internal.Matrix | 28 | import Internal.Matrix |
29 | import Internal.Element | 29 | import Internal.Element |
30 | import Internal.Numeric | 30 | import Internal.Numeric |
31 | import Data.Complex | ||
32 | import Internal.Algorithms(Field,linearSolveSVD) | 31 | import Internal.Algorithms(Field,linearSolveSVD) |
33 | 32 | ||
34 | ------------------------------------------------------------------ | 33 | ------------------------------------------------------------------ |
@@ -158,29 +157,6 @@ instance LSDiv Matrix | |||
158 | 157 | ||
159 | -------------------------------------------------------------------------------- | 158 | -------------------------------------------------------------------------------- |
160 | 159 | ||
161 | class Konst e d c | d -> c, c -> d | ||
162 | where | ||
163 | -- | | ||
164 | -- >>> konst 7 3 :: Vector Float | ||
165 | -- fromList [7.0,7.0,7.0] | ||
166 | -- | ||
167 | -- >>> konst i (3::Int,4::Int) | ||
168 | -- (3><4) | ||
169 | -- [ 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0 | ||
170 | -- , 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0 | ||
171 | -- , 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0 ] | ||
172 | -- | ||
173 | konst :: e -> d -> c e | ||
174 | |||
175 | instance Container Vector e => Konst e Int Vector | ||
176 | where | ||
177 | konst = konst' | ||
178 | |||
179 | instance (Num e, Container Vector e) => Konst e (Int,Int) Matrix | ||
180 | where | ||
181 | konst = konst' | ||
182 | |||
183 | -------------------------------------------------------------------------------- | ||
184 | 160 | ||
185 | class Build d f c e | d -> c, c -> d, f -> e, f -> d, f -> c, c e -> f, d e -> f | 161 | class Build d f c e | d -> c, c -> d, f -> e, f -> d, f -> c, c e -> f, d e -> f |
186 | where | 162 | where |
@@ -241,23 +217,6 @@ meanCov x = (med,cov) where | |||
241 | 217 | ||
242 | -------------------------------------------------------------------------------- | 218 | -------------------------------------------------------------------------------- |
243 | 219 | ||
244 | class ( Container Vector t | ||
245 | , Container Matrix t | ||
246 | , Konst t Int Vector | ||
247 | , Konst t (Int,Int) Matrix | ||
248 | , CTrans t | ||
249 | , Product t | ||
250 | ) => Numeric t | ||
251 | |||
252 | instance Numeric Double | ||
253 | instance Numeric (Complex Double) | ||
254 | instance Numeric Float | ||
255 | instance Numeric (Complex Float) | ||
256 | instance Numeric I | ||
257 | instance Numeric Z | ||
258 | |||
259 | -------------------------------------------------------------------------------- | ||
260 | |||
261 | sortVector :: (Ord t, Element t) => Vector t -> Vector t | 220 | sortVector :: (Ord t, Element t) => Vector t -> Vector t |
262 | sortVector = sortV | 221 | sortVector = sortV |
263 | 222 | ||
diff --git a/packages/base/src/Internal/Numeric.hs b/packages/base/src/Internal/Numeric.hs index 4d34885..a8ae2bb 100644 --- a/packages/base/src/Internal/Numeric.hs +++ b/packages/base/src/Internal/Numeric.hs | |||
@@ -549,6 +549,48 @@ accum | |||
549 | -> c e -- ^ result | 549 | -> c e -- ^ result |
550 | accum = accum' | 550 | accum = accum' |
551 | 551 | ||
552 | -------------------------------------------------------------------------------- | ||
553 | |||
554 | class Konst e d c | d -> c, c -> d | ||
555 | where | ||
556 | -- | | ||
557 | -- >>> konst 7 3 :: Vector Float | ||
558 | -- fromList [7.0,7.0,7.0] | ||
559 | -- | ||
560 | -- >>> konst i (3::Int,4::Int) | ||
561 | -- (3><4) | ||
562 | -- [ 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0 | ||
563 | -- , 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0 | ||
564 | -- , 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0 ] | ||
565 | -- | ||
566 | konst :: e -> d -> c e | ||
567 | |||
568 | instance Container Vector e => Konst e Int Vector | ||
569 | where | ||
570 | konst = konst' | ||
571 | |||
572 | instance (Num e, Container Vector e) => Konst e (Int,Int) Matrix | ||
573 | where | ||
574 | konst = konst' | ||
575 | |||
576 | -------------------------------------------------------------------------------- | ||
577 | |||
578 | class ( Container Vector t | ||
579 | , Container Matrix t | ||
580 | , Konst t Int Vector | ||
581 | , Konst t (Int,Int) Matrix | ||
582 | , CTrans t | ||
583 | , Product t | ||
584 | ) => Numeric t | ||
585 | |||
586 | instance Numeric Double | ||
587 | instance Numeric (Complex Double) | ||
588 | instance Numeric Float | ||
589 | instance Numeric (Complex Float) | ||
590 | instance Numeric I | ||
591 | instance Numeric Z | ||
592 | |||
593 | -------------------------------------------------------------------------------- | ||
552 | 594 | ||
553 | -------------------------------------------------------------------------------- | 595 | -------------------------------------------------------------------------------- |
554 | 596 | ||
diff --git a/packages/base/src/Internal/Sparse.hs b/packages/base/src/Internal/Sparse.hs index eb4ee1b..1604e7e 100644 --- a/packages/base/src/Internal/Sparse.hs +++ b/packages/base/src/Internal/Sparse.hs | |||
@@ -13,7 +13,6 @@ module Internal.Sparse( | |||
13 | import Internal.Vector | 13 | import Internal.Vector |
14 | import Internal.Matrix | 14 | import Internal.Matrix |
15 | import Internal.Numeric | 15 | import Internal.Numeric |
16 | import Internal.Container | ||
17 | import qualified Data.Vector.Storable as V | 16 | import qualified Data.Vector.Storable as V |
18 | import Data.Function(on) | 17 | import Data.Function(on) |
19 | import Control.Arrow((***)) | 18 | import Control.Arrow((***)) |