diff options
-rw-r--r-- | lib/Data/Packed/Internal/Matrix.hs | 5 | ||||
-rw-r--r-- | lib/Data/Packed/Matrix.hs | 6 | ||||
-rw-r--r-- | lib/Numeric/Container.hs | 6 |
3 files changed, 10 insertions, 7 deletions
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs index e66817e..5892f1c 100644 --- a/lib/Data/Packed/Internal/Matrix.hs +++ b/lib/Data/Packed/Internal/Matrix.hs | |||
@@ -255,22 +255,27 @@ class (Storable a, Floating a) => Element a where | |||
255 | transdata = transdata' | 255 | transdata = transdata' |
256 | constantD :: a -> Int -> Vector a | 256 | constantD :: a -> Int -> Vector a |
257 | constantD = constant' | 257 | constantD = constant' |
258 | ctrans' :: Matrix a -> Matrix a | ||
258 | 259 | ||
259 | instance Element Float where | 260 | instance Element Float where |
260 | transdata = transdataAux ctransF | 261 | transdata = transdataAux ctransF |
261 | constantD = constantAux cconstantF | 262 | constantD = constantAux cconstantF |
263 | ctrans' = trans | ||
262 | 264 | ||
263 | instance Element Double where | 265 | instance Element Double where |
264 | transdata = transdataAux ctransR | 266 | transdata = transdataAux ctransR |
265 | constantD = constantAux cconstantR | 267 | constantD = constantAux cconstantR |
268 | ctrans' = trans | ||
266 | 269 | ||
267 | instance Element (Complex Float) where | 270 | instance Element (Complex Float) where |
268 | transdata = transdataAux ctransQ | 271 | transdata = transdataAux ctransQ |
269 | constantD = constantAux cconstantQ | 272 | constantD = constantAux cconstantQ |
273 | ctrans' = liftMatrix (mapVector conjugate) . trans | ||
270 | 274 | ||
271 | instance Element (Complex Double) where | 275 | instance Element (Complex Double) where |
272 | transdata = transdataAux ctransC | 276 | transdata = transdataAux ctransC |
273 | constantD = constantAux cconstantC | 277 | constantD = constantAux cconstantC |
278 | ctrans' = liftMatrix (mapVector conjugate) . trans | ||
274 | 279 | ||
275 | ------------------------------------------------------------------- | 280 | ------------------------------------------------------------------- |
276 | 281 | ||
diff --git a/lib/Data/Packed/Matrix.hs b/lib/Data/Packed/Matrix.hs index 03e5889..af937f4 100644 --- a/lib/Data/Packed/Matrix.hs +++ b/lib/Data/Packed/Matrix.hs | |||
@@ -22,7 +22,7 @@ module Data.Packed.Matrix ( | |||
22 | Element, | 22 | Element, |
23 | Matrix,rows,cols, | 23 | Matrix,rows,cols, |
24 | (><), | 24 | (><), |
25 | trans, | 25 | trans, ctrans, |
26 | reshape, flatten, | 26 | reshape, flatten, |
27 | fromLists, toLists, buildMatrix, | 27 | fromLists, toLists, buildMatrix, |
28 | (@@>), | 28 | (@@>), |
@@ -268,6 +268,10 @@ asRow v = reshape (dim v) v | |||
268 | asColumn :: Element a => Vector a -> Matrix a | 268 | asColumn :: Element a => Vector a -> Matrix a |
269 | asColumn v = reshape 1 v | 269 | asColumn v = reshape 1 v |
270 | 270 | ||
271 | -- | conjugate transpose | ||
272 | ctrans :: Element e => Matrix e -> Matrix e | ||
273 | ctrans = ctrans' | ||
274 | |||
271 | 275 | ||
272 | {- | creates a Matrix of the specified size using the supplied function to | 276 | {- | creates a Matrix of the specified size using the supplied function to |
273 | to map the row/column position to the value at that row/column position. | 277 | to map the row/column position to the value at that row/column position. |
diff --git a/lib/Numeric/Container.hs b/lib/Numeric/Container.hs index 0a07adc..77c9902 100644 --- a/lib/Numeric/Container.hs +++ b/lib/Numeric/Container.hs | |||
@@ -213,8 +213,6 @@ instance (Container Vector a) => Container Matrix a where | |||
213 | class Element e => Product e where | 213 | class Element e => Product e where |
214 | -- | matrix product | 214 | -- | matrix product |
215 | multiply :: Matrix e -> Matrix e -> Matrix e | 215 | multiply :: Matrix e -> Matrix e -> Matrix e |
216 | -- | conjugate transpose | ||
217 | ctrans :: Matrix e -> Matrix e | ||
218 | -- | dot (inner) product | 216 | -- | dot (inner) product |
219 | dot :: Vector e -> Vector e -> e | 217 | dot :: Vector e -> Vector e -> e |
220 | -- | sum of absolute value of elements (differs in complex case from @norm1@ | 218 | -- | sum of absolute value of elements (differs in complex case from @norm1@ |
@@ -233,7 +231,6 @@ instance Product Float where | |||
233 | norm1 = toScalarF AbsSum | 231 | norm1 = toScalarF AbsSum |
234 | normInf = maxElement . vectorMapF Abs | 232 | normInf = maxElement . vectorMapF Abs |
235 | multiply = multiplyF | 233 | multiply = multiplyF |
236 | ctrans = trans | ||
237 | 234 | ||
238 | instance Product Double where | 235 | instance Product Double where |
239 | norm2 = toScalarR Norm2 | 236 | norm2 = toScalarR Norm2 |
@@ -242,7 +239,6 @@ instance Product Double where | |||
242 | norm1 = toScalarR AbsSum | 239 | norm1 = toScalarR AbsSum |
243 | normInf = maxElement . vectorMapR Abs | 240 | normInf = maxElement . vectorMapR Abs |
244 | multiply = multiplyR | 241 | multiply = multiplyR |
245 | ctrans = trans | ||
246 | 242 | ||
247 | instance Product (Complex Float) where | 243 | instance Product (Complex Float) where |
248 | norm2 = toScalarQ Norm2 | 244 | norm2 = toScalarQ Norm2 |
@@ -251,7 +247,6 @@ instance Product (Complex Float) where | |||
251 | norm1 = sumElements . fst . fromComplex . vectorMapQ Abs | 247 | norm1 = sumElements . fst . fromComplex . vectorMapQ Abs |
252 | normInf = maxElement . fst . fromComplex . vectorMapQ Abs | 248 | normInf = maxElement . fst . fromComplex . vectorMapQ Abs |
253 | multiply = multiplyQ | 249 | multiply = multiplyQ |
254 | ctrans = conj . trans | ||
255 | 250 | ||
256 | instance Product (Complex Double) where | 251 | instance Product (Complex Double) where |
257 | norm2 = toScalarC Norm2 | 252 | norm2 = toScalarC Norm2 |
@@ -260,7 +255,6 @@ instance Product (Complex Double) where | |||
260 | norm1 = sumElements . fst . fromComplex . vectorMapC Abs | 255 | norm1 = sumElements . fst . fromComplex . vectorMapC Abs |
261 | normInf = maxElement . fst . fromComplex . vectorMapC Abs | 256 | normInf = maxElement . fst . fromComplex . vectorMapC Abs |
262 | multiply = multiplyC | 257 | multiply = multiplyC |
263 | ctrans = conj . trans | ||
264 | 258 | ||
265 | ---------------------------------------------------------- | 259 | ---------------------------------------------------------- |
266 | 260 | ||