diff options
Diffstat (limited to 'packages/base/src')
-rw-r--r-- | packages/base/src/Internal/Algorithms.hs | 1 | ||||
-rw-r--r-- | packages/base/src/Internal/Container.hs | 1 | ||||
-rw-r--r-- | packages/base/src/Internal/Matrix.hs | 2 | ||||
-rw-r--r-- | packages/base/src/Internal/Modular.hs | 4 | ||||
-rw-r--r-- | packages/base/src/Internal/Numeric.hs | 23 |
5 files changed, 26 insertions, 5 deletions
diff --git a/packages/base/src/Internal/Algorithms.hs b/packages/base/src/Internal/Algorithms.hs index 1235da3..6ce1830 100644 --- a/packages/base/src/Internal/Algorithms.hs +++ b/packages/base/src/Internal/Algorithms.hs | |||
@@ -45,6 +45,7 @@ class (Product t, | |||
45 | Normed Matrix t, | 45 | Normed Matrix t, |
46 | Normed Vector t, | 46 | Normed Vector t, |
47 | Floating t, | 47 | Floating t, |
48 | CTrans t, | ||
48 | RealOf t ~ Double) => Field t where | 49 | RealOf t ~ Double) => Field t where |
49 | svd' :: Matrix t -> (Matrix t, Vector Double, Matrix t) | 50 | svd' :: Matrix t -> (Matrix t, Vector Double, Matrix t) |
50 | thinSVD' :: Matrix t -> (Matrix t, Vector Double, Matrix t) | 51 | thinSVD' :: Matrix t -> (Matrix t, Vector Double, Matrix t) |
diff --git a/packages/base/src/Internal/Container.hs b/packages/base/src/Internal/Container.hs index 1c158ff..8926fac 100644 --- a/packages/base/src/Internal/Container.hs +++ b/packages/base/src/Internal/Container.hs | |||
@@ -245,6 +245,7 @@ class ( Container Vector t | |||
245 | , Container Matrix t | 245 | , Container Matrix t |
246 | , Konst t Int Vector | 246 | , Konst t Int Vector |
247 | , Konst t (Int,Int) Matrix | 247 | , Konst t (Int,Int) Matrix |
248 | , CTrans t | ||
248 | , Product t | 249 | , Product t |
249 | ) => Numeric t | 250 | ) => Numeric t |
250 | 251 | ||
diff --git a/packages/base/src/Internal/Matrix.hs b/packages/base/src/Internal/Matrix.hs index a789cae..df56207 100644 --- a/packages/base/src/Internal/Matrix.hs +++ b/packages/base/src/Internal/Matrix.hs | |||
@@ -241,7 +241,7 @@ createMatrix ord r c = do | |||
241 | p <- createVector (r*c) | 241 | p <- createVector (r*c) |
242 | return (matrixFromVector ord r c p) | 242 | return (matrixFromVector ord r c p) |
243 | 243 | ||
244 | {- | Creates a matrix from a vector by grouping the elements in rows with the desired number of columns. (GNU-Octave groups by columns. To do it you can define @reshapeF r = trans . reshape r@ | 244 | {- | Creates a matrix from a vector by grouping the elements in rows with the desired number of columns. (GNU-Octave groups by columns. To do it you can define @reshapeF r = tr' . reshape r@ |
245 | where r is the desired number of rows.) | 245 | where r is the desired number of rows.) |
246 | 246 | ||
247 | >>> reshape 4 (fromList [1..12]) | 247 | >>> reshape 4 (fromList [1..12]) |
diff --git a/packages/base/src/Internal/Modular.hs b/packages/base/src/Internal/Modular.hs index 8fa2747..1d8f761 100644 --- a/packages/base/src/Internal/Modular.hs +++ b/packages/base/src/Internal/Modular.hs | |||
@@ -159,6 +159,10 @@ instance KnownNat m => Element (Mod m Z) | |||
159 | m' = fromIntegral . natVal $ (undefined :: Proxy m) | 159 | m' = fromIntegral . natVal $ (undefined :: Proxy m) |
160 | 160 | ||
161 | 161 | ||
162 | instance forall m . KnownNat m => CTrans (Mod m I) | ||
163 | instance forall m . KnownNat m => CTrans (Mod m Z) | ||
164 | |||
165 | |||
162 | instance forall m . KnownNat m => Container Vector (Mod m I) | 166 | instance forall m . KnownNat m => Container Vector (Mod m I) |
163 | where | 167 | where |
164 | conj' = id | 168 | conj' = id |
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 |