Portability | non-portable |
---|---|
Stability | experimental |
Maintainer | Nicola Squartini <tensor5@gmail.com> |
Safe Haskell | Safe-Inferred |
- class VectorSpace v where
- class Cardinal n => Product n t1 t2 where
- type MatrixProductSpace t1 t2 = ProdSpace (Succ Zero) t1 t2
- (.*.) :: Product (Succ Zero) t1 t2 => t1 -> t2 -> MatrixProductSpace t1 t2
- type :⊗: t1 t2 = ProdSpace C0 t1 t2
- (⊗) :: Product C0 t1 t2 => t1 -> t2 -> t1 :⊗: t2
- class DotProduct t where
- class (Tensor t, Index t ~ (i :|: (j :|: Nil))) => Matrix i j t where
- rowSwitch :: i -> i -> t -> t
- rowMult :: (Num e, Elem t ~ e) => i -> Elem t -> t -> t
- rowAdd :: (Num e, Elem t ~ e) => i -> Elem t -> i -> t -> t
- colSwitch :: j -> j -> t -> t
- colMult :: (Num e, Elem t ~ e) => j -> Elem t -> t -> t
- colAdd :: (Num e, Elem t ~ e) => j -> Elem t -> j -> t -> t
- rowEchelonForm :: (Eq e, Fractional e, Elem t ~ e) => t -> t
- class LinearSystem t1 t2 where
- type SolSpace t1 t2
- triangularSolve :: t1 -> t2 -> (t1, t2)
- parametricSolve :: t1 -> t2 -> Maybe (SolSpace t1 t2, [SolSpace t1 t2])
- class SquareMatrix t where
Documentation
class VectorSpace v whereSource
MultiIndex i => VectorSpace (Tensor i) |
class Cardinal n => Product n t1 t2 whereSource
A general form of product between two tensors, in which the last
n
dimensions of t1
are contracted with the first n
dimensions
of t2
. The resulting tensor belongs to the space
. The operators ProdSpace
n
t1 t2
and .*.
below are particular cases
where
n
is equal to 1 and 0 respectively.
(Num e, Cardinal n, MultiIndex i, MultiIndex j, JoinList n i j) => Product n (Tensor i e) (Tensor j e) |
type MatrixProductSpace t1 t2 = ProdSpace (Succ Zero) t1 t2Source
(.*.) :: Product (Succ Zero) t1 t2 => t1 -> t2 -> MatrixProductSpace t1 t2Source
It is the product of the last dimension of t1
with the first
dimension of t2
. In the case where t1
and t2
are matrices this
coincide with the ordinary matrix product.
class (Tensor t, Index t ~ (i :|: (j :|: Nil))) => Matrix i j t whereSource
A matrix with i
rows and j
columns.
rowSwitch :: i -> i -> t -> tSource
Switch two rows.
rowMult :: (Num e, Elem t ~ e) => i -> Elem t -> t -> tSource
Multiply a row by a number.
rowAdd :: (Num e, Elem t ~ e) => i -> Elem t -> i -> t -> tSource
adds rowAdd
i1 a i2 ta
times the row i2
to the
row i1
ot t
.
colSwitch :: j -> j -> t -> tSource
Switch two columns.
colMult :: (Num e, Elem t ~ e) => j -> Elem t -> t -> tSource
Multiply a column by a number.
colAdd :: (Num e, Elem t ~ e) => j -> Elem t -> j -> t -> tSource
adds colAdd
j1 a j2 ta
times the column j2
to
the column j1
ot t
.
rowEchelonForm :: (Eq e, Fractional e, Elem t ~ e) => t -> tSource
Reduced row echelon form of the matrix.
class LinearSystem t1 t2 whereSource
Solves linear systems AX=B
; t1
is the type of A
, t2
is
the type of B
, and
is the type of the solution
SolSpace
t1 t2X
.
triangularSolve :: t1 -> t2 -> (t1, t2)Source
Performs row operations on the augmented matrix [t1,t2] until t1 is in reduced row echelon form, then slits the result.
parametricSolve :: t1 -> t2 -> Maybe (SolSpace t1 t2, [SolSpace t1 t2])Source
Returns
if the system Nothing
AX=B
has no solution,
otherwise returns a solution for the system and a list of basis
vectors for the kernel of A
.
class SquareMatrix t whereSource
Indentity matrix.
inverse :: (Eq e, Fractional e) => t e -> Maybe (t e)Source
Inverts, if the matrix is invertible, otherwise
.
Nothing
Trace of the matrix.
charPoly :: Num e => t e -> [e]Source
Computes the coefficient of the polynomial p(z)=det(A+zI) using the method of closed ordered walks (clow) illustrated in the paper of G. Rote http://page.mi.fu-berlin.de/rote/Papers/pdf/Division-free+algorithms.pdf. The number of operations for the whole process is O(n^4), where n is the number of rows of the matrix. The first coefficient is the known term and equals the determinant, while the last one is the coefficient of z^(n-1) and equals the trace. The coefficient of z^n equals 1 and is not included in the resulting list. The k-th coefficient is the sum of all principal minors of order n-k+1.
minPoly :: (Eq e, Fractional e) => t e -> [e]Source
Minimal polynomial. The algorithm follows the paper of S. Bialas and M. Bialas http://bulletin.pan.pl/(56-4)391.pdf. The number of operations is O(n^4), where n is the number of rows of the matrix.
det :: Num e => t e -> eSource
Determinant of the matrix.
polyEval :: Num e => t e -> [e] -> t eSource
Evaluate a polynomial on a matrix.