diff options
author | Alberto Ruiz <aruiz@um.es> | 2015-06-30 12:30:57 +0200 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2015-06-30 12:30:57 +0200 |
commit | 4730254f061832591d4a44c86d3bdfa4620f4322 (patch) | |
tree | 3499347e0dfe8edb778101f6d124333a21f5b67e /packages/base/src/Internal/Numeric.hs | |
parent | b9329d636d19f6a26da1cf1fd7e8d7cbd0b04cce (diff) |
CTrans class to preserve slices in real transposes
Diffstat (limited to 'packages/base/src/Internal/Numeric.hs')
-rw-r--r-- | packages/base/src/Internal/Numeric.hs | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/packages/base/src/Internal/Numeric.hs b/packages/base/src/Internal/Numeric.hs index efcde2c..4d34885 100644 --- a/packages/base/src/Internal/Numeric.hs +++ b/packages/base/src/Internal/Numeric.hs | |||
@@ -782,9 +782,6 @@ buildV n f = fromList [f k | k <- ks] | |||
782 | where ks = map fromIntegral [0 .. (n-1)] | 782 | where ks = map fromIntegral [0 .. (n-1)] |
783 | 783 | ||
784 | -------------------------------------------------------- | 784 | -------------------------------------------------------- |
785 | -- | conjugate transpose | ||
786 | ctrans :: (Container Vector e, Element e) => Matrix e -> Matrix e | ||
787 | ctrans = liftMatrix conj' . trans | ||
788 | 785 | ||
789 | -- | Creates a square matrix with a given diagonal. | 786 | -- | Creates a square matrix with a given diagonal. |
790 | diag :: (Num a, Element a) => Vector a -> Matrix a | 787 | diag :: (Num a, Element a) => Vector a -> Matrix a |
@@ -843,6 +840,24 @@ selectCV f c l e t = f (toInt c') l' e' t' | |||
843 | 840 | ||
844 | -------------------------------------------------------------------------------- | 841 | -------------------------------------------------------------------------------- |
845 | 842 | ||
843 | class CTrans t | ||
844 | where | ||
845 | ctrans :: Matrix t -> Matrix t | ||
846 | ctrans = trans | ||
847 | |||
848 | instance CTrans Float | ||
849 | instance CTrans R | ||
850 | instance CTrans I | ||
851 | instance CTrans Z | ||
852 | |||
853 | instance CTrans C | ||
854 | where | ||
855 | ctrans = conj . trans | ||
856 | |||
857 | instance CTrans (Complex Float) | ||
858 | where | ||
859 | ctrans = conj . trans | ||
860 | |||
846 | class Transposable m mt | m -> mt, mt -> m | 861 | class Transposable m mt | m -> mt, mt -> m |
847 | where | 862 | where |
848 | -- | conjugate transpose | 863 | -- | conjugate transpose |
@@ -850,7 +865,7 @@ class Transposable m mt | m -> mt, mt -> m | |||
850 | -- | transpose | 865 | -- | transpose |
851 | tr' :: m -> mt | 866 | tr' :: m -> mt |
852 | 867 | ||
853 | instance (Container Vector t) => Transposable (Matrix t) (Matrix t) | 868 | instance (CTrans t, Container Vector t) => Transposable (Matrix t) (Matrix t) |
854 | where | 869 | where |
855 | tr = ctrans | 870 | tr = ctrans |
856 | tr' = trans | 871 | tr' = trans |