Safe Haskell | None |
---|---|
Language | Haskell98 |
Synopsis
- type Triangular lo diag up sh = Array (Triangular lo diag up sh)
- type UpLo lo up = (UpLoC lo up, UpLoC up lo)
- type Diagonal sh = FlexDiagonal NonUnit sh
- type Upper sh = FlexUpper NonUnit sh
- type FlexUpper diag sh = Array (UpperTriangular diag sh)
- type UnitUpper sh = FlexUpper Unit sh
- type Lower sh = FlexLower NonUnit sh
- type FlexLower diag sh = Array (LowerTriangular diag sh)
- type UnitLower sh = FlexLower Unit sh
- type Symmetric sh = Array (Symmetric sh)
- type FlexSymmetric diag sh = Array (FlexSymmetric diag sh)
- fromList :: (Content lo, Content up, C sh, Storable a) => Order -> sh -> [a] -> Triangular lo NonUnit up sh a
- autoFromList :: (Content lo, Content up, Storable a) => Order -> [a] -> Triangular lo NonUnit up ZeroInt a
- lowerFromList :: (C sh, Storable a) => Order -> sh -> [a] -> Lower sh a
- autoLowerFromList :: Storable a => Order -> [a] -> Lower ZeroInt a
- upperFromList :: (C sh, Storable a) => Order -> sh -> [a] -> Upper sh a
- autoUpperFromList :: Storable a => Order -> [a] -> Upper ZeroInt a
- symmetricFromList :: (C sh, Storable a) => Order -> sh -> [a] -> Symmetric sh a
- autoSymmetricFromList :: Storable a => Order -> [a] -> Symmetric ZeroInt a
- diagonalFromList :: (C sh, Storable a) => Order -> sh -> [a] -> Diagonal sh a
- autoDiagonalFromList :: Storable a => Order -> [a] -> Diagonal ZeroInt a
- relaxUnitDiagonal :: TriDiag diag => Triangular lo Unit up sh a -> Triangular lo diag up sh a
- strictNonUnitDiagonal :: TriDiag diag => Triangular lo diag up sh a -> Triangular lo NonUnit up sh a
- asDiagonal :: FlexDiagonal diag sh a -> FlexDiagonal diag sh a
- asLower :: FlexLower diag sh a -> FlexLower diag sh a
- asUpper :: FlexUpper diag sh a -> FlexUpper diag sh a
- asSymmetric :: FlexSymmetric diag sh a -> FlexSymmetric diag sh a
- forceUnitDiagonal :: Triangular lo Unit up sh a -> Triangular lo Unit up sh a
- forceNonUnitDiagonal :: Triangular lo NonUnit up sh a -> Triangular lo NonUnit up sh a
- identity :: (Content lo, Content up, C sh, Floating a) => Order -> sh -> Triangular lo Unit up sh a
- diagonal :: (Content lo, Content up, C sh, Floating a) => Order -> Vector sh a -> Triangular lo NonUnit up sh a
- takeDiagonal :: (Content lo, Content up, C sh, Floating a) => Triangular lo diag up sh a -> Vector sh a
- transpose :: (Content lo, Content up, TriDiag diag) => Triangular lo diag up sh a -> Triangular up diag lo sh a
- adjoint :: (Content lo, Content up, TriDiag diag, C sh, Floating a) => Triangular lo diag up sh a -> Triangular up diag lo sh a
- stackLower :: (TriDiag diag, C sh0, Eq sh0, C sh1, Eq sh1, Floating a) => FlexLower diag sh0 a -> General sh1 sh0 a -> FlexLower diag sh1 a -> FlexLower diag (sh0 :+: sh1) a
- stackUpper :: (TriDiag diag, C sh0, Eq sh0, C sh1, Eq sh1, Floating a) => FlexUpper diag sh0 a -> General sh0 sh1 a -> FlexUpper diag sh1 a -> FlexUpper diag (sh0 :+: sh1) a
- stackSymmetric :: (TriDiag diag, C sh0, Eq sh0, C sh1, Eq sh1, Floating a) => FlexSymmetric diag sh0 a -> General sh0 sh1 a -> FlexSymmetric diag sh1 a -> FlexSymmetric diag (sh0 :+: sh1) a
- toSquare :: (Content lo, Content up, C sh, Floating a) => Triangular lo diag up sh a -> Square sh a
- takeLower :: (C horiz, C height, C width, Floating a) => Full Small horiz height width a -> Lower height a
- takeUpper :: (C vert, C height, C width, Floating a) => Full vert Small height width a -> Upper width a
- fromLowerRowMajor :: (C sh, Floating a) => Array (Triangular Lower sh) a -> Lower sh a
- toLowerRowMajor :: (C sh, Floating a) => Lower sh a -> Array (Triangular Lower sh) a
- fromUpperRowMajor :: (C sh, Floating a) => Array (Triangular Upper sh) a -> Upper sh a
- toUpperRowMajor :: (C sh, Floating a) => Upper sh a -> Array (Triangular Upper sh) a
- forceOrder :: (Content lo, Content up, TriDiag diag, C sh, Floating a) => Order -> Triangular lo diag up sh a -> Triangular lo diag up sh a
- adaptOrder :: (Content lo, Content up, TriDiag diag, C sh, Floating a) => Triangular lo diag up sh a -> Triangular lo diag up sh a -> Triangular lo diag up sh a
- add :: (Content lo, Content up, Eq lo, Eq up, Eq sh, C sh, Floating a) => Triangular lo NonUnit up sh a -> Triangular lo NonUnit up sh a -> Triangular lo NonUnit up sh a
- sub :: (Content lo, Content up, Eq lo, Eq up, Eq sh, C sh, Floating a) => Triangular lo NonUnit up sh a -> Triangular lo NonUnit up sh a -> Triangular lo NonUnit up sh a
- type family PowerDiag lo up diag
- multiplyVector :: (Content lo, Content up, TriDiag diag, C sh, Eq sh, Floating a) => Triangular lo diag up sh a -> Vector sh a -> Vector sh a
- square :: (DiagUpLo lo up, TriDiag diag, C sh, Eq sh, Floating a) => Triangular lo diag up sh a -> Triangular lo diag up sh a
- squareGeneric :: (Content lo, Content up, TriDiag diag, C sh, Eq sh, Floating a) => Triangular lo diag up sh a -> Triangular lo (PowerDiag lo up diag) up sh a
- multiply :: (DiagUpLo lo up, TriDiag diag, C sh, Eq sh, Floating a) => Triangular lo diag up sh a -> Triangular lo diag up sh a -> Triangular lo diag up sh a
- multiplyFull :: (Content lo, Content up, TriDiag diag, C vert, C horiz, C height, Eq height, C width, Floating a) => Triangular lo diag up height a -> Full vert horiz height width a -> Full vert horiz height width a
- solve :: (Content lo, Content up, TriDiag diag, C vert, C horiz, C sh, Eq sh, C nrhs, Floating a) => Triangular lo diag up sh a -> Full vert horiz sh nrhs a -> Full vert horiz sh nrhs a
- inverse :: (DiagUpLo lo up, TriDiag diag, C sh, Floating a) => Triangular lo diag up sh a -> Triangular lo diag up sh a
- inverseGeneric :: (Content lo, Content up, TriDiag diag, C sh, Floating a) => Triangular lo diag up sh a -> Triangular lo (PowerDiag lo up diag) up sh a
- determinant :: (Content lo, Content up, TriDiag diag, C sh, Floating a) => Triangular lo diag up sh a -> a
- size :: Triangular lo diag up sh a -> sh
- eigenvalues :: (DiagUpLo lo up, C sh, Floating a) => Triangular lo diag up sh a -> Vector sh a
- eigensystem :: (DiagUpLo lo up, C sh, Floating a) => Triangular lo NonUnit up sh a -> (Triangular lo NonUnit up sh a, Vector sh a, Triangular lo NonUnit up sh a)
Documentation
type Triangular lo diag up sh = Array (Triangular lo diag up sh) Source #
type FlexUpper diag sh = Array (UpperTriangular diag sh) Source #
type FlexLower diag sh = Array (LowerTriangular diag sh) Source #
type FlexSymmetric diag sh = Array (FlexSymmetric diag sh) Source #
fromList :: (Content lo, Content up, C sh, Storable a) => Order -> sh -> [a] -> Triangular lo NonUnit up sh a Source #
autoFromList :: (Content lo, Content up, Storable a) => Order -> [a] -> Triangular lo NonUnit up ZeroInt a Source #
relaxUnitDiagonal :: TriDiag diag => Triangular lo Unit up sh a -> Triangular lo diag up sh a Source #
strictNonUnitDiagonal :: TriDiag diag => Triangular lo diag up sh a -> Triangular lo NonUnit up sh a Source #
asDiagonal :: FlexDiagonal diag sh a -> FlexDiagonal diag sh a Source #
asSymmetric :: FlexSymmetric diag sh a -> FlexSymmetric diag sh a Source #
forceUnitDiagonal :: Triangular lo Unit up sh a -> Triangular lo Unit up sh a Source #
forceNonUnitDiagonal :: Triangular lo NonUnit up sh a -> Triangular lo NonUnit up sh a Source #
identity :: (Content lo, Content up, C sh, Floating a) => Order -> sh -> Triangular lo Unit up sh a Source #
diagonal :: (Content lo, Content up, C sh, Floating a) => Order -> Vector sh a -> Triangular lo NonUnit up sh a Source #
takeDiagonal :: (Content lo, Content up, C sh, Floating a) => Triangular lo diag up sh a -> Vector sh a Source #
transpose :: (Content lo, Content up, TriDiag diag) => Triangular lo diag up sh a -> Triangular up diag lo sh a Source #
adjoint :: (Content lo, Content up, TriDiag diag, C sh, Floating a) => Triangular lo diag up sh a -> Triangular up diag lo sh a Source #
stackLower :: (TriDiag diag, C sh0, Eq sh0, C sh1, Eq sh1, Floating a) => FlexLower diag sh0 a -> General sh1 sh0 a -> FlexLower diag sh1 a -> FlexLower diag (sh0 :+: sh1) a Source #
stackUpper :: (TriDiag diag, C sh0, Eq sh0, C sh1, Eq sh1, Floating a) => FlexUpper diag sh0 a -> General sh0 sh1 a -> FlexUpper diag sh1 a -> FlexUpper diag (sh0 :+: sh1) a Source #
For upper triangular matrices it holds:
toSquare (stack a b c) = toSquare a ||| b === constant 0 ||| toSquare c
For the other triangular flavors it holds accordingly
It holds order (stack a b c) = order b
.
The function is most efficient when the order of all blocks match.
stackSymmetric :: (TriDiag diag, C sh0, Eq sh0, C sh1, Eq sh1, Floating a) => FlexSymmetric diag sh0 a -> General sh0 sh1 a -> FlexSymmetric diag sh1 a -> FlexSymmetric diag (sh0 :+: sh1) a Source #
toSquare :: (Content lo, Content up, C sh, Floating a) => Triangular lo diag up sh a -> Square sh a Source #
takeLower :: (C horiz, C height, C width, Floating a) => Full Small horiz height width a -> Lower height a Source #
takeUpper :: (C vert, C height, C width, Floating a) => Full vert Small height width a -> Upper width a Source #
fromLowerRowMajor :: (C sh, Floating a) => Array (Triangular Lower sh) a -> Lower sh a Source #
toLowerRowMajor :: (C sh, Floating a) => Lower sh a -> Array (Triangular Lower sh) a Source #
fromUpperRowMajor :: (C sh, Floating a) => Array (Triangular Upper sh) a -> Upper sh a Source #
toUpperRowMajor :: (C sh, Floating a) => Upper sh a -> Array (Triangular Upper sh) a Source #
forceOrder :: (Content lo, Content up, TriDiag diag, C sh, Floating a) => Order -> Triangular lo diag up sh a -> Triangular lo diag up sh a Source #
adaptOrder :: (Content lo, Content up, TriDiag diag, C sh, Floating a) => Triangular lo diag up sh a -> Triangular lo diag up sh a -> Triangular lo diag up sh a Source #
adaptOrder x y
contains the data of y
with the layout of x
.
add :: (Content lo, Content up, Eq lo, Eq up, Eq sh, C sh, Floating a) => Triangular lo NonUnit up sh a -> Triangular lo NonUnit up sh a -> Triangular lo NonUnit up sh a Source #
sub :: (Content lo, Content up, Eq lo, Eq up, Eq sh, C sh, Floating a) => Triangular lo NonUnit up sh a -> Triangular lo NonUnit up sh a -> Triangular lo NonUnit up sh a Source #
multiplyVector :: (Content lo, Content up, TriDiag diag, C sh, Eq sh, Floating a) => Triangular lo diag up sh a -> Vector sh a -> Vector sh a Source #
square :: (DiagUpLo lo up, TriDiag diag, C sh, Eq sh, Floating a) => Triangular lo diag up sh a -> Triangular lo diag up sh a Source #
squareGeneric :: (Content lo, Content up, TriDiag diag, C sh, Eq sh, Floating a) => Triangular lo diag up sh a -> Triangular lo (PowerDiag lo up diag) up sh a Source #
Include symmetric matrices. However, symmetric matrices do not preserve unit diagonals.
multiply :: (DiagUpLo lo up, TriDiag diag, C sh, Eq sh, Floating a) => Triangular lo diag up sh a -> Triangular lo diag up sh a -> Triangular lo diag up sh a Source #
multiplyFull :: (Content lo, Content up, TriDiag diag, C vert, C horiz, C height, Eq height, C width, Floating a) => Triangular lo diag up height a -> Full vert horiz height width a -> Full vert horiz height width a Source #
solve :: (Content lo, Content up, TriDiag diag, C vert, C horiz, C sh, Eq sh, C nrhs, Floating a) => Triangular lo diag up sh a -> Full vert horiz sh nrhs a -> Full vert horiz sh nrhs a Source #
inverse :: (DiagUpLo lo up, TriDiag diag, C sh, Floating a) => Triangular lo diag up sh a -> Triangular lo diag up sh a Source #
inverseGeneric :: (Content lo, Content up, TriDiag diag, C sh, Floating a) => Triangular lo diag up sh a -> Triangular lo (PowerDiag lo up diag) up sh a Source #
determinant :: (Content lo, Content up, TriDiag diag, C sh, Floating a) => Triangular lo diag up sh a -> a Source #
size :: Triangular lo diag up sh a -> sh Source #
eigenvalues :: (DiagUpLo lo up, C sh, Floating a) => Triangular lo diag up sh a -> Vector sh a Source #
eigensystem :: (DiagUpLo lo up, C sh, Floating a) => Triangular lo NonUnit up sh a -> (Triangular lo NonUnit up sh a, Vector sh a, Triangular lo NonUnit up sh a) Source #
(vr,d,vlAdj) = eigensystem a
Counterintuitively, vr
contains the right eigenvectors as columns
and vlAdj
contains the left conjugated eigenvectors as rows.
The idea is to provide a decomposition of a
.
If a
is diagonalizable, then vr
and vlAdj
are almost inverse to each other.
More precisely, vlAdj <#> vr
is a diagonal matrix.
This is because the eigenvectors are not normalized.
With the following scaling, the decomposition becomes perfect:
let scal = Array.map recip $ takeDiagonal $ vlAdj <#> vr a == vr <#> diagonal d <#> diagonal scal <#> vlAdj
If a
is non-diagonalizable
then some columns of vr
and corresponding rows of vlAdj
are left zero
and the above property does not hold.