Class CheckerMatrix<T extends Number>
java.lang.Object
util.AbstractChecker<T[][],CheckerMatrix<T>>
specialized_checkers.math.CheckerMatrix<T>
- Type Parameters:
T
- the type of the elements in the matrix being checked (must extendNumber
)
- All Implemented Interfaces:
InterfaceChecker<AbstractChecker<T[][],
CheckerMatrix<T>>, T[][]>
Checker for matrix (2D array) instances, providing fluent validation methods for matrices of any numeric type.
This class allows you to validate and assert properties of matrix objects in a fluent and readable way.
-
Field Summary
Fields inherited from class util.AbstractChecker
backObject, exceptionTracker, name, object, saveErrors, stop
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CheckerMatrix
(T[][] matrix, String name) Constructs a newCheckerMatrix
with the specified matrix and name. -
Method Summary
Modifier and TypeMethodDescriptionAsserts that all elements in the matrix match the provided predicate.Asserts that any element in the matrix matches the provided predicate.static <T extends Number>
CheckerMatrix<T> check
(T[][] matrix) Creates a newCheckerMatrix
for the given matrix instance with a default name.static <T extends Number>
CheckerMatrix<T> Creates a newCheckerMatrix
for the given matrix instance with a custom name.static <T extends Number>
double[][]convertToDoubleMatrix
(T[][] matrix) Converts a matrix of any numeric type to a matrix of doubles.hasRank
(int rank) Asserts that the matrix has the specified rank.Asserts that the matrix has only real eigenvalues.Asserts that the matrix is diagonal (all off-diagonal elements are zero).isEmpty()
Asserts that the matrix is empty (has zero rows or all rows are empty).Asserts that the matrix is full rank (rank equals the minimum of the number of rows and columns).Asserts that the matrix is an identity matrix (ones on the diagonal, zeros elsewhere).Asserts that the matrix is invertible (has a non-zero determinant).Asserts that the matrix is lower triangular (all elements above the main diagonal are zero).Asserts that the matrix is orthogonal (its transpose is its inverse).Asserts that the matrix is positive definite (all eigenvalues are positive).isSquare()
Asserts that the matrix is square (number of rows equals number of columns).Asserts that the matrix is symmetric (equal to its transpose).Asserts that the matrix is upper triangular (all elements below the main diagonal are zero).isZero()
Asserts that the matrix is a zero matrix (all elements are zero).protected CheckerMatrix
<T> self()
Returns this checker instance (for fluent API usage).Methods inherited from class util.AbstractChecker
checkProperty, checkProperty, checkProperty, end, getMethod, getObject, getProperty, hasErrors, hasNotErrors, is, is, isEqual, isNonNull, isNot, isNot, isNull, notSaveErrors, saveErrors, show, showNotThrownException, showThrownException, stop
-
Constructor Details
-
CheckerMatrix
-
-
Method Details
-
check
Creates a newCheckerMatrix
for the given matrix instance with a custom name.- Type Parameters:
T
- the type of the elements in the matrix (must extendNumber
)- Parameters:
matrix
- the matrix instance to be checkedname
- the name to identify this checker instance (useful for error messages)- Returns:
- a new
CheckerMatrix
for the provided matrix
-
check
Creates a newCheckerMatrix
for the given matrix instance with a default name.- Type Parameters:
T
- the type of the elements in the matrix (must extendNumber
)- Parameters:
matrix
- the matrix instance to be checked- Returns:
- a new
CheckerMatrix
for the provided matrix
-
self
Returns this checker instance (for fluent API usage).- Specified by:
self
in classAbstractChecker<T extends Number[][],
CheckerMatrix<T extends Number>> - Returns:
- this
CheckerMatrix
instance
-
isEmpty
Asserts that the matrix is empty (has zero rows or all rows are empty).- Returns:
- this
CheckerMatrix
instance for further validation
-
isSquare
Asserts that the matrix is square (number of rows equals number of columns).- Returns:
- this
CheckerMatrix
instance for further validation
-
isZero
Asserts that the matrix is a zero matrix (all elements are zero).- Returns:
- this
CheckerMatrix
instance for further validation
-
isIdentity
Asserts that the matrix is an identity matrix (ones on the diagonal, zeros elsewhere).- Returns:
- this
CheckerMatrix
instance for further validation
-
isSymmetric
Asserts that the matrix is symmetric (equal to its transpose).- Returns:
- this
CheckerMatrix
instance for further validation
-
isDiagonal
Asserts that the matrix is diagonal (all off-diagonal elements are zero).- Returns:
- this
CheckerMatrix
instance for further validation
-
isOrthogonal
Asserts that the matrix is orthogonal (its transpose is its inverse).- Returns:
- this
CheckerMatrix
instance for further validation
-
isInvertible
Asserts that the matrix is invertible (has a non-zero determinant).- Returns:
- this
CheckerMatrix
instance for further validation
-
isPositiveDefinite
Asserts that the matrix is positive definite (all eigenvalues are positive).- Returns:
- this
CheckerMatrix
instance for further validation
-
isUpperTriangular
Asserts that the matrix is upper triangular (all elements below the main diagonal are zero).- Returns:
- this
CheckerMatrix
instance for further validation
-
isLowerTriangular
Asserts that the matrix is lower triangular (all elements above the main diagonal are zero).- Returns:
- this
CheckerMatrix
instance for further validation
-
hasRank
Asserts that the matrix has the specified rank.- Parameters:
rank
- the expected rank of the matrix- Returns:
- this
CheckerMatrix
instance for further validation
-
hasRealEigenvalues
Asserts that the matrix has only real eigenvalues.- Returns:
- this
CheckerMatrix
instance for further validation
-
isFullRank
Asserts that the matrix is full rank (rank equals the minimum of the number of rows and columns).- Returns:
- this
CheckerMatrix
instance for further validation
-
anyMatch
Asserts that any element in the matrix matches the provided predicate.- Parameters:
predicate
- the predicate to test elements- Returns:
- this
CheckerMatrix
instance for further validation
-
allMatch
Asserts that all elements in the matrix match the provided predicate.- Parameters:
predicate
- the predicate to test elements- Returns:
- this
CheckerMatrix
instance for further validation
-
convertToDoubleMatrix
Converts a matrix of any numeric type to a matrix of doubles.- Type Parameters:
T
- the type of the elements in the matrix (must extendNumber
)- Parameters:
matrix
- the matrix to convert- Returns:
- a new matrix of doubles with the same dimensions as the input
-