cern.colt.matrix.tint.algo
Class IntProperty
- java.lang.Object
-
- cern.colt.PersistentObject
-
- cern.colt.matrix.tint.algo.IntProperty
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable
public class IntProperty extends PersistentObject
Tests matrices for linear algebraic properties (equality, tridiagonality, symmetry, singularity, etc).Note that this implementation is not synchronized.
Here are some example properties
matrix 4 x 4
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 04 x 4
1 0 0 0
0 0 0 0
0 0 0 0
0 0 0 14 x 4
1 1 0 0
1 1 1 0
0 1 1 1
0 0 1 14 x 4
0 1 1 1
0 1 1 1
0 0 0 1
0 0 0 14 x 4
0 0 0 0
1 1 0 0
1 1 0 0
1 1 1 14 x 4
1 1 0 0
0 1 1 0
0 1 0 1
1 0 1 14 x 4
1 1 1 0
0 1 0 0
1 1 0 1
0 0 1 1upperBandwidth 0013 0 12lowerBandwidth 0010 3 32semiBandwidth 1124 4 43description zerodiagonaltridiagonalupper triangular lower triangular unstructuredunstructured- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static IntPropertyDEFAULTThe default Property object;.
-
Constructor Summary
Constructors Constructor and Description IntProperty()Constructs an instance with a tolerance of Math.abs(newTolerance).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidcheckRectangular(IntMatrix2D A)Checks whether the given matrix A is rectangular.voidcheckSquare(IntMatrix2D A)Checks whether the given matrix A is square.intdensity(IntMatrix2D A)Returns the matrix's fraction of non-zero cells; A.cardinality() / A.size().booleanequals(IntMatrix1D A, int value)Returns whether all cells of the given matrix A are equal to the given value.booleanequals(IntMatrix1D A, IntMatrix1D B)Returns whether both given matrices A and B are equal.booleanequals(IntMatrix2D A, int value)Returns whether all cells of the given matrix A are equal to the given value.booleanequals(IntMatrix2D A, IntMatrix2D B)Returns whether both given matrices A and B are equal.booleanequals(IntMatrix3D A, int value)Returns whether all cells of the given matrix A are equal to the given value.booleanequals(IntMatrix3D A, IntMatrix3D B)Returns whether both given matrices A and B are equal.voidgenerateNonSingular(IntMatrix2D A)Modifies the given matrix square matrix A such that it is diagonally dominant by row and column, hence non-singular, hence invertible.booleanisDiagonal(IntMatrix2D A)A matrix A is diagonal if A[i,j] == 0 whenever i != j.booleanisDiagonallyDominantByColumn(IntMatrix2D A)A matrix A is diagonally dominant by column if the absolute value of each diagonal element is larger than the sum of the absolute values of the off-diagonal elements in the corresponding column.booleanisDiagonallyDominantByRow(IntMatrix2D A)A matrix A is diagonally dominant by row if the absolute value of each diagonal element is larger than the sum of the absolute values of the off-diagonal elements in the corresponding row.booleanisIdentity(IntMatrix2D A)A matrix A is an identity matrix if A[i,i] == 1 and all other cells are zero.booleanisLowerBidiagonal(IntMatrix2D A)A matrix A is lower bidiagonal if A[i,j]==0 unless i==j || i==j+1.booleanisLowerTriangular(IntMatrix2D A)A matrix A is lower triangular if A[i,j]==0 whenever i < j.booleanisNonNegative(IntMatrix2D A)A matrix A is non-negative if A[i,j] >= 0 holds for all cells.booleanisOrthogonal(IntMatrix2D A)A square matrix A is orthogonal if A*transpose(A) = I.booleanisPositive(IntMatrix2D A)A matrix A is positive if A[i,j] > 0 holds for all cells.booleanisSkewSymmetric(IntMatrix2D A)A square matrix A is skew-symmetric if A = -transpose(A), that is A[i,j] == -A[j,i].booleanisSquare(IntMatrix2D A)A matrix A is square if it has the same number of rows and columns.booleanisStrictlyLowerTriangular(IntMatrix2D A)A matrix A is strictly lower triangular if A[i,j]==0 whenever i <= j.booleanisStrictlyTriangular(IntMatrix2D A)A matrix A is strictly triangular if it is triangular and its diagonal elements all equal 0.booleanisStrictlyUpperTriangular(IntMatrix2D A)A matrix A is strictly upper triangular if A[i,j]==0 whenever i >= j.booleanisSymmetric(IntMatrix2D A)A matrix A is symmetric if A = tranpose(A), that is A[i,j] == A[j,i].booleanisTriangular(IntMatrix2D A)A matrix A is triangular iff it is either upper or lower triangular.booleanisTridiagonal(IntMatrix2D A)A matrix A is tridiagonal if A[i,j]==0 whenever Math.abs(i-j) > 1.booleanisUnitTriangular(IntMatrix2D A)A matrix A is unit triangular if it is triangular and its diagonal elements all equal 1.booleanisUpperBidiagonal(IntMatrix2D A)A matrix A is upper bidiagonal if A[i,j]==0 unless i==j || i==j-1.booleanisUpperTriangular(IntMatrix2D A)A matrix A is upper triangular if A[i,j]==0 whenever i > j.booleanisZero(IntMatrix2D A)A matrix A is zero if all its cells are zero.intlowerBandwidth(IntMatrix2D A)The lower bandwidth of a square matrix A is the maximum i-j for which A[i,j] is nonzero and i > j.intsemiBandwidth(IntMatrix2D A)Returns the semi-bandwidth of the given square matrix A.java.lang.StringtoString(IntMatrix2D A)Returns summary information about the given matrix A.intupperBandwidth(IntMatrix2D A)The upper bandwidth of a square matrix A is the maximum j-i for which A[i,j] is nonzero and j > i.-
Methods inherited from class cern.colt.PersistentObject
clone
-
-
-
-
Field Detail
-
DEFAULT
public static final IntProperty DEFAULT
The default Property object;.
-
-
Constructor Detail
-
IntProperty
public IntProperty()
Constructs an instance with a tolerance of Math.abs(newTolerance).
-
-
Method Detail
-
checkRectangular
public void checkRectangular(IntMatrix2D A)
Checks whether the given matrix A is rectangular.- Throws:
java.lang.IllegalArgumentException- if A.rows() < A.columns().
-
checkSquare
public void checkSquare(IntMatrix2D A)
Checks whether the given matrix A is square.- Throws:
java.lang.IllegalArgumentException- if A.rows() != A.columns().
-
density
public int density(IntMatrix2D A)
Returns the matrix's fraction of non-zero cells; A.cardinality() / A.size().
-
equals
public boolean equals(IntMatrix1D A, int value)
Returns whether all cells of the given matrix A are equal to the given value. The result is true if and only if A != null and ! (Math.abs(value - A[i]) > tolerance()) holds for all coordinates.- Parameters:
A- the first matrix to compare.value- the value to compare against.- Returns:
- true if the matrix is equal to the value; false otherwise.
-
equals
public boolean equals(IntMatrix1D A, IntMatrix1D B)
Returns whether both given matrices A and B are equal. The result is true if A==B. Otherwise, the result is true if and only if both arguments are != null, have the same size and ! (Math.abs(A[i] - B[i]) > tolerance()) holds for all indexes.- Parameters:
A- the first matrix to compare.B- the second matrix to compare.- Returns:
- true if both matrices are equal; false otherwise.
-
equals
public boolean equals(IntMatrix2D A, int value)
Returns whether all cells of the given matrix A are equal to the given value. The result is true if and only if A != null and ! (Math.abs(value - A[row,col]) > tolerance()) holds for all coordinates.- Parameters:
A- the first matrix to compare.value- the value to compare against.- Returns:
- true if the matrix is equal to the value; false otherwise.
-
equals
public boolean equals(IntMatrix2D A, IntMatrix2D B)
Returns whether both given matrices A and B are equal. The result is true if A==B. Otherwise, the result is true if and only if both arguments are != null, have the same number of columns and rows and ! (Math.abs(A[row,col] - B[row,col]) > tolerance()) holds for all coordinates.- Parameters:
A- the first matrix to compare.B- the second matrix to compare.- Returns:
- true if both matrices are equal; false otherwise.
-
equals
public boolean equals(IntMatrix3D A, int value)
Returns whether all cells of the given matrix A are equal to the given value. The result is true if and only if A != null and ! (Math.abs(value - A[slice,row,col]) > tolerance()) holds for all coordinates.- Parameters:
A- the first matrix to compare.value- the value to compare against.- Returns:
- true if the matrix is equal to the value; false otherwise.
-
equals
public boolean equals(IntMatrix3D A, IntMatrix3D B)
Returns whether both given matrices A and B are equal. The result is true if A==B. Otherwise, the result is true if and only if both arguments are != null, have the same number of columns, rows and slices, and ! (Math.abs(A[slice,row,col] - B[slice,row,col]) > tolerance()) holds for all coordinates.- Parameters:
A- the first matrix to compare.B- the second matrix to compare.- Returns:
- true if both matrices are equal; false otherwise.
-
generateNonSingular
public void generateNonSingular(IntMatrix2D A)
Modifies the given matrix square matrix A such that it is diagonally dominant by row and column, hence non-singular, hence invertible. For testing purposes only.- Parameters:
A- the square matrix to modify.- Throws:
java.lang.IllegalArgumentException- if !isSquare(A).
-
isDiagonal
public boolean isDiagonal(IntMatrix2D A)
A matrix A is diagonal if A[i,j] == 0 whenever i != j. Matrix may but need not be square.
-
isDiagonallyDominantByColumn
public boolean isDiagonallyDominantByColumn(IntMatrix2D A)
A matrix A is diagonally dominant by column if the absolute value of each diagonal element is larger than the sum of the absolute values of the off-diagonal elements in the corresponding column. returns true if for all i: abs(A[i,i]) > Sum(abs(A[j,i])); j != i. Matrix may but need not be square.Note: Ignores tolerance.
-
isDiagonallyDominantByRow
public boolean isDiagonallyDominantByRow(IntMatrix2D A)
A matrix A is diagonally dominant by row if the absolute value of each diagonal element is larger than the sum of the absolute values of the off-diagonal elements in the corresponding row. returns true if for all i: abs(A[i,i]) > Sum(abs(A[i,j])); j != i. Matrix may but need not be square.Note: Ignores tolerance.
-
isIdentity
public boolean isIdentity(IntMatrix2D A)
A matrix A is an identity matrix if A[i,i] == 1 and all other cells are zero. Matrix may but need not be square.
-
isLowerBidiagonal
public boolean isLowerBidiagonal(IntMatrix2D A)
A matrix A is lower bidiagonal if A[i,j]==0 unless i==j || i==j+1. Matrix may but need not be square.
-
isLowerTriangular
public boolean isLowerTriangular(IntMatrix2D A)
A matrix A is lower triangular if A[i,j]==0 whenever i < j. Matrix may but need not be square.
-
isNonNegative
public boolean isNonNegative(IntMatrix2D A)
A matrix A is non-negative if A[i,j] >= 0 holds for all cells.Note: Ignores tolerance.
-
isOrthogonal
public boolean isOrthogonal(IntMatrix2D A)
A square matrix A is orthogonal if A*transpose(A) = I.- Throws:
java.lang.IllegalArgumentException- if !isSquare(A).
-
isPositive
public boolean isPositive(IntMatrix2D A)
A matrix A is positive if A[i,j] > 0 holds for all cells.Note: Ignores tolerance.
-
isSkewSymmetric
public boolean isSkewSymmetric(IntMatrix2D A)
A square matrix A is skew-symmetric if A = -transpose(A), that is A[i,j] == -A[j,i].- Throws:
java.lang.IllegalArgumentException- if !isSquare(A).
-
isSquare
public boolean isSquare(IntMatrix2D A)
A matrix A is square if it has the same number of rows and columns.
-
isStrictlyLowerTriangular
public boolean isStrictlyLowerTriangular(IntMatrix2D A)
A matrix A is strictly lower triangular if A[i,j]==0 whenever i <= j. Matrix may but need not be square.
-
isStrictlyTriangular
public boolean isStrictlyTriangular(IntMatrix2D A)
A matrix A is strictly triangular if it is triangular and its diagonal elements all equal 0. Matrix may but need not be square.
-
isStrictlyUpperTriangular
public boolean isStrictlyUpperTriangular(IntMatrix2D A)
A matrix A is strictly upper triangular if A[i,j]==0 whenever i >= j. Matrix may but need not be square.
-
isSymmetric
public boolean isSymmetric(IntMatrix2D A)
A matrix A is symmetric if A = tranpose(A), that is A[i,j] == A[j,i].- Throws:
java.lang.IllegalArgumentException- if !isSquare(A).
-
isTriangular
public boolean isTriangular(IntMatrix2D A)
A matrix A is triangular iff it is either upper or lower triangular. Matrix may but need not be square.
-
isTridiagonal
public boolean isTridiagonal(IntMatrix2D A)
A matrix A is tridiagonal if A[i,j]==0 whenever Math.abs(i-j) > 1. Matrix may but need not be square.
-
isUnitTriangular
public boolean isUnitTriangular(IntMatrix2D A)
A matrix A is unit triangular if it is triangular and its diagonal elements all equal 1. Matrix may but need not be square.
-
isUpperBidiagonal
public boolean isUpperBidiagonal(IntMatrix2D A)
A matrix A is upper bidiagonal if A[i,j]==0 unless i==j || i==j-1. Matrix may but need not be square.
-
isUpperTriangular
public boolean isUpperTriangular(IntMatrix2D A)
A matrix A is upper triangular if A[i,j]==0 whenever i > j. Matrix may but need not be square.
-
isZero
public boolean isZero(IntMatrix2D A)
A matrix A is zero if all its cells are zero.
-
lowerBandwidth
public int lowerBandwidth(IntMatrix2D A)
The lower bandwidth of a square matrix A is the maximum i-j for which A[i,j] is nonzero and i > j. A banded matrix has a "band" about the diagonal. Diagonal, tridiagonal and triangular matrices are special cases.- Parameters:
A- the square matrix to analyze.- Returns:
- the lower bandwith.
- Throws:
java.lang.IllegalArgumentException- if !isSquare(A).- See Also:
semiBandwidth(IntMatrix2D),upperBandwidth(IntMatrix2D)
-
semiBandwidth
public int semiBandwidth(IntMatrix2D A)
Returns the semi-bandwidth of the given square matrix A. A banded matrix has a "band" about the diagonal. It is a matrix with all cells equal to zero, with the possible exception of the cells along the diagonal line, the k diagonal lines above the diagonal, and the k diagonal lines below the diagonal. The semi-bandwith l is the number k+1. The bandwidth p is the number 2*k + 1. For example, a tridiagonal matrix corresponds to k=1, l=2, p=3, a diagonal or zero matrix corresponds to k=0, l=1, p=1,The upper bandwidth is the maximum j-i for which A[i,j] is nonzero and j > i. The lower bandwidth is the maximum i-j for which A[i,j] is nonzero and i > j. Diagonal, tridiagonal and triangular matrices are special cases.
Examples:
matrix 4 x 4
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 04 x 4
1 0 0 0
0 0 0 0
0 0 0 0
0 0 0 14 x 4
1 1 0 0
1 1 1 0
0 1 1 1
0 0 1 14 x 4
0 1 1 1
0 1 1 1
0 0 0 1
0 0 0 14 x 4
0 0 0 0
1 1 0 0
1 1 0 0
1 1 1 14 x 4
1 1 0 0
0 1 1 0
0 1 0 1
1 0 1 14 x 4
1 1 1 0
0 1 0 0
1 1 0 1
0 0 1 1upperBandwidth 0013 0 12lowerBandwidth 0010 3 32semiBandwidth 1124 4 43description zerodiagonaltridiagonalupper triangular lower triangular unstructuredunstructured- Parameters:
A- the square matrix to analyze.- Returns:
- the semi-bandwith l.
- Throws:
java.lang.IllegalArgumentException- if !isSquare(A).- See Also:
lowerBandwidth(IntMatrix2D),upperBandwidth(IntMatrix2D)
-
toString
public java.lang.String toString(IntMatrix2D A)
Returns summary information about the given matrix A. That is a String with (propertyName, propertyValue) pairs. Useful for debugging or to quickly get the rough picture of a matrix. For example,density : 0.9 isDiagonal : false isDiagonallyDominantByRow : false isDiagonallyDominantByColumn : false isIdentity : false isLowerBidiagonal : false isLowerTriangular : false isNonNegative : true isOrthogonal : Illegal operation or error: Matrix must be square. isPositive : true isSingular : Illegal operation or error: Matrix must be square. isSkewSymmetric : Illegal operation or error: Matrix must be square. isSquare : false isStrictlyLowerTriangular : false isStrictlyTriangular : false isStrictlyUpperTriangular : false isSymmetric : Illegal operation or error: Matrix must be square. isTriangular : false isTridiagonal : false isUnitTriangular : false isUpperBidiagonal : false isUpperTriangular : false isZero : false lowerBandwidth : Illegal operation or error: Matrix must be square. semiBandwidth : Illegal operation or error: Matrix must be square. upperBandwidth : Illegal operation or error: Matrix must be square.
-
upperBandwidth
public int upperBandwidth(IntMatrix2D A)
The upper bandwidth of a square matrix A is the maximum j-i for which A[i,j] is nonzero and j > i. A banded matrix has a "band" about the diagonal. Diagonal, tridiagonal and triangular matrices are special cases.- Parameters:
A- the square matrix to analyze.- Returns:
- the upper bandwith.
- Throws:
java.lang.IllegalArgumentException- if !isSquare(A).- See Also:
semiBandwidth(IntMatrix2D),lowerBandwidth(IntMatrix2D)
-
-
DMelt 3.0 © DataMelt by jWork.ORG