Package edu.jas.vector
Class LinAlg<C extends RingElem<C>>
java.lang.Object
edu.jas.vector.LinAlg<C>
- Type Parameters:
C
- coefficient type
- All Implemented Interfaces:
Serializable
Linear algebra methods. Implements linear algebra computations and tests,
mainly based on Gauss elimination. Partly based on LU_decomposition.
Computation of Null space basis, row echelon form, inverses and ranks.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionMatrix LU decomposition.determinantLU
(GenMatrix<C> A, List<Integer> P) Determinant with LU decomposition.Matrix fraction free Gauss elimination.Inverse with LU decomposition.nullSpaceBasis
(GenMatrix<C> A) Matrix Null Space basis, cokernel.long
Rank via null space.long
Rank via row echelon form.rowEchelonForm
(GenMatrix<C> A) Matrix row echelon form construction.Matrix row echelon form construction.Solve linear system of equations.Solve with LU decomposition.
-
Field Details
-
logger
private static final org.apache.logging.log4j.Logger logger
-
-
Constructor Details
-
LinAlg
public LinAlg()Constructor.
-
-
Method Details
-
decompositionLU
Matrix LU decomposition. Matrix A is replaced by its LU decomposition. A contains a copy of both matrices L-E and U as A=(L-E)+U such that P*A=L*U. The permutation matrix is not stored as a matrix, but in an integer vector P of size N+1 containing column indexes where the permutation matrix has "1". The last element P[N]=S+N, where S is the number of row exchanges needed for determinant computation, det(P)=(-1)^S- Parameters:
A
- a n×n matrix.- Returns:
- permutation vector P and modified matrix A.
-
solveLU
Solve with LU decomposition.- Parameters:
A
- a n×n matrix in LU decomposition.P
- permutation vector.b
- right hand side vector.- Returns:
- x solution vector of A*x = b.
-
solve
Solve linear system of equations.- Parameters:
A
- a n×n matrix.b
- right hand side vector.- Returns:
- x solution vector of A*x = b.
-
determinantLU
Determinant with LU decomposition.- Parameters:
A
- a n×n matrix in LU decomposition.P
- permutation vector.- Returns:
- d determinant of A.
-
inverseLU
Inverse with LU decomposition.- Parameters:
A
- a n×n matrix in LU decomposition.P
- permutation vector.- Returns:
- inv(A) with A * inv(A) == 1.
-
nullSpaceBasis
Matrix Null Space basis, cokernel. From the transpose matrix At it computes the kernel with At*v_i = 0.- Parameters:
A
- a n×n matrix.- Returns:
- V a list of basis vectors (v_1, ..., v_k) with v_i*A == 0.
-
rankNS
Rank via null space.- Parameters:
A
- a n×n matrix.- Returns:
- r rank of A.
-
rowEchelonForm
Matrix row echelon form construction. Matrix A is replaced by its row echelon form, an upper triangle matrix.- Parameters:
A
- a n×m matrix.- Returns:
- A row echelon form of A, matrix A is modified.
-
rankRE
Rank via row echelon form.- Parameters:
A
- a n×n matrix.- Returns:
- r rank of A.
-
rowEchelonFormSparse
Matrix row echelon form construction. Matrix A is replaced by its row echelon form, an upper triangle matrix with less non-zero entries. No column swaps and transforms are performed as with the Gauss-Jordan algorithm.- Parameters:
A
- a n×m matrix.- Returns:
- A sparse row echelon form of A, matrix A is modified.
-
fractionfreeGaussElimination
Matrix fraction free Gauss elimination. Matrix A is replaced by its fraction free LU decomposition. A contains a copy of both matrices L-E and U as A=(L-E)+U such that P*A=L*U. TODO: L is not computed but 0. The permutation matrix is not stored as a matrix, but in an integer vector P of size N+1 containing column indexes where the permutation matrix has "1". The last element P[N]=S+N, where S is the number of row exchanges needed for determinant computation, det(P)=(-1)^S- Parameters:
A
- a n×n matrix.- Returns:
- permutation vector P and modified matrix A.
-