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.
Synopsis
- type ℝ = Double
- data R n
- vec2 :: ℝ -> ℝ -> R 2
- vec3 :: ℝ -> ℝ -> ℝ -> R 3
- vec4 :: ℝ -> ℝ -> ℝ -> ℝ -> R 4
- (&) :: forall n. KnownNat 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 c, KnownNat (r1 + r2), KnownNat r1, KnownNat r2) => 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
- 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
- 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
- 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
- dvmap :: forall n. KnownNat n => (field -> field) -> vec n -> vec n
- dmmap :: forall n m. (KnownNat m, KnownNat n) => (field -> field) -> mat n m -> mat n m
- outer :: forall n m. (KnownNat m, KnownNat n) => vec n -> vec m -> mat n m
- zipWithVector :: forall n. KnownNat n => (field -> field -> field) -> vec n -> vec n -> vec n
- det :: forall n. KnownNat n => mat n n -> field
- invlndet :: forall n. KnownNat n => mat n n -> (mat n n, (field, field))
- expm :: forall n. KnownNat n => mat n n -> mat n n
- sqrtm :: forall n. KnownNat n => mat n n -> mat n n
- inv :: forall n. KnownNat n => mat n n -> mat n 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
- 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
- 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
- (<·>) :: KnownNat n => R n -> R n -> ℝ
Vector
Instances
Matrix
Instances
(|||) :: (KnownNat c, KnownNat (r1 + r2), KnownNat r1, KnownNat r2) => 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
Instances
Instances
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
Instances
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 # | |
KnownNat n => Normed (R n) Source # | |
(KnownNat m, KnownNat n) => Normed (L m n) Source # | |
Random arrays
Uniform | uniform distribution in [0,1) |
Gaussian | normal distribution with mean zero and standard deviation one |
Instances
Enum RandDist 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 #
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 #
Instances
Domain ℂ C M Source # | |
Defined in Numeric.LinearAlgebra.Static mul :: (KnownNat m, KnownNat k, KnownNat n) => M m k -> M k n -> M m n Source # app :: (KnownNat m, KnownNat n) => M m n -> C n -> C m Source # dot :: KnownNat n => C n -> C n -> ℂ Source # cross :: C 3 -> C 3 -> C 3 Source # diagR :: (KnownNat m, KnownNat n, KnownNat k) => ℂ -> C k -> M m n Source # dvmap :: KnownNat n => (ℂ -> ℂ) -> C n -> C n Source # dmmap :: (KnownNat m, KnownNat n) => (ℂ -> ℂ) -> M n m -> M n m Source # outer :: (KnownNat m, KnownNat n) => C n -> C m -> M n m Source # zipWithVector :: KnownNat n => (ℂ -> ℂ -> ℂ) -> C n -> C n -> C n Source # det :: KnownNat n => M n n -> ℂ Source # invlndet :: KnownNat n => M n n -> (M n n, (ℂ, ℂ)) Source # expm :: KnownNat n => M n n -> M n n Source # | |
Domain ℝ R L Source # | |
Defined in Numeric.LinearAlgebra.Static mul :: (KnownNat m, KnownNat k, KnownNat n) => L m k -> L k n -> L m n Source # app :: (KnownNat m, KnownNat n) => L m n -> R n -> R m Source # dot :: KnownNat n => R n -> R n -> ℝ Source # cross :: R 3 -> R 3 -> R 3 Source # diagR :: (KnownNat m, KnownNat n, KnownNat k) => ℝ -> R k -> L m n Source # dvmap :: KnownNat n => (ℝ -> ℝ) -> R n -> R n Source # dmmap :: (KnownNat m, KnownNat n) => (ℝ -> ℝ) -> L n m -> L n m Source # outer :: (KnownNat m, KnownNat n) => R n -> R m -> L n m Source # zipWithVector :: KnownNat n => (ℝ -> ℝ -> ℝ) -> R n -> R n -> R n Source # det :: KnownNat n => L n n -> ℝ Source # invlndet :: KnownNat n => L n n -> (L n n, (ℝ, ℝ)) Source # expm :: KnownNat n => L n n -> L 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 #
Instances
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 # | |
Defined in Numeric.LinearAlgebra.Static |