Package dk.alexandra.fresco.stat
Class DefaultLinearAlgebra
Object
DefaultLinearAlgebra
- All Implemented Interfaces:
AdvancedLinearAlgebra
public class DefaultLinearAlgebra extends Object implements AdvancedLinearAlgebra
-
Method Summary
Modifier and Type Method Description DRes<ArrayList<DRes<SFixed>>>backSubstitution(Matrix<DRes<SFixed>> a, ArrayList<DRes<SFixed>> b)Use back substitution to compute a vector x such that ax = b where a is an upper triangular square matrix.DRes<ArrayList<DRes<SFixed>>>forwardSubstitution(Matrix<DRes<SFixed>> a, ArrayList<DRes<SFixed>> b)Use forward substitution to compute a vector x such that ax = b where a is a lower triangular square matrix.DRes<List<ArrayList<DRes<SFixed>>>>gramSchmidt(List<ArrayList<DRes<SFixed>>> vectors)Return a list of mutually orthogonal vectors spanning the same space as the given vectors.DRes<Matrix<DRes<SFixed>>>invertLowerTriangularMatrix(Matrix<DRes<SFixed>> l)Compute the inverse of a lower triangular matrix.DRes<List<DRes<SFixed>>>iterativeEigenvalues(Matrix<DRes<SFixed>> a, int iterations)Approximate the eigenvalues of a matrix using the QR-algorithm.DRes<ArrayList<DRes<SFixed>>>linearInverseProblem(Matrix<DRes<SFixed>> a, ArrayList<DRes<SFixed>> b)Solve a linear inverse problem, eg.DRes<Matrix<DRes<SFixed>>>moorePenrosePseudoInverse(Matrix<DRes<SFixed>> a)Compute the Moore-Penrose pseudo-inverse of an m×n-matrix with full column rank.DRes<ArrayList<DRes<SFixed>>>normalizeVector(ArrayList<DRes<SFixed>> u)Normalize a non-zero vector.DRes<ArrayList<DRes<SFixed>>>projection(ArrayList<DRes<SFixed>> a, ArrayList<DRes<SFixed>> u)Compute the projection of a vector a onto another vector u.DRes<Pair<Matrix<DRes<SFixed>>,Matrix<DRes<SFixed>>>>qrDecomposition(Matrix<DRes<SFixed>> a)Compute the QR-decomposition of an mxn-matrix a with m ≥ n and full column rank.
-
Method Details
-
backSubstitution
public DRes<ArrayList<DRes<SFixed>>> backSubstitution(Matrix<DRes<SFixed>> a, ArrayList<DRes<SFixed>> b)Description copied from interface:AdvancedLinearAlgebraUse back substitution to compute a vector x such that ax = b where a is an upper triangular square matrix.- Specified by:
backSubstitutionin interfaceAdvancedLinearAlgebra- Parameters:
a- An upper triangular matrix.b- A vector.- Returns:
- A vector x such that ax = b.
-
forwardSubstitution
public DRes<ArrayList<DRes<SFixed>>> forwardSubstitution(Matrix<DRes<SFixed>> a, ArrayList<DRes<SFixed>> b)Description copied from interface:AdvancedLinearAlgebraUse forward substitution to compute a vector x such that ax = b where a is a lower triangular square matrix.- Specified by:
forwardSubstitutionin interfaceAdvancedLinearAlgebra- Parameters:
a- An lower triangular matrix.b- A vector.- Returns:
- A vector x such that ax = b.
-
gramSchmidt
Description copied from interface:AdvancedLinearAlgebraReturn a list of mutually orthogonal vectors spanning the same space as the given vectors.- Specified by:
gramSchmidtin interfaceAdvancedLinearAlgebra- Parameters:
vectors- A set of linearly independent vectors.- Returns:
- A set of mutually orthogonal vectors spanning the same space as the input.
-
invertLowerTriangularMatrix
public DRes<Matrix<DRes<SFixed>>> invertLowerTriangularMatrix(Matrix<DRes<SFixed>> l)Description copied from interface:AdvancedLinearAlgebraCompute the inverse of a lower triangular matrix.- Specified by:
invertLowerTriangularMatrixin interfaceAdvancedLinearAlgebra- Parameters:
l- A lower triangular matrix.- Returns:
- The inverse of l
-
linearInverseProblem
public DRes<ArrayList<DRes<SFixed>>> linearInverseProblem(Matrix<DRes<SFixed>> a, ArrayList<DRes<SFixed>> b)Description copied from interface:AdvancedLinearAlgebraSolve a linear inverse problem, eg. find an x such that ax = b where a is an m×n-matrix and b is an n-dimensional vector. If a system is overdetermined (m ≥ n), the computation will find the x minimising ||ax - b||.- Specified by:
linearInverseProblemin interfaceAdvancedLinearAlgebra- Parameters:
a- An m×n-matrix.b- An n-dimensional vector.- Returns:
- A solution to the equation ax = b or a matrix minimising ax - b.
-
moorePenrosePseudoInverse
public DRes<Matrix<DRes<SFixed>>> moorePenrosePseudoInverse(Matrix<DRes<SFixed>> a)Description copied from interface:AdvancedLinearAlgebraCompute the Moore-Penrose pseudo-inverse of an m×n-matrix with full column rank.- Specified by:
moorePenrosePseudoInversein interfaceAdvancedLinearAlgebra- Parameters:
a- An m×n-matrix with full column rank.- Returns:
- The Moore-Penrose pseudo-inverse of a.
-
normalizeVector
Description copied from interface:AdvancedLinearAlgebraNormalize a non-zero vector.- Specified by:
normalizeVectorin interfaceAdvancedLinearAlgebra- Parameters:
u- A non-zero vector.- Returns:
- A vector with the same direction as u and magnitude 1.
-
projection
public DRes<ArrayList<DRes<SFixed>>> projection(ArrayList<DRes<SFixed>> a, ArrayList<DRes<SFixed>> u)Description copied from interface:AdvancedLinearAlgebraCompute the projection of a vector a onto another vector u.- Specified by:
projectionin interfaceAdvancedLinearAlgebra- Parameters:
a- A vector.u- A vector.- Returns:
- a projected onto u.
-
iterativeEigenvalues
Description copied from interface:AdvancedLinearAlgebraApproximate the eigenvalues of a matrix using the QR-algorithm.- Specified by:
iterativeEigenvaluesin interfaceAdvancedLinearAlgebra- Parameters:
a- A square matrix.iterations- The number of iterations.- Returns:
- An approximation of the eigenvalues of a.
-
qrDecomposition
public DRes<Pair<Matrix<DRes<SFixed>>,Matrix<DRes<SFixed>>>> qrDecomposition(Matrix<DRes<SFixed>> a)Description copied from interface:AdvancedLinearAlgebraCompute the QR-decomposition of an mxn-matrix a with m ≥ n and full column rank. The QR-decomposition is a pair of matrices (Q,R) with A = QR and where Q is an mxn-matrix with orthonormal columns and R is an upper-triangular nxn-matrix.- Specified by:
qrDecompositionin interfaceAdvancedLinearAlgebra- Parameters:
a- An mxn-matrix- Returns:
- A pair of matrices (Q,R) with a = QR and where * Q is an mxn-matrix with orthonormal columns and R is an upper-triangular * nxn-matrix.
-