summaryrefslogtreecommitdiff
path: root/packages/base/src/Numeric
diff options
context:
space:
mode:
Diffstat (limited to 'packages/base/src/Numeric')
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Static.hs24
1 files changed, 22 insertions, 2 deletions
diff --git a/packages/base/src/Numeric/LinearAlgebra/Static.hs b/packages/base/src/Numeric/LinearAlgebra/Static.hs
index 43a21a3..86c13d7 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Static.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Static.hs
@@ -58,8 +58,8 @@ module Numeric.LinearAlgebra.Static(
58 -- * Misc 58 -- * Misc
59 mean, meanCov, 59 mean, meanCov,
60 Disp(..), Domain(..), 60 Disp(..), Domain(..),
61 withVector, exactLength, withMatrix, exactDims, 61 withVector, withMatrix, exactLength, exactDims,
62 toRows, toColumns, 62 toRows, toColumns, withRows, withColumns,
63 Sized(..), Diag(..), Sym, sym, mTm, unSym, (<·>) 63 Sized(..), Diag(..), Sym, sym, mTm, unSym, (<·>)
64) where 64) where
65 65
@@ -381,10 +381,30 @@ splitCols = (tr *** tr) . splitRows . tr
381toRows :: forall m n . (KnownNat m, KnownNat n) => L m n -> [R n] 381toRows :: forall m n . (KnownNat m, KnownNat n) => L m n -> [R n]
382toRows (LA.toRows . extract -> vs) = map mkR vs 382toRows (LA.toRows . extract -> vs) = map mkR vs
383 383
384withRows
385 :: forall n z . KnownNat n
386 => [R n]
387 -> (forall m . KnownNat m => L m n -> z)
388 -> z
389withRows (LA.fromRows . map extract -> m) f =
390 case someNatVal $ fromIntegral $ LA.rows m of
391 Nothing -> error "static/dynamic mismatch"
392 Just (SomeNat (_ :: Proxy m)) -> f (mkL m :: L m n)
384 393
385toColumns :: forall m n . (KnownNat m, KnownNat n) => L m n -> [R m] 394toColumns :: forall m n . (KnownNat m, KnownNat n) => L m n -> [R m]
386toColumns (LA.toColumns . extract -> vs) = map mkR vs 395toColumns (LA.toColumns . extract -> vs) = map mkR vs
387 396
397withColumns
398 :: forall m z . KnownNat m
399 => [R m]
400 -> (forall n . KnownNat n => L m n -> z)
401 -> z
402withColumns (LA.fromColumns . map extract -> m) f =
403 case someNatVal $ fromIntegral $ LA.cols m of
404 Nothing -> error "static/dynamic mismatch"
405 Just (SomeNat (_ :: Proxy n)) -> f (mkL m :: L m n)
406
407
388 408
389-------------------------------------------------------------------------------- 409--------------------------------------------------------------------------------
390 410