Package org.la4j
Class Matrices
- java.lang.Object
-
- org.la4j.Matrices
-
public final class Matrices extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
Matrices.DiagonallyDominantPredicate
private static class
Matrices.PositiveDefiniteMatrixPredicate
private static class
Matrices.SymmetricMatrixPredicate
-
Field Summary
Fields Modifier and Type Field Description static MatrixFactory<Basic1DMatrix>
BASIC_1D
A matrix factory that produces zeroBasic1DMatrix
.static MatrixFactory<Basic2DMatrix>
BASIC_2D
A matrix factory that produces zeroBasic2DMatrix
.static MatrixFactory<CCSMatrix>
CCS
A matrix factory that produces zeroCCSMatrix
.static MatrixFactory<?>[]
CONVERTERS
static MatrixFactory<CRSMatrix>
CRS
A matrix factory that produces zeroCRSMatrix
.static MatrixFunction
DEC_FUNCTION
Decreases each element of matrix by1
.static MatrixFactory<Basic2DMatrix>
DENSE
A default matrix factory for dense matrices.static MatrixPredicate
DIAGONAL_MATRIX
Checks whether the matrix is a diagonal matrix.static AdvancedMatrixPredicate
DIAGONALLY_DOMINANT_MATRIX
Checks whether the matrix is a diagonally dominant matrix.static double
EPS
The machine epsilon, that is calculated at runtime.static MatrixPredicate
IDENTITY_MATRIX
Checks whether the matrix is an identity matrix.static MatrixFunction
INC_FUNCTION
Increases each element of matrix by1
.static MatrixFunction
INV_FUNCTION
Inverts each element of matrix.static MatrixPredicate
LOWER_BIDIAGONAL_MATRIX
Checks whether the matrix is a lower bi-diagonal matrix.static MatrixPredicate
LOWER_TRIANGULAR_MATRIX
Checks whether the matrix is a lower triangular matrix.static MatrixPredicate
NEGATIVE_MATRIX
Checks whether the matrix is a negative matrix.static AdvancedMatrixPredicate
POSITIVE_DEFINITE_MATRIX
Checks whether the matrix is positive definite.static MatrixPredicate
POSITIVE_MATRIX
Checks whether the matrix is a positive matrix.static int
ROUND_FACTOR
Exponent of machine epsilonstatic MatrixFactory<CRSMatrix>
SPARSE
A default factory for sparse matrices.static MatrixFactory<CCSMatrix>
SPARSE_COLUMN_MAJOR
A default factory for sparse column-major matrices.static MatrixFactory<CRSMatrix>
SPARSE_ROW_MAJOR
A default factory for sparse row-major matrices.static AdvancedMatrixPredicate
SYMMETRIC_MATRIX
Checks whether the matrix is a symmetric matrix.static MatrixPredicate
TRIDIAGONAL_MATRIX
Checks whether the matrix is a tridiagonal matrix.static MatrixPredicate
UPPER_BIDIAGONAL_MATRIX
Checks whether the matrix is an upper bidiagonal matrix.static MatrixPredicate
UPPER_TRIANGULAR_MATRIX
Checks whether the matrix is an upper triangular matrix.static MatrixPredicate
ZERO_MATRIX
Checks whether the matrix is a zero matrix.
-
Constructor Summary
Constructors Constructor Description Matrices()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static MatrixProcedure
asAccumulatorProcedure(MatrixAccumulator accumulator)
Creates an accumulator procedure that adapts a matrix accumulator for procedure interface.static MatrixFunction
asConstFunction(double arg)
Creates a const function that evaluates it's argument to givenvalue
.static MatrixFunction
asDivFunction(double arg)
Creates a div function that divides it's argument by givenvalue
.static MatrixFunction
asMinusFunction(double arg)
Creates a minus function that subtracts givenvalue
from it's argument.static MatrixFunction
asModFunction(double arg)
Creates a mod function that calculates the modulus of it's argument and givenvalue
.static MatrixFunction
asMulFunction(double arg)
Creates a mul function that multiplies givenvalue
by it's argument.static MatrixFunction
asPlusFunction(double arg)
Creates a plus function that adds givenvalue
to it's argument.static MatrixAccumulator
asProductAccumulator(double neutral)
Creates a product matrix accumulator that calculates the product of all elements in the matrix.static MatrixAccumulator
asProductFunctionAccumulator(double neutral, MatrixFunction function)
Creates a product function accumulator, that calculates the product of all elements in the matrix after applying givenfunction
to each of them.static MatrixAccumulator
asSumAccumulator(double neutral)
Creates a sum matrix accumulator that calculates the sum of all elements in the matrix.static MatrixAccumulator
asSumFunctionAccumulator(double neutral, MatrixFunction function)
Creates a sum function accumulator, that calculates the sum of all elements in the matrix after applying givenfunction
to each of them.static MatrixAccumulator
mkEuclideanNormAccumulator()
Makes an Euclidean norm accumulator that allows to useMatrix.fold(org.la4j.vector.functor.MatrixAccumulator)
method for norm calculation.static MatrixAccumulator
mkInfinityNormAccumulator()
Makes an Infinity norm accumulator that allows to useMatrix.fold(org.la4j.vector.functor.MatrixAccumulator)
method for norm calculation.static MatrixAccumulator
mkManhattanNormAccumulator()
Makes an Manhattan norm accumulator that allows to useMatrix.fold(org.la4j.vector.functor.MatrixAccumulator)
method for norm calculation.static MatrixAccumulator
mkMaxAccumulator()
Makes a maximum matrix accumulator that accumulates the maximum of matrix elements.static MatrixAccumulator
mkMinAccumulator()
Makes a minimum matrix accumulator that accumulates the minimum of matrix elements.
-
-
-
Field Detail
-
EPS
public static final double EPS
The machine epsilon, that is calculated at runtime.
-
ROUND_FACTOR
public static final int ROUND_FACTOR
Exponent of machine epsilon
-
DIAGONAL_MATRIX
public static final MatrixPredicate DIAGONAL_MATRIX
Checks whether the matrix is a diagonal matrix.
-
IDENTITY_MATRIX
public static final MatrixPredicate IDENTITY_MATRIX
Checks whether the matrix is an identity matrix.
-
ZERO_MATRIX
public static final MatrixPredicate ZERO_MATRIX
Checks whether the matrix is a zero matrix.
-
TRIDIAGONAL_MATRIX
public static final MatrixPredicate TRIDIAGONAL_MATRIX
Checks whether the matrix is a tridiagonal matrix.
-
POSITIVE_MATRIX
public static final MatrixPredicate POSITIVE_MATRIX
Checks whether the matrix is a positive matrix.
-
NEGATIVE_MATRIX
public static final MatrixPredicate NEGATIVE_MATRIX
Checks whether the matrix is a negative matrix.
-
LOWER_BIDIAGONAL_MATRIX
public static final MatrixPredicate LOWER_BIDIAGONAL_MATRIX
Checks whether the matrix is a lower bi-diagonal matrix.
-
UPPER_BIDIAGONAL_MATRIX
public static final MatrixPredicate UPPER_BIDIAGONAL_MATRIX
Checks whether the matrix is an upper bidiagonal matrix.
-
LOWER_TRIANGULAR_MATRIX
public static final MatrixPredicate LOWER_TRIANGULAR_MATRIX
Checks whether the matrix is a lower triangular matrix.
-
UPPER_TRIANGULAR_MATRIX
public static final MatrixPredicate UPPER_TRIANGULAR_MATRIX
Checks whether the matrix is an upper triangular matrix.
-
SYMMETRIC_MATRIX
public static final AdvancedMatrixPredicate SYMMETRIC_MATRIX
Checks whether the matrix is a symmetric matrix.
-
DIAGONALLY_DOMINANT_MATRIX
public static final AdvancedMatrixPredicate DIAGONALLY_DOMINANT_MATRIX
Checks whether the matrix is a diagonally dominant matrix.
-
POSITIVE_DEFINITE_MATRIX
public static final AdvancedMatrixPredicate POSITIVE_DEFINITE_MATRIX
Checks whether the matrix is positive definite.
-
BASIC_2D
public static final MatrixFactory<Basic2DMatrix> BASIC_2D
A matrix factory that produces zeroBasic2DMatrix
.
-
BASIC_1D
public static final MatrixFactory<Basic1DMatrix> BASIC_1D
A matrix factory that produces zeroBasic1DMatrix
.
-
DENSE
public static final MatrixFactory<Basic2DMatrix> DENSE
A default matrix factory for dense matrices.
-
CCS
public static final MatrixFactory<CCSMatrix> CCS
A matrix factory that produces zeroCCSMatrix
.
-
CRS
public static final MatrixFactory<CRSMatrix> CRS
A matrix factory that produces zeroCRSMatrix
.
-
SPARSE
public static final MatrixFactory<CRSMatrix> SPARSE
A default factory for sparse matrices.
-
SPARSE_ROW_MAJOR
public static final MatrixFactory<CRSMatrix> SPARSE_ROW_MAJOR
A default factory for sparse row-major matrices.
-
SPARSE_COLUMN_MAJOR
public static final MatrixFactory<CCSMatrix> SPARSE_COLUMN_MAJOR
A default factory for sparse column-major matrices.
-
CONVERTERS
public static final MatrixFactory<?>[] CONVERTERS
-
INC_FUNCTION
public static final MatrixFunction INC_FUNCTION
Increases each element of matrix by1
.
-
DEC_FUNCTION
public static final MatrixFunction DEC_FUNCTION
Decreases each element of matrix by1
.
-
INV_FUNCTION
public static final MatrixFunction INV_FUNCTION
Inverts each element of matrix.
-
-
Method Detail
-
asConstFunction
public static MatrixFunction asConstFunction(double arg)
Creates a const function that evaluates it's argument to givenvalue
.- Parameters:
arg
- a const value- Returns:
- a closure object that does
_
-
asPlusFunction
public static MatrixFunction asPlusFunction(double arg)
Creates a plus function that adds givenvalue
to it's argument.- Parameters:
arg
- a value to be added to function's argument- Returns:
- a closure object that does
_ + _
-
asMinusFunction
public static MatrixFunction asMinusFunction(double arg)
Creates a minus function that subtracts givenvalue
from it's argument.- Parameters:
arg
- a value to be subtracted from function's argument- Returns:
- a closure that does
_ - _
-
asMulFunction
public static MatrixFunction asMulFunction(double arg)
Creates a mul function that multiplies givenvalue
by it's argument.- Parameters:
arg
- a value to be multiplied by function's argument- Returns:
- a closure that does
_ * _
-
asDivFunction
public static MatrixFunction asDivFunction(double arg)
Creates a div function that divides it's argument by givenvalue
.- Parameters:
arg
- a divisor value- Returns:
- a closure that does
_ / _
-
asModFunction
public static MatrixFunction asModFunction(double arg)
Creates a mod function that calculates the modulus of it's argument and givenvalue
.- Parameters:
arg
- a divisor value- Returns:
- a closure that does
_ % _
-
mkMinAccumulator
public static MatrixAccumulator mkMinAccumulator()
Makes a minimum matrix accumulator that accumulates the minimum of matrix elements.- Returns:
- a minimum vector accumulator
-
mkMaxAccumulator
public static MatrixAccumulator mkMaxAccumulator()
Makes a maximum matrix accumulator that accumulates the maximum of matrix elements.- Returns:
- a maximum vector accumulator
-
mkEuclideanNormAccumulator
public static MatrixAccumulator mkEuclideanNormAccumulator()
Makes an Euclidean norm accumulator that allows to useMatrix.fold(org.la4j.vector.functor.MatrixAccumulator)
method for norm calculation.- Returns:
- an Euclidean norm accumulator
-
mkManhattanNormAccumulator
public static MatrixAccumulator mkManhattanNormAccumulator()
Makes an Manhattan norm accumulator that allows to useMatrix.fold(org.la4j.vector.functor.MatrixAccumulator)
method for norm calculation.- Returns:
- a Manhattan norm accumulator
-
mkInfinityNormAccumulator
public static MatrixAccumulator mkInfinityNormAccumulator()
Makes an Infinity norm accumulator that allows to useMatrix.fold(org.la4j.vector.functor.MatrixAccumulator)
method for norm calculation.- Returns:
- an Infinity norm accumulator
-
asSumAccumulator
public static MatrixAccumulator asSumAccumulator(double neutral)
Creates a sum matrix accumulator that calculates the sum of all elements in the matrix.- Parameters:
neutral
- the neutral value- Returns:
- a sum accumulator
-
asProductAccumulator
public static MatrixAccumulator asProductAccumulator(double neutral)
Creates a product matrix accumulator that calculates the product of all elements in the matrix.- Parameters:
neutral
- the neutral value- Returns:
- a product accumulator
-
asSumFunctionAccumulator
public static MatrixAccumulator asSumFunctionAccumulator(double neutral, MatrixFunction function)
Creates a sum function accumulator, that calculates the sum of all elements in the matrix after applying givenfunction
to each of them.- Parameters:
neutral
- the neutral valuefunction
- the matrix function- Returns:
- a sum function accumulator
-
asProductFunctionAccumulator
public static MatrixAccumulator asProductFunctionAccumulator(double neutral, MatrixFunction function)
Creates a product function accumulator, that calculates the product of all elements in the matrix after applying givenfunction
to each of them.- Parameters:
neutral
- the neutral valuefunction
- the matrix function- Returns:
- a product function accumulator
-
asAccumulatorProcedure
public static MatrixProcedure asAccumulatorProcedure(MatrixAccumulator accumulator)
Creates an accumulator procedure that adapts a matrix accumulator for procedure interface. This is useful for reusing a single accumulator for multiple fold operations in multiple matrices.- Parameters:
accumulator
- the matrix accumulator- Returns:
- an accumulator procedure
-
-