diff options
Diffstat (limited to 'packages/base/src/Internal/Numeric.hs')
-rw-r--r-- | packages/base/src/Internal/Numeric.hs | 42 |
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 |
550 | accum = accum' | 550 | accum = accum' |
551 | 551 | ||
552 | -------------------------------------------------------------------------------- | ||
553 | |||
554 | class 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 | |||
568 | instance Container Vector e => Konst e Int Vector | ||
569 | where | ||
570 | konst = konst' | ||
571 | |||
572 | instance (Num e, Container Vector e) => Konst e (Int,Int) Matrix | ||
573 | where | ||
574 | konst = konst' | ||
575 | |||
576 | -------------------------------------------------------------------------------- | ||
577 | |||
578 | class ( 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 | |||
586 | instance Numeric Double | ||
587 | instance Numeric (Complex Double) | ||
588 | instance Numeric Float | ||
589 | instance Numeric (Complex Float) | ||
590 | instance Numeric I | ||
591 | instance Numeric Z | ||
592 | |||
593 | -------------------------------------------------------------------------------- | ||
552 | 594 | ||
553 | -------------------------------------------------------------------------------- | 595 | -------------------------------------------------------------------------------- |
554 | 596 | ||