diff options
Diffstat (limited to 'packages')
-rw-r--r-- | packages/base/src/Numeric/LinearAlgebra/Static.hs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/packages/base/src/Numeric/LinearAlgebra/Static.hs b/packages/base/src/Numeric/LinearAlgebra/Static.hs index fafbf81..8175ff5 100644 --- a/packages/base/src/Numeric/LinearAlgebra/Static.hs +++ b/packages/base/src/Numeric/LinearAlgebra/Static.hs | |||
@@ -79,7 +79,7 @@ import Internal.Static | |||
79 | import Control.Arrow((***)) | 79 | import Control.Arrow((***)) |
80 | import Text.Printf | 80 | import Text.Printf |
81 | import Data.Type.Equality ((:~:)(Refl)) | 81 | import Data.Type.Equality ((:~:)(Refl)) |
82 | import Data.Bifunctor (first) | 82 | import qualified Data.Bifunctor as BF (first) |
83 | 83 | ||
84 | ud1 :: R n -> Vector ℝ | 84 | ud1 :: R n -> Vector ℝ |
85 | ud1 (R (Dim v)) = v | 85 | ud1 (R (Dim v)) = v |
@@ -539,6 +539,7 @@ class Domain field vec mat | mat -> vec field, vec -> mat field, field -> mat ve | |||
539 | invlndet :: forall n. KnownNat n => mat n n -> (mat n n, (field, field)) | 539 | invlndet :: forall n. KnownNat n => mat n n -> (mat n n, (field, field)) |
540 | expm :: forall n. KnownNat n => mat n n -> mat n n | 540 | expm :: forall n. KnownNat n => mat n n -> mat n n |
541 | sqrtm :: forall n. KnownNat n => mat n n -> mat n n | 541 | sqrtm :: forall n. KnownNat n => mat n n -> mat n n |
542 | inv :: forall n. KnownNat n => mat n n -> mat n n | ||
542 | 543 | ||
543 | 544 | ||
544 | instance Domain ℝ R L | 545 | instance Domain ℝ R L |
@@ -556,6 +557,7 @@ instance Domain ℝ R L | |||
556 | invlndet = invlndetL | 557 | invlndet = invlndetL |
557 | expm = expmL | 558 | expm = expmL |
558 | sqrtm = sqrtmL | 559 | sqrtm = sqrtmL |
560 | inv = invL | ||
559 | 561 | ||
560 | instance Domain ℂ C M | 562 | instance Domain ℂ C M |
561 | where | 563 | where |
@@ -572,6 +574,7 @@ instance Domain ℂ C M | |||
572 | invlndet = invlndetM | 574 | invlndet = invlndetM |
573 | expm = expmM | 575 | expm = expmM |
574 | sqrtm = sqrtmM | 576 | sqrtm = sqrtmM |
577 | inv = invM | ||
575 | 578 | ||
576 | -------------------------------------------------------------------------------- | 579 | -------------------------------------------------------------------------------- |
577 | 580 | ||
@@ -627,7 +630,7 @@ detL :: KnownNat n => Sq n -> ℝ | |||
627 | detL = LA.det . unwrap | 630 | detL = LA.det . unwrap |
628 | 631 | ||
629 | invlndetL :: KnownNat n => Sq n -> (L n n, (ℝ, ℝ)) | 632 | invlndetL :: KnownNat n => Sq n -> (L n n, (ℝ, ℝ)) |
630 | invlndetL = first mkL . LA.invlndet . unwrap | 633 | invlndetL = BF.first mkL . LA.invlndet . unwrap |
631 | 634 | ||
632 | expmL :: KnownNat n => Sq n -> Sq n | 635 | expmL :: KnownNat n => Sq n -> Sq n |
633 | expmL = overMatL' LA.expm | 636 | expmL = overMatL' LA.expm |
@@ -635,6 +638,9 @@ expmL = overMatL' LA.expm | |||
635 | sqrtmL :: KnownNat n => Sq n -> Sq n | 638 | sqrtmL :: KnownNat n => Sq n -> Sq n |
636 | sqrtmL = overMatL' LA.sqrtm | 639 | sqrtmL = overMatL' LA.sqrtm |
637 | 640 | ||
641 | invL :: KnownNat n => Sq n -> Sq n | ||
642 | invL = overMatL' LA.inv | ||
643 | |||
638 | -------------------------------------------------------------------------------- | 644 | -------------------------------------------------------------------------------- |
639 | 645 | ||
640 | mulC :: forall m k n. (KnownNat m, KnownNat k, KnownNat n) => M m k -> M k n -> M m n | 646 | mulC :: forall m k n. (KnownNat m, KnownNat k, KnownNat n) => M m k -> M k n -> M m n |
@@ -689,7 +695,7 @@ detM :: KnownNat n => M n n -> ℂ | |||
689 | detM = LA.det . unwrap | 695 | detM = LA.det . unwrap |
690 | 696 | ||
691 | invlndetM :: KnownNat n => M n n -> (M n n, (ℂ, ℂ)) | 697 | invlndetM :: KnownNat n => M n n -> (M n n, (ℂ, ℂ)) |
692 | invlndetM = first mkM . LA.invlndet . unwrap | 698 | invlndetM = BF.first mkM . LA.invlndet . unwrap |
693 | 699 | ||
694 | expmM :: KnownNat n => M n n -> M n n | 700 | expmM :: KnownNat n => M n n -> M n n |
695 | expmM = overMatM' LA.expm | 701 | expmM = overMatM' LA.expm |
@@ -697,6 +703,8 @@ expmM = overMatM' LA.expm | |||
697 | sqrtmM :: KnownNat n => M n n -> M n n | 703 | sqrtmM :: KnownNat n => M n n -> M n n |
698 | sqrtmM = overMatM' LA.sqrtm | 704 | sqrtmM = overMatM' LA.sqrtm |
699 | 705 | ||
706 | invM :: KnownNat n => M n n -> M n n | ||
707 | invM = overMatM' LA.inv | ||
700 | 708 | ||
701 | -------------------------------------------------------------------------------- | 709 | -------------------------------------------------------------------------------- |
702 | 710 | ||