hmatrix-0.18.0.0: Numeric Linear Algebra

Copyright(c) Alberto Ruiz 2014
LicenseBSD3
Stabilityexperimental
Safe HaskellNone
LanguageHaskell98

Numeric.LinearAlgebra.Static

Contents

Description

Experimental interface with statically checked dimensions.

See code examples at http://dis.um.es/~alberto/hmatrix/static.html.

Synopsis

Vector

data R n Source

Instances

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 

vec2 :: -> -> R 2 Source

vec3 :: -> -> -> R 3 Source

vec4 :: -> -> -> -> R 4 Source

(&) :: forall n. (KnownNat n, 1 <= n) => R n -> -> R (n + 1) infixl 4 Source

(#) :: forall n m. (KnownNat n, KnownNat m) => R n -> R m -> R (n + m) infixl 4 Source

split :: forall p n. (KnownNat p, KnownNat n, p <= n) => R n -> (R p, R (n - p)) Source

headTail :: (KnownNat n, 1 <= n) => R n -> (, R (n - 1)) Source

vector :: KnownNat n => [] -> R n Source

linspace :: forall n. KnownNat n => (, ) -> R n Source

range :: forall n. KnownNat n => R n Source

dim :: forall n. KnownNat n => R n Source

Matrix

data L m n Source

Instances

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 m, KnownNat n) => 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 

type Sq n = L n n Source

build :: forall m n. (KnownNat n, KnownNat m) => ( -> -> ) -> L m n Source

row :: R n -> L 1 n Source

col :: KnownNat n => R n -> L n 1 Source

(|||) :: (KnownNat r1, KnownNat c, KnownNat r2, KnownNat ((+) r1 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

unrow :: L 1 n -> R n Source

uncol :: KnownNat n => L n 1 -> R n Source

tr :: Transposable m mt => m -> mt Source

conjugate transpose

eye :: KnownNat n => Sq n Source

diag :: KnownNat n => R n -> Sq n Source

blockAt :: forall m n. (KnownNat m, KnownNat n) => -> Int -> Int -> Matrix Double -> L m n Source

matrix :: (KnownNat m, KnownNat n) => [] -> L m n Source

Complex

data C n Source

Instances

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 

data M m n Source

Instances

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 

data Her n Source

Instances

her :: KnownNat n => M n n -> Her n Source

𝑖 :: Sized s c => s Source

Products

(<>) :: forall m k n. (KnownNat m, KnownNat k, KnownNat n) => L m k -> L k n -> L m n infixr 8 Source

(#>) :: (KnownNat m, KnownNat n) => L m n -> R n -> R m infixr 8 Source

(<.>) :: R n -> R n -> infixr 8 Source

Linear Systems

linSolve :: (KnownNat m, KnownNat n) => L m m -> L m n -> Maybe (L m n) Source

(<\>) :: (KnownNat m, KnownNat n, KnownNat r) => L m n -> L m r -> L n r Source

Factorizations

svd :: (KnownNat m, KnownNat n) => L m n -> (L m m, R n, L n n) Source

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

svdTall :: (KnownNat m, KnownNat n, n <= m) => L m n -> (L m n, R n, L n n) Source

svdFlat :: (KnownNat m, KnownNat n, m <= n) => L m n -> (L m m, R m, L n m) Source

class Eigen m l v | m -> l, m -> v where Source

Methods

eigensystem :: m -> (l, v) Source

eigenvalues :: m -> l Source

Instances

KnownNat n => Eigen (Sym n) (R n) (L n n) Source 
KnownNat n => Eigen (Sq n) (C n) (M n n) 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

qr :: (KnownNat m, KnownNat n) => L m n -> (L m m, L m n) Source

chol :: KnownNat n => Sym n -> Sq n Source

Norms

Random arrays

type Seed = Int Source

data RandDist Source

Constructors

Uniform

uniform distribution in [0,1)

Gaussian

normal distribution with mean zero and standard deviation one

Instances

randomVector :: forall n. KnownNat n => Seed -> RandDist -> R n Source

rand :: forall m n. (KnownNat m, KnownNat n) => IO (L m n) Source

randn :: forall m n. (KnownNat m, KnownNat n) => IO (L m n) Source

gaussianSample :: forall m n. (KnownNat m, KnownNat n) => Seed -> R n -> Sym n -> L m n Source

uniformSample Source

Arguments

:: (KnownNat m, KnownNat n) 
=> Seed 
-> R n

minimums of each row

-> R n

maximums of each row

-> L m n 

Misc

mean :: (KnownNat n, 1 <= n) => R n -> Source

meanCov :: forall m n. (KnownNat m, KnownNat n, 1 <= m) => L m n -> (R n, Sym n) Source

class Disp t where Source

Methods

disp :: Int -> t -> IO () Source

Instances

KnownNat n => Disp (C n) Source 
KnownNat n => Disp (R n) Source 
KnownNat n => Disp (Her n) Source 
KnownNat n => Disp (Sym n) Source 
(KnownNat m, KnownNat n) => Disp (M m n) Source 
(KnownNat m, KnownNat n) => Disp (L m n) Source 

class Domain field vec mat | mat -> vec field, vec -> mat field, field -> mat vec where Source

Methods

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

inv :: forall n. KnownNat n => mat n n -> mat n n Source

withVector :: forall z. Vector -> (forall n. KnownNat n => R n -> z) -> z 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.

toRows :: forall m n. (KnownNat m, KnownNat n) => L m n -> [R n] Source

toColumns :: forall m n. (KnownNat m, KnownNat n) => L m n -> [R m] Source

withRows :: forall n z. KnownNat n => [R n] -> (forall m. KnownNat m => L m n -> z) -> z Source

withColumns :: forall m z. KnownNat m => [R m] -> (forall n. KnownNat n => L m n -> z) -> z Source

class Num t => Sized t s d | s -> t, s -> d where Source

Methods

konst :: t -> s Source

unwrap :: s -> d t Source

fromList :: [t] -> s Source

extract :: s -> d t Source

create :: d t -> Maybe s Source

size :: s -> IndexOf d Source

Instances

class Diag m d | m -> d where Source

Methods

takeDiag :: m -> d Source

Instances

KnownNat n => Diag (M n n) (C n) Source 
KnownNat n => Diag (L n n) (R n) Source 

data Sym n Source

Instances

sym :: KnownNat n => Sq n -> Sym n Source

mTm :: (KnownNat m, KnownNat n) => L m n -> Sym n Source

unSym :: Sym n -> Sq n Source

<·> :: R n -> R n -> infixr 8 Source