diff options
-rw-r--r-- | lib/Numeric/MatrixBoot.hs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/Numeric/MatrixBoot.hs b/lib/Numeric/MatrixBoot.hs new file mode 100644 index 0000000..13560b1 --- /dev/null +++ b/lib/Numeric/MatrixBoot.hs | |||
@@ -0,0 +1,41 @@ | |||
1 | {-# LANGUAGE FlexibleContexts #-} | ||
2 | ----------------------------------------------------------------------------- | ||
3 | -- | | ||
4 | -- Module : Numeric.MatrixBoot | ||
5 | -- Copyright : (c) Alberto Ruiz 2010 | ||
6 | -- License : GPL-style | ||
7 | -- | ||
8 | -- Maintainer : Alberto Ruiz <aruiz@um.es> | ||
9 | -- Stability : provisional | ||
10 | -- Portability : portable | ||
11 | -- | ||
12 | -- Module to avoid cyclic dependency | ||
13 | -- | ||
14 | ----------------------------------------------------------------------------- | ||
15 | |||
16 | module Numeric.MatrixBoot ( | ||
17 | ctrans, diag, ident, | ||
18 | ) where | ||
19 | |||
20 | import Data.Packed.Vector | ||
21 | import Data.Packed.Matrix | ||
22 | import Data.Packed.Internal.Matrix | ||
23 | import Numeric.Container | ||
24 | |||
25 | ------------------------------------------------------------------- | ||
26 | |||
27 | -- | conjugate transpose | ||
28 | ctrans :: (Container Vector e, Element e) => Matrix e -> Matrix e | ||
29 | ctrans = liftMatrix conj . trans | ||
30 | |||
31 | -- | Creates a square matrix with a given diagonal. | ||
32 | diag :: (Num a, Element a) => Vector a -> Matrix a | ||
33 | diag v = diagRect 0 v n n where n = dim v | ||
34 | |||
35 | -- | creates the identity matrix of given dimension | ||
36 | ident :: (Num a, Element a) => Int -> Matrix a | ||
37 | ident n = diag (constantD 1 n) | ||
38 | |||
39 | ---------------------------------------------------- | ||
40 | |||
41 | |||