Copyright | (c) Alberto Ruiz 2014 |
---|---|
License | BSD3 |
Stability | experimental |
Safe Haskell | None |
Language | Haskell98 |
Experimental interface with statically checked dimensions.
This module is under active development and the interface is subject to changes.
- type ℝ = Double
- data R n
- vec2 :: ℝ -> ℝ -> R 2
- vec3 :: ℝ -> ℝ -> ℝ -> R 3
- vec4 :: ℝ -> ℝ -> ℝ -> ℝ -> R 4
- (&) :: forall n. (KnownNat n, 1 <= n) => R n -> ℝ -> R (n + 1)
- (#) :: forall n m. (KnownNat n, KnownNat m) => R n -> R m -> R (n + m)
- split :: forall p n. (KnownNat p, KnownNat n, p <= n) => R n -> (R p, R (n - p))
- headTail :: (KnownNat n, 1 <= n) => R n -> (ℝ, R (n - 1))
- vector :: KnownNat n => [ℝ] -> R n
- linspace :: forall n. KnownNat n => (ℝ, ℝ) -> R n
- range :: forall n. KnownNat n => R n
- dim :: forall n. KnownNat n => R n
- data L m n
- type Sq n = L n n
- build :: forall m n. (KnownNat n, KnownNat m) => (ℝ -> ℝ -> ℝ) -> L m n
- row :: R n -> L 1 n
- col :: KnownNat n => R n -> L n 1
- (¦) :: (KnownNat ((+) r1 r2), KnownNat r2, KnownNat c, KnownNat r1) => L c r1 -> L c r2 -> L c ((+) r1 r2)
- —— :: (KnownNat r1, KnownNat r2, KnownNat c) => L r1 c -> L r2 c -> L (r1 + r2) c
- splitRows :: forall p m n. (KnownNat p, KnownNat m, KnownNat n, p <= m) => L m n -> (L p n, L (m - p) n)
- splitCols :: forall p m n. (KnownNat p, KnownNat m, KnownNat n, KnownNat (n - p), p <= n) => L m n -> (L m p, L m (n - p))
- unrow :: L 1 n -> R n
- uncol :: KnownNat n => L n 1 -> R n
- tr :: Transposable m mt => m -> mt
- eye :: KnownNat n => Sq n
- diag :: KnownNat n => R n -> Sq n
- blockAt :: forall m n. (KnownNat m, KnownNat n) => ℝ -> Int -> Int -> Matrix Double -> L m n
- matrix :: (KnownNat m, KnownNat n) => [ℝ] -> L m n
- data C n
- data M m n
- data Her n
- her :: KnownNat n => M n n -> Her n
- 𝑖 :: Sized ℂ s c => s
- (<>) :: forall m k n. (KnownNat m, KnownNat k, KnownNat n) => L m k -> L k n -> L m n
- (#>) :: (KnownNat m, KnownNat n) => L m n -> R n -> R m
- <·> :: R n -> R n -> ℝ
- linSolve :: (KnownNat m, KnownNat n) => L m m -> L m n -> Maybe (L m n)
- (<\>) :: (KnownNat m, KnownNat n, KnownNat r) => L m n -> L m r -> L n r
- svd :: (KnownNat m, KnownNat n) => L m n -> (L m m, R n, L n n)
- withCompactSVD :: forall m n z. (KnownNat m, KnownNat n) => L m n -> (forall k. KnownNat k => (L m k, R k, L n k) -> z) -> z
- svdTall :: (KnownNat m, KnownNat n, n <= m) => L m n -> (L m n, R n, L n n)
- svdFlat :: (KnownNat m, KnownNat n, m <= n) => L m n -> (L m m, R m, L n m)
- class Eigen m l v | m -> l, m -> v where
- eigensystem :: m -> (l, v)
- eigenvalues :: m -> l
- withNullspace :: forall m n z. (KnownNat m, KnownNat n) => L m n -> (forall k. KnownNat k => L n k -> z) -> z
- qr :: (KnownNat m, KnownNat n) => L m n -> (L m m, L m n)
- mean :: (KnownNat n, 1 <= n) => R n -> ℝ
- class Disp t where
- class Domain field vec mat | mat -> vec field, vec -> mat field, field -> mat vec where
- mul :: forall m k n. (KnownNat m, KnownNat k, KnownNat n) => mat m k -> mat k n -> mat m n
- app :: forall m n. (KnownNat m, KnownNat n) => mat m n -> vec n -> vec m
- dot :: forall n. KnownNat n => vec n -> vec n -> field
- cross :: vec 3 -> vec 3 -> vec 3
- diagR :: forall m n k. (KnownNat m, KnownNat n, KnownNat k) => field -> vec k -> mat m n
- withVector :: forall z. Vector ℝ -> (forall n. KnownNat n => R n -> z) -> z
- withMatrix :: forall z. Matrix ℝ -> (forall m n. (KnownNat m, KnownNat n) => L m n -> z) -> z
- toRows :: forall m n. (KnownNat m, KnownNat n) => L m n -> [R n]
- toColumns :: forall m n. (KnownNat m, KnownNat n) => L m n -> [R m]
- class Num t => Sized t s d | s -> t, s -> d where
- class Diag m d | m -> d where
- takeDiag :: m -> d
- data Sym n
- sym :: KnownNat n => Sq n -> Sym n
- mTm :: (KnownNat m, KnownNat n) => L m n -> Sym n
- unSym :: Sym n -> Sq n
Vector
Domain ℝ R L | |
KnownNat n => Sized ℝ (R n) Vector | |
Floating (R n) | |
Fractional (R n) | |
Num (R n) | |
KnownNat n => Show (R n) | |
KnownNat n => Disp (R n) | |
KnownNat n => Eigen (Sym n) (R n) (L n n) | |
(KnownNat m, KnownNat n, (<=) n ((+) m 1)) => Diag (L m n) (R n) | |
(KnownNat m, KnownNat n, (<=) m ((+) n 1)) => Diag (L m n) (R m) | |
KnownNat n => Diag (L n n) (R n) |
Matrix
Domain ℝ R L | |
(KnownNat m, KnownNat n) => Sized ℝ (L m n) Matrix | |
KnownNat n => Eigen (Sym n) (R n) (L n n) | |
KnownNat n => Eigen (Sq n) (C n) (M n n) | |
(KnownNat n, KnownNat m) => Floating (L n m) | |
(KnownNat n, KnownNat m) => Fractional (L n m) | |
(KnownNat n, KnownNat m) => Num (L n m) | |
(KnownNat m, KnownNat n) => Show (L m n) | |
(KnownNat n', KnownNat m') => Testable (L n' m') | |
(KnownNat m, KnownNat n) => Disp (L m n) | |
(KnownNat m, KnownNat n, (<=) n ((+) m 1)) => Diag (L m n) (R n) | |
(KnownNat m, KnownNat n, (<=) m ((+) n 1)) => Diag (L m n) (R m) | |
KnownNat n => Diag (L n n) (R n) | |
(KnownNat n, KnownNat m) => Transposable (L m n) (L n m) |
(¦) :: (KnownNat ((+) r1 r2), KnownNat r2, KnownNat c, KnownNat r1) => L c r1 -> L c r2 -> L c ((+) r1 r2) infixl 3 Source
splitRows :: forall p m n. (KnownNat p, KnownNat m, KnownNat n, p <= m) => L m n -> (L p n, L (m - p) n) Source
splitCols :: forall p m n. (KnownNat p, KnownNat m, KnownNat n, KnownNat (n - p), p <= n) => L m n -> (L m p, L m (n - p)) Source
tr :: Transposable m mt => m -> mt Source
(conjugate) transpose
Complex
Domain ℂ C M | |
(KnownNat m, KnownNat n) => Sized ℂ (M m n) Matrix | |
KnownNat n => Eigen (Sq n) (C n) (M n n) | |
(KnownNat n, KnownNat m) => Floating (M n m) | |
(KnownNat n, KnownNat m) => Fractional (M n m) | |
(KnownNat n, KnownNat m) => Num (M n m) | |
(KnownNat m, KnownNat n) => Show (M m n) | |
(KnownNat m, KnownNat n) => Disp (M m n) | |
(KnownNat n, KnownNat m) => Transposable (M m n) (M n m) |
Products
(<>) :: forall m k n. (KnownNat m, KnownNat k, KnownNat n) => L m k -> L k n -> L m n infixr 8 Source
Linear Systems
Factorizations
withCompactSVD :: forall m n z. (KnownNat m, KnownNat n) => L m n -> (forall k. KnownNat k => (L m k, R k, L n k) -> z) -> z Source
class Eigen m l v | m -> l, m -> v where Source
eigensystem :: m -> (l, v) Source
eigenvalues :: m -> l Source
withNullspace :: forall m n z. (KnownNat m, KnownNat n) => L m n -> (forall k. KnownNat k => L n k -> z) -> z Source
Misc
class Domain field vec mat | mat -> vec field, vec -> mat field, field -> mat vec where Source
mul :: forall m k n. (KnownNat m, KnownNat k, KnownNat n) => mat m k -> mat k n -> mat m n Source
app :: forall m n. (KnownNat m, KnownNat n) => mat m n -> vec n -> vec m Source
dot :: forall n. KnownNat n => vec n -> vec n -> field Source
cross :: vec 3 -> vec 3 -> vec 3 Source
diagR :: forall m n k. (KnownNat m, KnownNat n, KnownNat k) => field -> vec k -> mat m n Source
withMatrix :: forall z. Matrix ℝ -> (forall m n. (KnownNat m, KnownNat n) => L m n -> z) -> z Source