Safe Haskell | None |
---|---|
Language | Haskell98 |
Synopsis
- type Square sh = Array (Square sh)
- size :: Square sh a -> sh
- toFull :: (C vert, C horiz) => Square sh a -> Full vert horiz sh sh a
- toGeneral :: Square sh a -> General sh sh a
- fromGeneral :: Eq sh => General sh sh a -> Square sh a
- fromScalar :: Storable a => a -> Square () a
- toScalar :: Storable a => Square () a -> a
- fromList :: (C sh, Storable a) => sh -> [a] -> Square sh a
- autoFromList :: Storable a => [a] -> Square ZeroInt a
- transpose :: Square sh a -> Square sh a
- adjoint :: (C sh, Floating a) => Square sh a -> Square sh a
- identity :: (C sh, Floating a) => sh -> Square sh a
- identityFrom :: (C sh, Floating a) => Square sh a -> Square sh a
- identityFromWidth :: (C height, C width, Floating a) => General height width a -> Square width a
- identityFromHeight :: (C height, C width, Floating a) => General height width a -> Square height a
- diagonal :: (C sh, Floating a) => Vector sh a -> Square sh a
- takeDiagonal :: (C sh, Floating a) => Square sh a -> Vector sh a
- trace :: (C sh, Floating a) => Square sh a -> a
- multiply :: (C sh, Eq sh, Floating a) => Square sh a -> Square sh a -> Square sh a
- square :: (C sh, Floating a) => Square sh a -> Square sh a
- power :: (C sh, Floating a) => Integer -> Square sh a -> Square sh a
- solve :: (C vert, C horiz, C sh, Eq sh, C nrhs, Floating a) => Square sh a -> Full vert horiz sh nrhs a -> Full vert horiz sh nrhs a
- inverse :: (C sh, Floating a) => Square sh a -> Square sh a
- determinant :: (C sh, Floating a) => Square sh a -> a
- eigenvalues :: (C sh, Floating a) => Square sh a -> Vector sh (ComplexOf a)
- schur :: (C sh, Floating a) => Square sh a -> (Square sh a, Square sh a)
- eigensystem :: (C sh, Floating a) => Square sh a -> (Square sh (ComplexOf a), Vector sh (ComplexOf a), Square sh (ComplexOf a))
- type ComplexOf x = Complex (RealOf x)
Documentation
fromScalar :: Storable a => a -> Square () a Source #
identityFromWidth :: (C height, C width, Floating a) => General height width a -> Square width a Source #
identityFromHeight :: (C height, C width, Floating a) => General height width a -> Square height a Source #
solve :: (C vert, C horiz, C sh, Eq sh, C nrhs, Floating a) => Square sh a -> Full vert horiz sh nrhs a -> Full vert horiz sh nrhs a Source #
schur :: (C sh, Floating a) => Square sh a -> (Square sh a, Square sh a) Source #
If (q,r) = schur a
, then a = q <> adjoint q
,
where q
is unitary (orthogonal)
and r
is a right-upper triangular matrix for complex a
and a 1x1-or-2x2-block upper triangular matrix for real a
.
With takeDiagonal r
you get all eigenvalues of a
if a
is complex
and the real parts of the eigenvalues if a
is real.
Complex conjugated eigenvalues of a real matrix a
are encoded as 2x2 blocks along the diagonal.
eigensystem :: (C sh, Floating a) => Square sh a -> (Square sh (ComplexOf a), Vector sh (ComplexOf a), Square sh (ComplexOf a)) Source #
(vr,d,vl) = eigensystem a
Counterintuitively, vr
contains the right eigenvectors
and vl
contains the left eigenvectors as columns.
The idea is to provide a decomposition of a
.
If a
is diagonalizable, then vr
and vl
are almost inverse to each other.
More precisely, adjoint vl <#> vr
is a diagonal matrix.
This is because all eigenvectors are normalized to Euclidean norm 1.
With the following scaling, the decomposition becomes perfect:
let scal = Array.map recip $ takeDiagonal $ adjoint vl <#> vr a == vr <#> diagonal d <#> diagonal scal <#> adjoint vl
If a
is non-diagonalizable then some columns of vr
and vl
are left zero
and the above property does not hold.