Copyright | (c) Alberto Ruiz 2014 |
---|---|
License | BSD3 |
Stability | experimental |
Safe Haskell | None |
Language | Haskell98 |
Experimental interface with statically checked dimensions.
See code examples at http://dis.um.es/~alberto/hmatrix/static.html.
- 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 r2, KnownNat r1, KnownNat ((+) r1 r2), KnownNat c) => 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
- type ℂ = Complex Double
- 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
- (<.>) :: KnownNat n => 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
- withNullspace :: forall m n z. (KnownNat m, KnownNat n) => L m n -> (forall k. KnownNat k => L n k -> z) -> z
- withOrth :: 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)
- chol :: KnownNat n => Sym n -> Sq n
- class Normed a where
- type Seed = Int
- data RandDist
- randomVector :: forall n. KnownNat n => Seed -> RandDist -> R n
- rand :: forall m n. (KnownNat m, KnownNat n) => IO (L m n)
- randn :: forall m n. (KnownNat m, KnownNat n) => IO (L m n)
- gaussianSample :: forall m n. (KnownNat m, KnownNat n) => Seed -> R n -> Sym n -> L m n
- uniformSample :: forall m n. (KnownNat m, KnownNat n) => Seed -> R n -> R n -> L m n
- mean :: (KnownNat n, 1 <= n) => R n -> ℝ
- meanCov :: forall m n. (KnownNat m, KnownNat n, 1 <= m) => L m n -> (R n, Sym n)
- class Disp t where
- class Domain field vec mat | mat -> vec field, vec -> mat field, field -> mat vec where
- 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
- exactLength :: forall n m. (KnownNat n, KnownNat m) => R m -> Maybe (R n)
- exactDims :: forall n m j k. (KnownNat n, KnownNat m, KnownNat j, KnownNat k) => L m n -> Maybe (L j k)
- 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]
- withRows :: forall n z. KnownNat n => [R n] -> (forall m. KnownNat m => L m n -> z) -> z
- withColumns :: forall m z. KnownNat m => [R m] -> (forall n. KnownNat n => L m n -> z) -> z
- class Num t => Sized t s d | s -> t, s -> d where
- class Diag m d | m -> d where
- 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
- (<·>) :: KnownNat n => R n -> R n -> ℝ
Vector
Domain ℝ R L Source # | |
KnownNat n => Sized ℝ (R n) Vector Source # | |
Floating (R n) Source # | |
Fractional (R n) Source # | |
Num (R n) Source # | |
KnownNat n => Show (R n) Source # | |
Generic (R n) Source # | |
KnownNat n => Binary (R n) Source # | |
NFData (R n) Source # | |
Additive (R n) Source # | |
KnownNat n => Disp (R n) Source # | |
KnownNat n => Eigen (Sym n) (R n) (L n n) Source # | |
KnownNat n => Diag (L n n) (R n) Source # | |
type Rep (R n) Source # | |
Matrix
Domain ℝ R L Source # | |
(KnownNat m, KnownNat n) => Sized ℝ (L m n) Matrix Source # | |
KnownNat n => Eigen (Sym n) (R n) (L n n) Source # | |
KnownNat n => Eigen (Sq n) (C n) (M n n) Source # | |
(KnownNat n, KnownNat m) => Floating (L n m) Source # | |
(KnownNat n, KnownNat m) => Fractional (L n m) Source # | |
(KnownNat n, KnownNat m) => Num (L n m) Source # | |
(KnownNat m, KnownNat n) => Show (L m n) Source # | |
Generic (L m n) Source # | |
(KnownNat n, KnownNat m) => Binary (L m n) Source # | |
NFData (L n m) Source # | |
(KnownNat m, KnownNat n) => Additive (L m n) Source # | |
(KnownNat m, KnownNat n) => Disp (L m n) Source # | |
KnownNat n => Diag (L n n) (R n) Source # | |
(KnownNat n, KnownNat m) => Transposable (L m n) (L n m) Source # | |
type Rep (L m n) Source # | |
(|||) :: (KnownNat r2, KnownNat r1, KnownNat ((+) r1 r2), KnownNat c) => L c r1 -> L c r2 -> L c ((+) r1 r2) infixl 3 Source #
(===) :: (KnownNat r1, KnownNat r2, KnownNat c) => L r1 c -> L r2 c -> L (r1 + r2) c infixl 2 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
blockAt :: forall m n. (KnownNat m, KnownNat n) => ℝ -> Int -> Int -> Matrix Double -> L m n Source #
Complex
Domain ℂ C M Source # | |
KnownNat n => Sized ℂ (C n) Vector Source # | |
Floating (C n) Source # | |
Fractional (C n) Source # | |
Num (C n) Source # | |
KnownNat n => Show (C n) Source # | |
Generic (C n) Source # | |
NFData (C n) Source # | |
Additive (C n) Source # | |
KnownNat n => Disp (C n) Source # | |
KnownNat n => Eigen (Sq n) (C n) (M n n) Source # | |
KnownNat n => Diag (M n n) (C n) Source # | |
type Rep (C n) Source # | |
Domain ℂ C M Source # | |
(KnownNat m, KnownNat n) => Sized ℂ (M m n) Matrix Source # | |
KnownNat n => Eigen (Sq n) (C n) (M n n) Source # | |
(KnownNat n, KnownNat m) => Floating (M n m) Source # | |
(KnownNat n, KnownNat m) => Fractional (M n m) Source # | |
(KnownNat n, KnownNat m) => Num (M n m) Source # | |
(KnownNat m, KnownNat n) => Show (M m n) Source # | |
Generic (M m n) Source # | |
NFData (M n m) Source # | |
(KnownNat m, KnownNat n) => Additive (M m n) Source # | |
(KnownNat m, KnownNat n) => Disp (M m n) Source # | |
KnownNat n => Diag (M n n) (C n) Source # | |
(KnownNat n, KnownNat m) => Transposable (M m n) (M n m) Source # | |
type Rep (M m n) Source # | |
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 #
withOrth :: forall m n z. (KnownNat m, KnownNat n) => L m n -> (forall k. KnownNat k => L n k -> z) -> z Source #
Norms
p-norm for vectors, operator norm for matrices
Normed (Vector Float) Source # | |
Normed (Vector (Complex Float)) Source # | |
Normed (Vector C) Source # | |
Normed (Vector R) Source # | |
Normed (Vector Z) Source # | |
Normed (Vector I) Source # | |
KnownNat m => Normed (Vector (Mod m Z)) Source # | |
KnownNat m => Normed (Vector (Mod m I)) Source # | |
Normed (Matrix C) Source # | |
Normed (Matrix R) Source # | |
Random arrays
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 #
dvmap :: forall n. KnownNat n => (field -> field) -> vec n -> vec n Source #
dmmap :: forall n m. (KnownNat m, KnownNat n) => (field -> field) -> mat n m -> mat n m Source #
outer :: forall n m. (KnownNat m, KnownNat n) => vec n -> vec m -> mat n m Source #
zipWithVector :: forall n. KnownNat n => (field -> field -> field) -> vec n -> vec n -> vec n Source #
det :: forall n. KnownNat n => mat n n -> field Source #
invlndet :: forall n. KnownNat n => mat n n -> (mat n n, (field, field)) Source #
expm :: forall n. KnownNat n => mat n n -> mat n n Source #
sqrtm :: forall n. KnownNat n => mat n n -> mat n n Source #
withMatrix :: forall z. Matrix ℝ -> (forall m n. (KnownNat m, KnownNat n) => L m n -> z) -> z Source #
exactLength :: forall n m. (KnownNat n, KnownNat m) => R m -> Maybe (R n) Source #
Useful for constraining two dependently typed vectors to match each other in length when they are unknown at compile-time.
exactDims :: forall n m j k. (KnownNat n, KnownNat m, KnownNat j, KnownNat k) => L m n -> Maybe (L j k) Source #
Useful for constraining two dependently typed matrices to match each other in dimensions when they are unknown at compile-time.
withColumns :: forall m z. KnownNat m => [R m] -> (forall n. KnownNat n => L m n -> z) -> z Source #
KnownNat n => Floating (Sym n) Source # | |
KnownNat n => Fractional (Sym n) Source # | |
KnownNat n => Num (Sym n) Source # | |
KnownNat n => Show (Sym n) Source # | |
KnownNat n => Additive (Sym n) Source # | |
KnownNat n => Disp (Sym n) Source # | |
KnownNat n => Transposable (Sym n) (Sym n) Source # | |
KnownNat n => Eigen (Sym n) (R n) (L n n) Source # | |