diff options
Diffstat (limited to 'packages/base')
-rw-r--r-- | packages/base/src/Numeric/LinearAlgebra/Static.hs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/packages/base/src/Numeric/LinearAlgebra/Static.hs b/packages/base/src/Numeric/LinearAlgebra/Static.hs index e18ba0c..84a623b 100644 --- a/packages/base/src/Numeric/LinearAlgebra/Static.hs +++ b/packages/base/src/Numeric/LinearAlgebra/Static.hs | |||
@@ -786,3 +786,40 @@ instance (KnownNat m, KnownNat n) => Normed (L m n) | |||
786 | norm_1 m = norm_1 (extract m) | 786 | norm_1 m = norm_1 (extract m) |
787 | norm_2 m = norm_2 (extract m) | 787 | norm_2 m = norm_2 (extract m) |
788 | norm_Inf m = norm_Inf (extract m) | 788 | norm_Inf m = norm_Inf (extract m) |
789 | |||
790 | mkSym f = Sym . f . unSym | ||
791 | mkSym2 f x y = Sym (f (unSym x) (unSym y)) | ||
792 | |||
793 | instance KnownNat n => Num (Sym n) | ||
794 | where | ||
795 | (+) = mkSym2 (+) | ||
796 | (*) = mkSym2 (*) | ||
797 | (-) = mkSym2 (-) | ||
798 | abs = mkSym abs | ||
799 | signum = mkSym signum | ||
800 | negate = mkSym negate | ||
801 | fromInteger = Sym . fromInteger | ||
802 | |||
803 | instance KnownNat n => Fractional (Sym n) | ||
804 | where | ||
805 | fromRational = Sym . L . Dim . Dim . fromRational | ||
806 | (/) = mkSym2 (/) | ||
807 | |||
808 | instance KnownNat n => Floating (Sym n) where | ||
809 | sin = mkSym sin | ||
810 | cos = mkSym cos | ||
811 | tan = mkSym tan | ||
812 | asin = mkSym asin | ||
813 | acos = mkSym acos | ||
814 | atan = mkSym atan | ||
815 | sinh = mkSym sinh | ||
816 | cosh = mkSym cosh | ||
817 | tanh = mkSym tanh | ||
818 | asinh = mkSym asinh | ||
819 | acosh = mkSym acosh | ||
820 | atanh = mkSym atanh | ||
821 | exp = mkSym exp | ||
822 | log = mkSym log | ||
823 | sqrt = mkSym sqrt | ||
824 | (**) = mkSym2 (**) | ||
825 | pi = Sym pi | ||