Package org.flag4j.core
Interface TensorComparisonsMixin
- All Known Implementing Classes:
CMatrix
,ComplexDenseTensorBase
,ComplexSparseTensorBase
,CooCMatrix
,CooCTensor
,CooCVector
,CooMatrix
,CooTensor
,CooVector
,CsrCMatrix
,CsrMatrix
,CTensor
,CVector
,DenseTensorBase
,Matrix
,RealDenseTensorBase
,RealSparseTensorBase
,SparseTensorBase
,Tensor
,TensorBase
,Vector
public interface TensorComparisonsMixin
This interface specifies comparisons which all tensors (i.e. matrices and vectors) should implement.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if this tensor is equal to a specified Object.boolean
isOnes()
Checks if this tensor only contains ones.boolean
isZeros()
Checks if this tensor only contains zeros.boolean
tensorEquals
(TensorBase<?, ?, ?, ?, ?, ?, ?> B) Checks if two tensors are equal.
-
Method Details
-
isZeros
boolean isZeros()Checks if this tensor only contains zeros.- Returns:
- True if this tensor only contains zeros. Otherwise, returns false.
-
isOnes
boolean isOnes()Checks if this tensor only contains ones.- Returns:
- True if this tensor only contains ones. Otherwise, returns false.
-
equals
Checks if this tensor is equal to a specified Object. Note, this method differs fromtensorEquals(TensorBase)
as, in this method, the types of the objects must match where intensorEquals(TensorBase)
the typed need not match. -
tensorEquals
Checks if two tensors are equal. Note, this method is much more permissive than
equals(Object)
as it allows for comparisons with any tensor, matrix, or vector. If the shapes are equal and entries are element-wise equivalent then this method returns true regardless of the types of the two tensors.xFor Example, a
Dense Tensor
of rank 2 with the same values as aSparse CSR Matrix
will be considered equal.- Parameters:
B
- Tensor, matrix, or vector to compare to this tensor.- Returns:
- True if both tensors (or matrix/vector) have the same shape and all entries are numerically equivalent by index. This accounts for possible zero values in sparse objects. Returns false if the tensors do not have the same shape or if the tensors differ in value at any index.
-