diff options
Diffstat (limited to 'lib/Numeric/Container.hs')
-rw-r--r-- | lib/Numeric/Container.hs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/Numeric/Container.hs b/lib/Numeric/Container.hs index 83bf44e..1afc5a1 100644 --- a/lib/Numeric/Container.hs +++ b/lib/Numeric/Container.hs | |||
@@ -22,6 +22,7 @@ | |||
22 | module Numeric.Container ( | 22 | module Numeric.Container ( |
23 | -- * Generic operations | 23 | -- * Generic operations |
24 | Container(..), | 24 | Container(..), |
25 | ctrans, diag, ident, | ||
25 | -- * Matrix product and related functions | 26 | -- * Matrix product and related functions |
26 | Product(..), | 27 | Product(..), |
27 | mXm,mXv,vXm, | 28 | mXm,mXv,vXm, |
@@ -221,6 +222,20 @@ instance (Container Vector a) => Container Matrix a where | |||
221 | 222 | ||
222 | ---------------------------------------------------- | 223 | ---------------------------------------------------- |
223 | 224 | ||
225 | -- | conjugate transpose | ||
226 | ctrans :: Element e => Matrix e -> Matrix e | ||
227 | ctrans = liftMatrix conjugateD . trans | ||
228 | |||
229 | -- | Creates a square matrix with a given diagonal. | ||
230 | diag :: (Num a, Element a) => Vector a -> Matrix a | ||
231 | diag v = diagRect 0 v n n where n = dim v | ||
232 | |||
233 | -- | creates the identity matrix of given dimension | ||
234 | ident :: (Num a, Element a) => Int -> Matrix a | ||
235 | ident n = diag (constantD 1 n) | ||
236 | |||
237 | ---------------------------------------------------- | ||
238 | |||
224 | 239 | ||
225 | -- | Matrix product and related functions | 240 | -- | Matrix product and related functions |
226 | class Element e => Product e where | 241 | class Element e => Product e where |