- 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
- class SquareMatrix t where
A general form of product between two tensors, in which the last
n dimensions of
t1 are contracted with the first
t2. The resulting tensor belongs to the space
. The operators
⊗ below are particular cases
n is equal to 1 and 0 respectively.
It is the product of the last dimension of
t1 with the first
t2. In the case where
t2 are matrices this
coincide with the ordinary matrix product.
A matrix with
i rows and
Switch two rows.
Multiply a row by a number.
rowAdd i1 a i2 t
a times the row
i2 to the
Switch two columns.
Multiply a column by a number.
colAdd j1 a j2 t
a times the column
Reduced row echelon form of the matrix.
Solves linear systems
t1 is the type of
the type of
is the type of the solution
SolSpace t1 t2
Performs row operations on the augmented matrix [t1,t2] until t1 is in reduced row echelon form, then slits the result.
if the system
AX=B has no solution,
otherwise returns a solution for the system and a list of basis
vectors for the kernel of
Inverts, if the matrix is invertible, otherwise
Trace of the matrix.
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.
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.
Determinant of the matrix.
Evaluate a polynomial on a matrix.