summaryrefslogtreecommitdiff
path: root/lib/Numeric/Container.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Numeric/Container.hs')
-rw-r--r--lib/Numeric/Container.hs19
1 files changed, 8 insertions, 11 deletions
diff --git a/lib/Numeric/Container.hs b/lib/Numeric/Container.hs
index 44e2711..2c9c500 100644
--- a/lib/Numeric/Container.hs
+++ b/lib/Numeric/Container.hs
@@ -71,9 +71,11 @@ class (Element e) => Container c e where
71 -- | element by element division 71 -- | element by element division
72 divide :: c e -> c e -> c e 72 divide :: c e -> c e -> c e
73 equal :: c e -> c e -> Bool 73 equal :: c e -> c e -> Bool
74 74 --
75 -- | cannot implement instance Functor because of Element class constraint 75 -- | cannot implement instance Functor because of Element class constraint
76 cmap :: (Element a, Element b) => (a -> b) -> c a -> c b 76 cmap :: (Element a, Element b) => (a -> b) -> c a -> c b
77 -- | constant structure of given size
78 konst :: e -> IndexOf c -> c e
77 -- 79 --
78 -- | indexing function 80 -- | indexing function
79 atIndex :: c e -> IndexOf c -> e 81 atIndex :: c e -> IndexOf c -> e
@@ -107,8 +109,7 @@ instance Container Vector Float where
107 divide = vectorZipF Div 109 divide = vectorZipF Div
108 equal u v = dim u == dim v && maxElement (vectorMapF Abs (sub u v)) == 0.0 110 equal u v = dim u == dim v && maxElement (vectorMapF Abs (sub u v)) == 0.0
109 scalar x = fromList [x] 111 scalar x = fromList [x]
110 -- 112 konst = constantD
111--instance Container Vector Float where
112 cmap = mapVector 113 cmap = mapVector
113 atIndex = (@>) 114 atIndex = (@>)
114 minIndex = round . toScalarF MinIdx 115 minIndex = round . toScalarF MinIdx
@@ -128,8 +129,7 @@ instance Container Vector Double where
128 divide = vectorZipR Div 129 divide = vectorZipR Div
129 equal u v = dim u == dim v && maxElement (vectorMapR Abs (sub u v)) == 0.0 130 equal u v = dim u == dim v && maxElement (vectorMapR Abs (sub u v)) == 0.0
130 scalar x = fromList [x] 131 scalar x = fromList [x]
131 -- 132 konst = constantD
132--instance Container Vector Double where
133 cmap = mapVector 133 cmap = mapVector
134 atIndex = (@>) 134 atIndex = (@>)
135 minIndex = round . toScalarR MinIdx 135 minIndex = round . toScalarR MinIdx
@@ -149,8 +149,7 @@ instance Container Vector (Complex Double) where
149 divide = vectorZipC Div 149 divide = vectorZipC Div
150 equal u v = dim u == dim v && maxElement (mapVector magnitude (sub u v)) == 0.0 150 equal u v = dim u == dim v && maxElement (mapVector magnitude (sub u v)) == 0.0
151 scalar x = fromList [x] 151 scalar x = fromList [x]
152 -- 152 konst = constantD
153--instance Container Vector (Complex Double) where
154 cmap = mapVector 153 cmap = mapVector
155 atIndex = (@>) 154 atIndex = (@>)
156 minIndex = minIndex . fst . fromComplex . (zipVectorWith (*) `ap` mapVector conjugate) 155 minIndex = minIndex . fst . fromComplex . (zipVectorWith (*) `ap` mapVector conjugate)
@@ -170,8 +169,7 @@ instance Container Vector (Complex Float) where
170 divide = vectorZipQ Div 169 divide = vectorZipQ Div
171 equal u v = dim u == dim v && maxElement (mapVector magnitude (sub u v)) == 0.0 170 equal u v = dim u == dim v && maxElement (mapVector magnitude (sub u v)) == 0.0
172 scalar x = fromList [x] 171 scalar x = fromList [x]
173 -- 172 konst = constantD
174--instance Container Vector (Complex Float) where
175 cmap = mapVector 173 cmap = mapVector
176 atIndex = (@>) 174 atIndex = (@>)
177 minIndex = minIndex . fst . fromComplex . (zipVectorWith (*) `ap` mapVector conjugate) 175 minIndex = minIndex . fst . fromComplex . (zipVectorWith (*) `ap` mapVector conjugate)
@@ -193,8 +191,7 @@ instance (Container Vector a) => Container Matrix a where
193 divide = liftMatrix2 divide 191 divide = liftMatrix2 divide
194 equal a b = cols a == cols b && flatten a `equal` flatten b 192 equal a b = cols a == cols b && flatten a `equal` flatten b
195 scalar x = (1><1) [x] 193 scalar x = (1><1) [x]
196 -- 194 konst v (r,c) = reshape c (konst v (r*c))
197--instance (Container Vector a) => Container Matrix a where
198 cmap f = liftMatrix (mapVector f) 195 cmap f = liftMatrix (mapVector f)
199 atIndex = (@@>) 196 atIndex = (@@>)
200 minIndex m = let (r,c) = (rows m,cols m) 197 minIndex m = let (r,c) = (rows m,cols m)