summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/base/THANKS.md2
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Static.hs27
-rw-r--r--stack.yaml1
3 files changed, 24 insertions, 6 deletions
diff --git a/packages/base/THANKS.md b/packages/base/THANKS.md
index 55a428c..34675d3 100644
--- a/packages/base/THANKS.md
+++ b/packages/base/THANKS.md
@@ -207,3 +207,5 @@ module reorganization, monadic mapVectorM, and many other improvements.
207 207
208- Patrik Jansson changed meanCov and gaussianSample to use Herm type. Fixed stack.yaml. 208- Patrik Jansson changed meanCov and gaussianSample to use Herm type. Fixed stack.yaml.
209 209
210- Justin Le added NFData instances for Static types and added mapping and outer product methods to Domain.
211
diff --git a/packages/base/src/Numeric/LinearAlgebra/Static.hs b/packages/base/src/Numeric/LinearAlgebra/Static.hs
index 4de4d7a..bd0e593 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Static.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Static.hs
@@ -50,6 +50,8 @@ module Numeric.LinearAlgebra.Static(
50 -- * Factorizations 50 -- * Factorizations
51 svd, withCompactSVD, svdTall, svdFlat, Eigen(..), 51 svd, withCompactSVD, svdTall, svdFlat, Eigen(..),
52 withNullspace, qr, chol, 52 withNullspace, qr, chol,
53 -- * Norms
54 Normed(..),
53 -- * Misc 55 -- * Misc
54 mean, 56 mean,
55 Disp(..), Domain(..), 57 Disp(..), Domain(..),
@@ -418,7 +420,7 @@ class Domain field vec mat | mat -> vec field, vec -> mat field, field -> mat ve
418 diagR :: forall m n k . (KnownNat m, KnownNat n, KnownNat k) => field -> vec k -> mat m n 420 diagR :: forall m n k . (KnownNat m, KnownNat n, KnownNat k) => field -> vec k -> mat m n
419 dvmap :: forall n. (field -> field) -> vec n -> vec n 421 dvmap :: forall n. (field -> field) -> vec n -> vec n
420 dmmap :: forall n m. (field -> field) -> mat n m -> mat n m 422 dmmap :: forall n m. (field -> field) -> mat n m -> mat n m
421 outer :: forall n m. vec n -> vec m -> mat n m 423 outer :: forall n m. (KnownNat m, KnownNat n) => vec n -> vec m -> mat n m
422 424
423 425
424instance Domain ℝ R L 426instance Domain ℝ R L
@@ -481,8 +483,8 @@ crossR (extract -> x) (extract -> y) = vec3 z1 z2 z3
481 z2 = x!2*y!0-x!0*y!2 483 z2 = x!2*y!0-x!0*y!2
482 z3 = x!0*y!1-x!1*y!0 484 z3 = x!0*y!1-x!1*y!0
483 485
484outerR :: R n -> R m -> L n m 486outerR :: (KnownNat m, KnownNat n) => R n -> R m -> L n m
485outerR (R (Dim x)) (R (Dim y)) = mkL (LA.outer x y) 487outerR (extract -> x) (extract -> y) = mkL (LA.outer x y)
486 488
487mapR :: (ℝ -> ℝ) -> R n -> R n 489mapR :: (ℝ -> ℝ) -> R n -> R n
488mapR f (R (Dim v)) = R (Dim (LA.cmap f v)) 490mapR f (R (Dim v)) = R (Dim (LA.cmap f v))
@@ -528,8 +530,8 @@ crossC (extract -> x) (extract -> y) = mkC (LA.fromList [z1, z2, z3])
528 z2 = x!2*y!0-x!0*y!2 530 z2 = x!2*y!0-x!0*y!2
529 z3 = x!0*y!1-x!1*y!0 531 z3 = x!0*y!1-x!1*y!0
530 532
531outerC :: C n -> C m -> M n m 533outerC :: (KnownNat m, KnownNat n) => C n -> C m -> M n m
532outerC (C (Dim x)) (C (Dim y)) = mkM (LA.outer x y) 534outerC (extract -> x) (extract -> y) = mkM (LA.outer x y)
533 535
534mapC :: (ℂ -> ℂ) -> C n -> C n 536mapC :: (ℂ -> ℂ) -> C n -> C n
535mapC f (C (Dim v)) = C (Dim (LA.cmap f v)) 537mapC f (C (Dim v)) = C (Dim (LA.cmap f v))
@@ -643,3 +645,18 @@ instance (KnownNat n', KnownNat m') => Testable (L n' m')
643 where 645 where
644 checkT _ = test 646 checkT _ = test
645 647
648--------------------------------------------------------------------------------
649
650instance KnownNat n => Normed (R n)
651 where
652 norm_0 v = norm_0 (extract v)
653 norm_1 v = norm_1 (extract v)
654 norm_2 v = norm_2 (extract v)
655 norm_Inf v = norm_Inf (extract v)
656
657instance (KnownNat m, KnownNat n) => Normed (L m n)
658 where
659 norm_0 m = norm_0 (extract m)
660 norm_1 m = norm_1 (extract m)
661 norm_2 m = norm_2 (extract m)
662 norm_Inf m = norm_Inf (extract m)
diff --git a/stack.yaml b/stack.yaml
index c9cb363..ee89f64 100644
--- a/stack.yaml
+++ b/stack.yaml
@@ -10,7 +10,6 @@ flags:
10packages: 10packages:
11- packages/tests/ 11- packages/tests/
12- packages/special/ 12- packages/special/
13- packages/sparse/
14- packages/gsl/ 13- packages/gsl/
15- packages/glpk/ 14- packages/glpk/
16- packages/base/ 15- packages/base/