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 classMatrices.DiagonallyDominantPredicateprivate static classMatrices.PositiveDefiniteMatrixPredicateprivate static classMatrices.SymmetricMatrixPredicate
-
Field Summary
Fields Modifier and Type Field Description static MatrixFactory<Basic1DMatrix>BASIC_1DA matrix factory that produces zeroBasic1DMatrix.static MatrixFactory<Basic2DMatrix>BASIC_2DA matrix factory that produces zeroBasic2DMatrix.static MatrixFactory<CCSMatrix>CCSA matrix factory that produces zeroCCSMatrix.static MatrixFactory<?>[]CONVERTERSstatic MatrixFactory<CRSMatrix>CRSA matrix factory that produces zeroCRSMatrix.static MatrixFunctionDEC_FUNCTIONDecreases each element of matrix by1.static MatrixFactory<Basic2DMatrix>DENSEA default matrix factory for dense matrices.static MatrixPredicateDIAGONAL_MATRIXChecks whether the matrix is a diagonal matrix.static AdvancedMatrixPredicateDIAGONALLY_DOMINANT_MATRIXChecks whether the matrix is a diagonally dominant matrix.static doubleEPSThe machine epsilon, that is calculated at runtime.static MatrixPredicateIDENTITY_MATRIXChecks whether the matrix is an identity matrix.static MatrixFunctionINC_FUNCTIONIncreases each element of matrix by1.static MatrixFunctionINV_FUNCTIONInverts each element of matrix.static MatrixPredicateLOWER_BIDIAGONAL_MATRIXChecks whether the matrix is a lower bi-diagonal matrix.static MatrixPredicateLOWER_TRIANGULAR_MATRIXChecks whether the matrix is a lower triangular matrix.static MatrixPredicateNEGATIVE_MATRIXChecks whether the matrix is a negative matrix.static AdvancedMatrixPredicatePOSITIVE_DEFINITE_MATRIXChecks whether the matrix is positive definite.static MatrixPredicatePOSITIVE_MATRIXChecks whether the matrix is a positive matrix.static intROUND_FACTORExponent of machine epsilonstatic MatrixFactory<CRSMatrix>SPARSEA default factory for sparse matrices.static MatrixFactory<CCSMatrix>SPARSE_COLUMN_MAJORA default factory for sparse column-major matrices.static MatrixFactory<CRSMatrix>SPARSE_ROW_MAJORA default factory for sparse row-major matrices.static AdvancedMatrixPredicateSYMMETRIC_MATRIXChecks whether the matrix is a symmetric matrix.static MatrixPredicateTRIDIAGONAL_MATRIXChecks whether the matrix is a tridiagonal matrix.static MatrixPredicateUPPER_BIDIAGONAL_MATRIXChecks whether the matrix is an upper bidiagonal matrix.static MatrixPredicateUPPER_TRIANGULAR_MATRIXChecks whether the matrix is an upper triangular matrix.static MatrixPredicateZERO_MATRIXChecks 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 MatrixProcedureasAccumulatorProcedure(MatrixAccumulator accumulator)Creates an accumulator procedure that adapts a matrix accumulator for procedure interface.static MatrixFunctionasConstFunction(double arg)Creates a const function that evaluates it's argument to givenvalue.static MatrixFunctionasDivFunction(double arg)Creates a div function that divides it's argument by givenvalue.static MatrixFunctionasMinusFunction(double arg)Creates a minus function that subtracts givenvaluefrom it's argument.static MatrixFunctionasModFunction(double arg)Creates a mod function that calculates the modulus of it's argument and givenvalue.static MatrixFunctionasMulFunction(double arg)Creates a mul function that multiplies givenvalueby it's argument.static MatrixFunctionasPlusFunction(double arg)Creates a plus function that adds givenvalueto it's argument.static MatrixAccumulatorasProductAccumulator(double neutral)Creates a product matrix accumulator that calculates the product of all elements in the matrix.static MatrixAccumulatorasProductFunctionAccumulator(double neutral, MatrixFunction function)Creates a product function accumulator, that calculates the product of all elements in the matrix after applying givenfunctionto each of them.static MatrixAccumulatorasSumAccumulator(double neutral)Creates a sum matrix accumulator that calculates the sum of all elements in the matrix.static MatrixAccumulatorasSumFunctionAccumulator(double neutral, MatrixFunction function)Creates a sum function accumulator, that calculates the sum of all elements in the matrix after applying givenfunctionto each of them.static MatrixAccumulatormkEuclideanNormAccumulator()Makes an Euclidean norm accumulator that allows to useMatrix.fold(org.la4j.vector.functor.MatrixAccumulator)method for norm calculation.static MatrixAccumulatormkInfinityNormAccumulator()Makes an Infinity norm accumulator that allows to useMatrix.fold(org.la4j.vector.functor.MatrixAccumulator)method for norm calculation.static MatrixAccumulatormkManhattanNormAccumulator()Makes an Manhattan norm accumulator that allows to useMatrix.fold(org.la4j.vector.functor.MatrixAccumulator)method for norm calculation.static MatrixAccumulatormkMaxAccumulator()Makes a maximum matrix accumulator that accumulates the maximum of matrix elements.static MatrixAccumulatormkMinAccumulator()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 givenvalueto 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 givenvaluefrom 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 givenvalueby 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 givenfunctionto 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 givenfunctionto 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
-
-