summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2016-01-29 20:25:21 +0100
committerAlberto Ruiz <aruiz@um.es>2016-01-29 20:25:21 +0100
commit95c7cc6303fdb0af3ca0e1fc08cfe3ebf2674814 (patch)
tree207b9f4a96f74ebbf6003cbf4f739ae60476bfdd /packages
parenta7c1ccf2f1f69982076ad2acc1029abc95460430 (diff)
parent85703cc308e6de7f60945661db11f5d828bf096f (diff)
Merge pull request #173 from sid-kap/sym_instances
Add Num, Fractional, Floating instances for Sym
Diffstat (limited to 'packages')
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Static.hs38
1 files changed, 38 insertions, 0 deletions
diff --git a/packages/base/src/Numeric/LinearAlgebra/Static.hs b/packages/base/src/Numeric/LinearAlgebra/Static.hs
index e18ba0c..3e772b2 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Static.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Static.hs
@@ -786,3 +786,41 @@ 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
790mkSym f = Sym . f . unSym
791mkSym2 f x y = Sym (f (unSym x) (unSym y))
792
793instance 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
803instance KnownNat n => Fractional (Sym n)
804 where
805 fromRational = Sym . fromRational
806 (/) = mkSym2 (/)
807
808instance KnownNat n => Floating (Sym n)
809 where
810 sin = mkSym sin
811 cos = mkSym cos
812 tan = mkSym tan
813 asin = mkSym asin
814 acos = mkSym acos
815 atan = mkSym atan
816 sinh = mkSym sinh
817 cosh = mkSym cosh
818 tanh = mkSym tanh
819 asinh = mkSym asinh
820 acosh = mkSym acosh
821 atanh = mkSym atanh
822 exp = mkSym exp
823 log = mkSym log
824 sqrt = mkSym sqrt
825 (**) = mkSym2 (**)
826 pi = Sym pi