public class FloatProperty extends PersistentObject
Except where explicitly indicated, all methods involving equality tests (
==) allow for numerical instability, to a degree specified upon
instance construction and returned by method tolerance()
. The public
static final variable DEFAULT represents a default Property object
with a tolerance of 1.0E-5. The public static final variable
ZERO represents a Property object with a tolerance of 0.0.
The public static final variable SEVEN represents a Property object
with a tolerance of 1.0E-7. As long as you are happy with these
tolerances, there is no need to construct Property objects. Simply use idioms
like Property.DEFAULT.equals(A,B),
Property.ZERO.equals(A,B), Property.SEVEN.equals(A,B).
To work with a different tolerance (e.g. 1.0E-2) use the constructor
and/or method setTolerance(float)
. Note that the public static final
Property objects are immutable: Is is not possible to alter their tolerance.
Any attempt to do so will throw an Exception.
Note that this implementation is not synchronized.
Example: equals(FloatMatrix2D A, FloatMatrix2D B) is defined as follows
{ some other tests not related to tolerance go here } float epsilon = tolerance(); for (int row=rows; --row >= 0;) { for (int column=columns; --column >= 0;) { //if (!(A.getQuick(row,column) == B.getQuick(row,column))) return false; if (Math.abs(A.getQuick(row,column) - B.getQuick(row,column)) > epsilon) return false; } } return true; |
matrix | 4 x 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
4 x 4 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 |
4 x 4 1 1 0 0 1 1 1 0 0 1 1 1 0 0 1 1 |
4 x 4 0 1 1 1 0 1 1 1 0 0 0 1 0 0 0 1 |
4 x 4 0 0 0 0 1 1 0 0 1 1 0 0 1 1 1 1 |
4 x 4 1 1 0 0 0 1 1 0 0 1 0 1 1 0 1 1 |
4 x 4 1 1 1 0 0 1 0 0 1 1 0 1 0 0 1 1 |
upperBandwidth | 0 |
0 |
1 |
3 | 0 | 1 |
2 |
lowerBandwidth | 0 |
0 |
1 |
0 | 3 | 3 |
2 |
semiBandwidth | 1 |
1 |
2 |
4 | 4 | 4 |
3 |
description | zero |
diagonal |
tridiagonal |
upper triangular | lower triangular | unstructured
|
unstructured
|
Modifier and Type | Field and Description |
---|---|
static FloatProperty |
DEFAULT
The default Property object; currently has tolerance()==1.0E-5.
|
static FloatProperty |
SEVEN
A Property object with tolerance()==1.0E-7.
|
static FloatProperty |
ZERO
A Property object with tolerance()==0.0.
|
Constructor and Description |
---|
FloatProperty(float newTolerance)
Constructs an instance with a tolerance of
Math.abs(newTolerance).
|
Modifier and Type | Method and Description |
---|---|
void |
checkDense(FloatMatrix1D A) |
void |
checkDense(FloatMatrix2D A) |
void |
checkRectangular(FloatMatrix2D A)
Checks whether the given matrix A is rectangular.
|
void |
checkSparse(FloatMatrix1D A) |
void |
checkSparse(FloatMatrix2D A) |
void |
checkSquare(FloatMatrix2D A)
Checks whether the given matrix A is square.
|
float |
density(FloatMatrix2D A)
Returns the matrix's fraction of non-zero cells;
A.cardinality() / A.size().
|
boolean |
equals(FloatMatrix1D A,
float value)
Returns whether all cells of the given matrix A are equal to the
given value.
|
boolean |
equals(FloatMatrix1D A,
FloatMatrix1D B)
Returns whether both given matrices A and B are equal.
|
boolean |
equals(FloatMatrix2D A,
float value)
Returns whether all cells of the given matrix A are equal to the
given value.
|
boolean |
equals(FloatMatrix2D A,
FloatMatrix2D B)
Returns whether both given matrices A and B are equal.
|
boolean |
equals(FloatMatrix3D A,
float value)
Returns whether all cells of the given matrix A are equal to the
given value.
|
boolean |
equals(FloatMatrix3D A,
FloatMatrix3D B)
Returns whether both given matrices A and B are equal.
|
void |
generateNonSingular(FloatMatrix2D A)
Modifies the given matrix square matrix A such that it is
diagonally dominant by row and column, hence non-singular, hence
invertible.
|
boolean |
isDiagonal(FloatMatrix2D A)
A matrix A is diagonal if A[i,j] == 0 whenever
i != j.
|
boolean |
isDiagonallyDominantByColumn(FloatMatrix2D 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.
|
boolean |
isDiagonallyDominantByRow(FloatMatrix2D 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.
|
boolean |
isIdentity(FloatMatrix2D A)
A matrix A is an identity matrix if A[i,i] == 1
and all other cells are zero.
|
boolean |
isLowerBidiagonal(FloatMatrix2D A)
A matrix A is lower bidiagonal if A[i,j]==0
unless i==j || i==j+1.
|
boolean |
isLowerTriangular(FloatMatrix2D A)
A matrix A is lower triangular if A[i,j]==0
whenever i < j.
|
boolean |
isNonNegative(FloatMatrix2D A)
A matrix A is non-negative if A[i,j] >= 0
holds for all cells.
|
boolean |
isOrthogonal(FloatMatrix2D A)
A square matrix A is orthogonal if
A*transpose(A) = I.
|
boolean |
isPositive(FloatMatrix2D A)
A matrix A is positive if A[i,j] > 0 holds
for all cells.
|
boolean |
isSingular(FloatMatrix2D A)
A matrix A is singular if it has no inverse, that is, iff
det(A)==0.
|
boolean |
isSkewSymmetric(FloatMatrix2D A)
A square matrix A is skew-symmetric if
A = -transpose(A), that is A[i,j] == -A[j,i].
|
boolean |
isSquare(FloatMatrix2D A)
A matrix A is square if it has the same number of rows
and columns.
|
boolean |
isStrictlyLowerTriangular(FloatMatrix2D A)
A matrix A is strictly lower triangular if
A[i,j]==0 whenever i <= j.
|
boolean |
isStrictlyTriangular(FloatMatrix2D A)
A matrix A is strictly triangular if it is triangular and
its diagonal elements all equal 0.
|
boolean |
isStrictlyUpperTriangular(FloatMatrix2D A)
A matrix A is strictly upper triangular if
A[i,j]==0 whenever i >= j.
|
boolean |
isSymmetric(FloatMatrix2D A)
A matrix A is symmetric if A = tranpose(A), that
is A[i,j] == A[j,i].
|
boolean |
isTriangular(FloatMatrix2D A)
A matrix A is triangular iff it is either upper or lower
triangular.
|
boolean |
isTridiagonal(FloatMatrix2D A)
A matrix A is tridiagonal if A[i,j]==0 whenever
Math.abs(i-j) > 1.
|
boolean |
isUnitTriangular(FloatMatrix2D A)
A matrix A is unit triangular if it is triangular and its
diagonal elements all equal 1.
|
boolean |
isUpperBidiagonal(FloatMatrix2D A)
A matrix A is upper bidiagonal if A[i,j]==0
unless i==j || i==j-1.
|
boolean |
isUpperTriangular(FloatMatrix2D A)
A matrix A is upper triangular if A[i,j]==0
whenever i > j.
|
boolean |
isZero(FloatMatrix2D A)
A matrix A is zero if all its cells are zero.
|
int |
lowerBandwidth(FloatMatrix2D A)
The lower bandwidth of a square matrix A is the maximum
i-j for which A[i,j] is nonzero and i > j.
|
int |
semiBandwidth(FloatMatrix2D A)
Returns the semi-bandwidth of the given square matrix A.
|
void |
setTolerance(float newTolerance)
Sets the tolerance to Math.abs(newTolerance).
|
float |
tolerance()
Returns the current tolerance.
|
String |
toString(FloatMatrix2D A)
Returns summary information about the given matrix A.
|
int |
upperBandwidth(FloatMatrix2D A)
The upper bandwidth of a square matrix A is the maximum
j-i for which A[i,j] is nonzero and j > i.
|
clone
public static final FloatProperty DEFAULT
public static final FloatProperty ZERO
public static final FloatProperty SEVEN
public FloatProperty(float newTolerance)
public void checkRectangular(FloatMatrix2D A)
IllegalArgumentException
- if A.rows() < A.columns().public void checkSquare(FloatMatrix2D A)
IllegalArgumentException
- if A.rows() != A.columns().public void checkDense(FloatMatrix2D A)
public void checkDense(FloatMatrix1D A)
public void checkSparse(FloatMatrix1D A)
public void checkSparse(FloatMatrix2D A)
public float density(FloatMatrix2D A)
public boolean equals(FloatMatrix1D A, float value)
A
- the first matrix to compare.value
- the value to compare against.public boolean equals(FloatMatrix1D A, FloatMatrix1D B)
A
- the first matrix to compare.B
- the second matrix to compare.public boolean equals(FloatMatrix2D A, float value)
A
- the first matrix to compare.value
- the value to compare against.public boolean equals(FloatMatrix2D A, FloatMatrix2D B)
A
- the first matrix to compare.B
- the second matrix to compare.public boolean equals(FloatMatrix3D A, float value)
A
- the first matrix to compare.value
- the value to compare against.public boolean equals(FloatMatrix3D A, FloatMatrix3D B)
A
- the first matrix to compare.B
- the second matrix to compare.public void generateNonSingular(FloatMatrix2D A)
A
- the square matrix to modify.IllegalArgumentException
- if !isSquare(A).public boolean isDiagonal(FloatMatrix2D A)
public boolean isDiagonallyDominantByColumn(FloatMatrix2D A)
Note: Ignores tolerance.
public boolean isDiagonallyDominantByRow(FloatMatrix2D A)
Note: Ignores tolerance.
public boolean isIdentity(FloatMatrix2D A)
public boolean isLowerBidiagonal(FloatMatrix2D A)
public boolean isLowerTriangular(FloatMatrix2D A)
public boolean isNonNegative(FloatMatrix2D A)
Note: Ignores tolerance.
public boolean isOrthogonal(FloatMatrix2D A)
IllegalArgumentException
- if !isSquare(A).public boolean isPositive(FloatMatrix2D A)
Note: Ignores tolerance.
public boolean isSingular(FloatMatrix2D A)
public boolean isSkewSymmetric(FloatMatrix2D A)
IllegalArgumentException
- if !isSquare(A).public boolean isSquare(FloatMatrix2D A)
public boolean isStrictlyLowerTriangular(FloatMatrix2D A)
public boolean isStrictlyTriangular(FloatMatrix2D A)
public boolean isStrictlyUpperTriangular(FloatMatrix2D A)
public boolean isSymmetric(FloatMatrix2D A)
IllegalArgumentException
- if !isSquare(A).public boolean isTriangular(FloatMatrix2D A)
public boolean isTridiagonal(FloatMatrix2D A)
public boolean isUnitTriangular(FloatMatrix2D A)
public boolean isUpperBidiagonal(FloatMatrix2D A)
public boolean isUpperTriangular(FloatMatrix2D A)
public boolean isZero(FloatMatrix2D A)
public int lowerBandwidth(FloatMatrix2D A)
A
- the square matrix to analyze.IllegalArgumentException
- if !isSquare(A).semiBandwidth(FloatMatrix2D)
,
upperBandwidth(FloatMatrix2D)
public int semiBandwidth(FloatMatrix2D A)
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 0 |
4 x 4 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 |
4 x 4 1 1 0 0 1 1 1 0 0 1 1 1 0 0 1 1 |
4 x 4 0 1 1 1 0 1 1 1 0 0 0 1 0 0 0 1 |
4 x 4 0 0 0 0 1 1 0 0 1 1 0 0 1 1 1 1 |
4 x 4 1 1 0 0 0 1 1 0 0 1 0 1 1 0 1 1 |
4 x 4 1 1 1 0 0 1 0 0 1 1 0 1 0 0 1 1 |
upperBandwidth | 0 |
0 |
1 |
3 | 0 | 1 |
2 |
lowerBandwidth | 0 |
0 |
1 |
0 | 3 | 3 |
2 |
semiBandwidth | 1 |
1 |
2 |
4 | 4 | 4 |
3 |
description | zero |
diagonal |
tridiagonal |
upper triangular | lower triangular |
unstructured |
unstructured |
A
- the square matrix to analyze.IllegalArgumentException
- if !isSquare(A).lowerBandwidth(FloatMatrix2D)
,
upperBandwidth(FloatMatrix2D)
public void setTolerance(float newTolerance)
UnsupportedOperationException
- if this==DEFAULT || this==ZERO || this==TWELVE.public float tolerance()
public String toString(FloatMatrix2D A)
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.
public int upperBandwidth(FloatMatrix2D A)
A
- the square matrix to analyze.IllegalArgumentException
- if !isSquare(A).semiBandwidth(FloatMatrix2D)
,
lowerBandwidth(FloatMatrix2D)
Jump to the Parallel Colt Homepage