summaryrefslogtreecommitdiff
path: root/packages/base/src/Internal/Numeric.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2015-07-13 12:28:15 +0200
committerAlberto Ruiz <aruiz@um.es>2015-07-13 12:28:15 +0200
commit14f492c0139c7d7e2768311068beda5441730ce3 (patch)
tree14f325bbfa9b7d1bc7ccf16e6b73ac4db14db953 /packages/base/src/Internal/Numeric.hs
parenta3b28fdf0b6a335b4905c25413cf82438383319e (diff)
make Numeric superclass of Field
Diffstat (limited to 'packages/base/src/Internal/Numeric.hs')
-rw-r--r--packages/base/src/Internal/Numeric.hs42
1 files changed, 42 insertions, 0 deletions
diff --git a/packages/base/src/Internal/Numeric.hs b/packages/base/src/Internal/Numeric.hs
index 4d34885..a8ae2bb 100644
--- a/packages/base/src/Internal/Numeric.hs
+++ b/packages/base/src/Internal/Numeric.hs
@@ -549,6 +549,48 @@ accum
549 -> c e -- ^ result 549 -> c e -- ^ result
550accum = accum' 550accum = accum'
551 551
552--------------------------------------------------------------------------------
553
554class Konst e d c | d -> c, c -> d
555 where
556 -- |
557 -- >>> konst 7 3 :: Vector Float
558 -- fromList [7.0,7.0,7.0]
559 --
560 -- >>> konst i (3::Int,4::Int)
561 -- (3><4)
562 -- [ 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0
563 -- , 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0
564 -- , 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0 ]
565 --
566 konst :: e -> d -> c e
567
568instance Container Vector e => Konst e Int Vector
569 where
570 konst = konst'
571
572instance (Num e, Container Vector e) => Konst e (Int,Int) Matrix
573 where
574 konst = konst'
575
576--------------------------------------------------------------------------------
577
578class ( Container Vector t
579 , Container Matrix t
580 , Konst t Int Vector
581 , Konst t (Int,Int) Matrix
582 , CTrans t
583 , Product t
584 ) => Numeric t
585
586instance Numeric Double
587instance Numeric (Complex Double)
588instance Numeric Float
589instance Numeric (Complex Float)
590instance Numeric I
591instance Numeric Z
592
593--------------------------------------------------------------------------------
552 594
553-------------------------------------------------------------------------------- 595--------------------------------------------------------------------------------
554 596