Class MatrixFeatures_FDRM
- java.lang.Object
-
- org.ejml.dense.row.MatrixFeatures_FDRM
-
public class MatrixFeatures_FDRM extends java.lang.ObjectUsed to compute features that describe the structure of a matrix.
Unless explicitly stated otherwise it is assumed that the elements of input matrices contain only real numbers. If an element is NaN or infinite then the behavior is undefined. See IEEE 754 for more information on this issue.
-
-
Constructor Summary
Constructors Constructor Description MatrixFeatures_FDRM()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcountNonZero(org.ejml.data.FMatrixRMaj A)Counts the number of elements in A which are not zero.static booleanhasNaN(org.ejml.data.FMatrixD1 m)Checks to see if any element in the matrix is NaN.static booleanhasUncountable(org.ejml.data.FMatrixD1 m)Checks to see if any element in the matrix is NaN of Infinite.static booleanisConstantVal(org.ejml.data.FMatrixRMaj mat, float val, float tol)Checks to see if every value in the matrix is the specified value.static booleanisDiagonalPositive(org.ejml.data.FMatrixRMaj a)Checks to see if all the diagonal elements in the matrix are positive.static booleanisEquals(org.ejml.data.BMatrixRMaj a, org.ejml.data.BMatrixRMaj b)Checks to see if each element in the two matrices are equal: aij == bijstatic booleanisEquals(org.ejml.data.FMatrixD1 a, org.ejml.data.FMatrixD1 b)Checks to see if each element in the two matrices are equal: aij == bijstatic booleanisEquals(org.ejml.data.FMatrixD1 a, org.ejml.data.FMatrixD1 b, float tol)Checks to see if each element in the two matrices are within tolerance of each other: tol ≥ |aij - bij|.static booleanisEqualsTriangle(org.ejml.data.FMatrix a, org.ejml.data.FMatrix b, boolean upper, float tol)Checks to see if each element in the upper or lower triangular portion of the two matrices are within tolerance of each other: tol ≥ |aij - bij|.static booleanisFullRank(org.ejml.data.FMatrixRMaj a)static booleanisIdentical(org.ejml.data.FMatrixD1 a, org.ejml.data.FMatrixD1 b, float tol)Checks to see if each corresponding element in the two matrices are within tolerance of each other or have the some symbolic meaning.static booleanisIdentity(org.ejml.data.FMatrixRMaj mat, float tol)Checks to see if the provided matrix is within tolerance to an identity matrix.static booleanisInverse(org.ejml.data.FMatrixRMaj a, org.ejml.data.FMatrixRMaj b, float tol)Checks to see if the two matrices are inverses of each other.static booleanisLowerTriangle(org.ejml.data.FMatrixRMaj A, int hessenberg, float tol)Checks to see if a matrix is lower triangular or Hessenberg.static booleanisNegative(org.ejml.data.FMatrixD1 a, org.ejml.data.FMatrixD1 b, float tol)Checks to see if the two matrices are the negative of each other:
aij = -bijstatic booleanisOrthogonal(org.ejml.data.FMatrixRMaj Q, float tol)Checks to see if a matrix is orthogonal or isometric.static booleanisPositiveDefinite(org.ejml.data.FMatrixRMaj A)Checks to see if the matrix is positive definite.static booleanisPositiveSemidefinite(org.ejml.data.FMatrixRMaj A)Checks to see if the matrix is positive semidefinite:static booleanisRowsLinearIndependent(org.ejml.data.FMatrixRMaj A)Checks to see if the rows of the provided matrix are linearly independent.static booleanisSkewSymmetric(org.ejml.data.FMatrixRMaj A, float tol)Checks to see if a matrix is skew symmetric with in tolerance:
-A = AT
or
|aij + aji| ≤ tolstatic booleanisSquare(org.ejml.data.FMatrixD1 mat)Checks to see if it is a square matrix.static booleanisSymmetric(org.ejml.data.FMatrixRMaj m)Returns true if the matrix is perfectly symmetric.static booleanisSymmetric(org.ejml.data.FMatrixRMaj m, float tol)Returns true if the matrix is symmetric within the tolerance.static booleanisUpperTriangle(org.ejml.data.FMatrixRMaj A, int hessenberg, float tol)Checks to see if a matrix is upper triangular or Hessenberg.static booleanisVector(org.ejml.data.Matrix mat)Checks to see if the matrix is a vector or not.static booleanisZeros(org.ejml.data.FMatrixD1 m, float tol)Checks to see all the elements in the matrix are zerosstatic intnullity(org.ejml.data.FMatrixRMaj A)Computes the nullity of a matrix using the default tolerance.static intnullity(org.ejml.data.FMatrixRMaj A, float threshold)Computes the nullity of a matrix using the specified tolerance.static intrank(org.ejml.data.FMatrixRMaj A)Computes the rank of a matrix using a default tolerance.static intrank(org.ejml.data.FMatrixRMaj A, float threshold)Computes the rank of a matrix using the specified tolerance.
-
-
-
Method Detail
-
hasNaN
public static boolean hasNaN(org.ejml.data.FMatrixD1 m)
Checks to see if any element in the matrix is NaN.- Parameters:
m- A matrix. Not modified.- Returns:
- True if any element in the matrix is NaN.
-
hasUncountable
public static boolean hasUncountable(org.ejml.data.FMatrixD1 m)
Checks to see if any element in the matrix is NaN of Infinite.- Parameters:
m- A matrix. Not modified.- Returns:
- True if any element in the matrix is NaN of Infinite.
-
isZeros
public static boolean isZeros(org.ejml.data.FMatrixD1 m, float tol)Checks to see all the elements in the matrix are zeros- Parameters:
m- A matrix. Not modified.- Returns:
- True if all elements are zeros or false if not
-
isVector
public static boolean isVector(org.ejml.data.Matrix mat)
Checks to see if the matrix is a vector or not.- Parameters:
mat- A matrix. Not modified.- Returns:
- True if it is a vector and false if it is not.
-
isPositiveDefinite
public static boolean isPositiveDefinite(org.ejml.data.FMatrixRMaj A)
Checks to see if the matrix is positive definite.
xT A x > 0
for all x where x is a non-zero vector and A is a symmetric matrix.- Parameters:
A- square symmetric matrix. Not modified.- Returns:
- True if it is positive definite and false if it is not.
-
isPositiveSemidefinite
public static boolean isPositiveSemidefinite(org.ejml.data.FMatrixRMaj A)
Checks to see if the matrix is positive semidefinite:
xT A x ≥ 0
for all x where x is a non-zero vector and A is a symmetric matrix.- Parameters:
A- square symmetric matrix. Not modified.- Returns:
- True if it is positive semidefinite and false if it is not.
-
isSquare
public static boolean isSquare(org.ejml.data.FMatrixD1 mat)
Checks to see if it is a square matrix. A square matrix has the same number of rows and columns.- Parameters:
mat- A matrix. Not modified.- Returns:
- True if it is a square matrix and false if it is not.
-
isSymmetric
public static boolean isSymmetric(org.ejml.data.FMatrixRMaj m, float tol)Returns true if the matrix is symmetric within the tolerance. Only square matrices can be symmetric.
A matrix is symmetric if:
|aij - aji| ≤ tol- Parameters:
m- A matrix. Not modified.tol- Tolerance for how similar two elements need to be.- Returns:
- true if it is symmetric and false if it is not.
-
isSymmetric
public static boolean isSymmetric(org.ejml.data.FMatrixRMaj m)
Returns true if the matrix is perfectly symmetric. Only square matrices can be symmetric.
A matrix is symmetric if:
aij == aji- Parameters:
m- A matrix. Not modified.- Returns:
- true if it is symmetric and false if it is not.
-
isSkewSymmetric
public static boolean isSkewSymmetric(org.ejml.data.FMatrixRMaj A, float tol)Checks to see if a matrix is skew symmetric with in tolerance:
-A = AT
or
|aij + aji| ≤ tol- Parameters:
A- The matrix being tested.tol- Tolerance for being skew symmetric.- Returns:
- True if it is skew symmetric and false if it is not.
-
isInverse
public static boolean isInverse(org.ejml.data.FMatrixRMaj a, org.ejml.data.FMatrixRMaj b, float tol)Checks to see if the two matrices are inverses of each other.- Parameters:
a- A matrix. Not modified.b- A matrix. Not modified.
-
isEquals
public static boolean isEquals(org.ejml.data.FMatrixD1 a, org.ejml.data.FMatrixD1 b, float tol)Checks to see if each element in the two matrices are within tolerance of each other: tol ≥ |aij - bij|.
NOTE: If any of the elements are not countable then false is returned.
NOTE: If a tolerance of zero is passed in this is equivalent to callingisEquals(FMatrixD1, FMatrixD1)- Parameters:
a- A matrix. Not modified.b- A matrix. Not modified.tol- How close to being identical each element needs to be.- Returns:
- true if equals and false otherwise.
-
isEqualsTriangle
public static boolean isEqualsTriangle(org.ejml.data.FMatrix a, org.ejml.data.FMatrix b, boolean upper, float tol)Checks to see if each element in the upper or lower triangular portion of the two matrices are within tolerance of each other: tol ≥ |aij - bij|.
NOTE: If any of the elements are not countable then false is returned.
NOTE: If a tolerance of zero is passed in this is equivalent to callingisEquals(FMatrixD1, FMatrixD1)- Parameters:
a- A matrix. Not modified.b- A matrix. Not modified.upper- true of upper triangular and false for lower.tol- How close to being identical each element needs to be.- Returns:
- true if equals and false otherwise.
-
isEquals
public static boolean isEquals(org.ejml.data.FMatrixD1 a, org.ejml.data.FMatrixD1 b)Checks to see if each element in the two matrices are equal: aij == bij
NOTE: If any of the elements are NaN then false is returned. If two corresponding elements are both positive or negative infinity then they are equal.
- Parameters:
a- A matrix. Not modified.b- A matrix. Not modified.- Returns:
- true if identical and false otherwise.
-
isEquals
public static boolean isEquals(org.ejml.data.BMatrixRMaj a, org.ejml.data.BMatrixRMaj b)Checks to see if each element in the two matrices are equal: aij == bij
NOTE: If any of the elements are NaN then false is returned. If two corresponding elements are both positive or negative infinity then they are equal.
- Parameters:
a- A matrix. Not modified.b- A matrix. Not modified.- Returns:
- true if identical and false otherwise.
-
isIdentical
public static boolean isIdentical(org.ejml.data.FMatrixD1 a, org.ejml.data.FMatrixD1 b, float tol)Checks to see if each corresponding element in the two matrices are within tolerance of each other or have the some symbolic meaning. This can handle NaN and Infinite numbers.
If both elements are countable then the following equality test is used:
|aij - bij| ≤ tol.
Otherwise both numbers must both be Float.NaN, Float.POSITIVE_INFINITY, or Float.NEGATIVE_INFINITY to be identical.- Parameters:
a- A matrix. Not modified.b- A matrix. Not modified.tol- Tolerance for equality.- Returns:
- true if identical and false otherwise.
-
isOrthogonal
public static boolean isOrthogonal(org.ejml.data.FMatrixRMaj Q, float tol)Checks to see if a matrix is orthogonal or isometric.
- Parameters:
Q- The matrix being tested. Not modified.tol- Tolerance.- Returns:
- True if it passes the test.
-
isRowsLinearIndependent
public static boolean isRowsLinearIndependent(org.ejml.data.FMatrixRMaj A)
Checks to see if the rows of the provided matrix are linearly independent.- Parameters:
A- Matrix whose rows are being tested for linear independence.- Returns:
- true if linearly independent and false otherwise.
-
isIdentity
public static boolean isIdentity(org.ejml.data.FMatrixRMaj mat, float tol)Checks to see if the provided matrix is within tolerance to an identity matrix.- Parameters:
mat- Matrix being examined. Not modified.tol- Tolerance.- Returns:
- True if it is within tolerance to an identify matrix.
-
isConstantVal
public static boolean isConstantVal(org.ejml.data.FMatrixRMaj mat, float val, float tol)Checks to see if every value in the matrix is the specified value.- Parameters:
mat- The matrix being tested. Not modified.val- Checks to see if every element in the matrix has this value.tol- True if all the elements are within this tolerance.- Returns:
- true if the test passes.
-
isDiagonalPositive
public static boolean isDiagonalPositive(org.ejml.data.FMatrixRMaj a)
Checks to see if all the diagonal elements in the matrix are positive.- Parameters:
a- A matrix. Not modified.- Returns:
- true if all the diagonal elements are positive, false otherwise.
-
isFullRank
public static boolean isFullRank(org.ejml.data.FMatrixRMaj a)
-
isNegative
public static boolean isNegative(org.ejml.data.FMatrixD1 a, org.ejml.data.FMatrixD1 b, float tol)Checks to see if the two matrices are the negative of each other:
aij = -bij- Parameters:
a- First matrix. Not modified.b- Second matrix. Not modified.tol- Numerical tolerance.- Returns:
- True if they are the negative of each other within tolerance.
-
isUpperTriangle
public static boolean isUpperTriangle(org.ejml.data.FMatrixRMaj A, int hessenberg, float tol)Checks to see if a matrix is upper triangular or Hessenberg. A Hessenberg matrix of degree N has the following property:
aij ≤ 0 for all i < j+N
A triangular matrix is a Hessenberg matrix of degree 0.- Parameters:
A- Matrix being tested. Not modified.hessenberg- The degree of being hessenberg.tol- How close to zero the lower left elements need to be.- Returns:
- If it is an upper triangular/hessenberg matrix or not.
-
isLowerTriangle
public static boolean isLowerTriangle(org.ejml.data.FMatrixRMaj A, int hessenberg, float tol)Checks to see if a matrix is lower triangular or Hessenberg. A Hessenberg matrix of degree N has the following property:
aij ≤ 0 for all i < j+N
A triangular matrix is a Hessenberg matrix of degree 0.- Parameters:
A- Matrix being tested. Not modified.hessenberg- The degree of being hessenberg.tol- How close to zero the lower left elements need to be.- Returns:
- If it is an upper triangular/hessenberg matrix or not.
-
rank
public static int rank(org.ejml.data.FMatrixRMaj A)
Computes the rank of a matrix using a default tolerance.- Parameters:
A- Matrix whose rank is to be calculated. Not modified.- Returns:
- The matrix's rank.
-
rank
public static int rank(org.ejml.data.FMatrixRMaj A, float threshold)Computes the rank of a matrix using the specified tolerance.- Parameters:
A- Matrix whose rank is to be calculated. Not modified.threshold- The numerical threshold used to determine a singular value.- Returns:
- The matrix's rank.
-
nullity
public static int nullity(org.ejml.data.FMatrixRMaj A)
Computes the nullity of a matrix using the default tolerance.- Parameters:
A- Matrix whose rank is to be calculated. Not modified.- Returns:
- The matrix's nullity.
-
nullity
public static int nullity(org.ejml.data.FMatrixRMaj A, float threshold)Computes the nullity of a matrix using the specified tolerance.- Parameters:
A- Matrix whose rank is to be calculated. Not modified.threshold- The numerical threshold used to determine a singular value.- Returns:
- The matrix's nullity.
-
countNonZero
public static int countNonZero(org.ejml.data.FMatrixRMaj A)
Counts the number of elements in A which are not zero.- Parameters:
A- A matrix- Returns:
- number of non-zero elements
-
-