Interface RingTensorMixin<T extends RingTensorMixin<T,U,V>,U extends RingTensorMixin<U,U,V>,V extends Ring<V>>
- Type Parameters:
T- Type of this tensor.U- Dense equivalent of this tensor. If this tensor is dense, this should be the same type asTV- Type of an element of this tensor. Satisfiesringaxioms.
- All Superinterfaces:
SemiringTensorMixin<T,,U, V> TensorOverRing<T,,U, V[], V> TensorOverSemiring<T,U, V[], V>
- All Known Subinterfaces:
FieldTensorMixin<T,U, V>
- All Known Implementing Classes:
AbstractCooFieldMatrix,AbstractCooFieldTensor,AbstractCooFieldVector,AbstractCooRingMatrix,AbstractCooRingTensor,AbstractCooRingVector,AbstractCsrFieldMatrix,AbstractCsrRingMatrix,AbstractDenseFieldMatrix,AbstractDenseFieldTensor,AbstractDenseFieldVector,AbstractDenseRingMatrix,AbstractDenseRingTensor,AbstractDenseRingVector,CMatrix,CooCMatrix,CooCTensor,CooCVector,CooFieldMatrix,CooFieldTensor,CooFieldVector,CooRingMatrix,CooRingTensor,CooRingVector,CsrCMatrix,CsrFieldMatrix,CsrRingMatrix,CTensor,CVector,FieldMatrix,FieldTensor,FieldVector,RingMatrix,RingTensor,RingVector
public interface RingTensorMixin<T extends RingTensorMixin<T,U,V>,U extends RingTensorMixin<U,U,V>,V extends Ring<V>>
extends TensorOverRing<T,U,V[],V>, SemiringTensorMixin<T,U,V>
This interface provides default functionality for all tensors whose data are elements of a Ring. This includes both
sparse and dense tensors.
The default methods in this interface can be overridden if desired, but it is generally recommended to use them as is.
-
Method Summary
Modifier and TypeMethodDescriptiondefault TAdds a scalar value to each entry of this tensor.default voidAdds a scalar value to each entry of this tensor and stores the result in this tensor.default int[]argmax()Finds the indices of the maximum value in this tensor.default int[]Finds the indices of the maximum absolute value in this tensor.default int[]argmin()Finds the indices of the minimum value in this tensor.default int[]Finds the indices of the minimum absolute value in this tensor.default Tconj()Computes the element-wise conjugation of this tensor.default booleanisOnes()Checks if this tensor only contains ones.default booleanisZeros()Checks if this tensor only contains zeros.default V[]makeEmptyDataArray(int length) Creates an empty array of the same type as the data array of this tensor.default Vmax()Finds the maximum value in this tensor.default doublemaxAbs()Finds the maximum absolute value in this tensor.default Vmin()Finds the minimum value in this tensor.default doubleminAbs()Finds the minimum value, in absolute value, in this tensor.default TMultiplies a scalar value to each entry of this tensor.default voidMultiplies a scalar value to each entry of this tensor and stores the result in this tensor.default doublenorm()Computes the Euclidean norm of this vector.default doublenorm(double p) Computes the p-norm of this vector.default Vprod()Computes the product of all values in this tensor (or non-zero values if this tensor is sparse).default TSubtracts a scalar value from each entry of this tensor.default voidSubtracts a scalar value from each entry of this tensor and stores the result in this tensor.default Vsum()Computes the sum of all values in this tensor.
-
Method Details
-
makeEmptyDataArray
Creates an empty array of the same type as the data array of this tensor.- Specified by:
makeEmptyDataArrayin interfaceSemiringTensorMixin<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>> - Parameters:
length- The length of the array to construct.- Returns:
- An empty array of the same type as the data array of this tensor.
-
sub
Subtracts a scalar value from each entry of this tensor. -
subEq
Subtracts a scalar value from each entry of this tensor and stores the result in this tensor. -
conj
-
min
Finds the minimum value in this tensor. If this tensor is complex, then this method finds the smallest value in magnitude.- Specified by:
minin interfaceSemiringTensorMixin<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>> - Specified by:
minin interfaceTensorOverRing<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>[], V extends Ring<V>> - Returns:
- The minimum value (smallest in magnitude for a complex valued tensor) in this tensor.
-
max
Finds the maximum value in this tensor. If this tensor is complex, then this method finds the largest value in magnitude.- Specified by:
maxin interfaceSemiringTensorMixin<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>> - Specified by:
maxin interfaceTensorOverRing<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>[], V extends Ring<V>> - Returns:
- The maximum value (largest in magnitude for a complex valued tensor) in this tensor.
-
argmin
default int[] argmin()Finds the indices of the minimum value in this tensor.- Specified by:
argminin interfaceSemiringTensorMixin<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>> - Specified by:
argminin interfaceTensorOverRing<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>[], V extends Ring<V>> - Returns:
- The indices of the minimum value in this tensor. If this value occurs multiple times, the indices of the first entry (in row-major ordering) are returned.
-
argmax
default int[] argmax()Finds the indices of the maximum value in this tensor.- Specified by:
argmaxin interfaceSemiringTensorMixin<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>> - Specified by:
argmaxin interfaceTensorOverRing<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>[], V extends Ring<V>> - Returns:
- The indices of the maximum value in this tensor. If this value occurs multiple times, the indices of the first entry (in row-major ordering) are returned.
-
argminAbs
default int[] argminAbs()Finds the indices of the minimum absolute value in this tensor.- Specified by:
argminAbsin interfaceTensorOverRing<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>[], V extends Ring<V>> - Returns:
- The indices of the minimum value in this tensor. If this value occurs multiple times, the indices of the first entry (in row-major ordering) are returned.
-
argmaxAbs
default int[] argmaxAbs()Finds the indices of the maximum absolute value in this tensor.- Specified by:
argmaxAbsin interfaceTensorOverRing<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>[], V extends Ring<V>> - Returns:
- The indices of the maximum value in this tensor. If this value occurs multiple times, the indices of the first entry (in row-major ordering) are returned.
-
minAbs
default double minAbs()Finds the minimum value, in absolute value, in this tensor. -
maxAbs
-
add
Adds a scalar value to each entry of this tensor. If the tensor is sparse, the scalar will only be added to the non-zero data of the tensor.- Specified by:
addin interfaceSemiringTensorMixin<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>> - Specified by:
addin interfaceTensorOverSemiring<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>[], V extends Ring<V>> - Parameters:
b- Scalar field value in sum.- Returns:
- The sum of this tensor with the scalar
b.
-
addEq
Adds a scalar value to each entry of this tensor and stores the result in this tensor.- Specified by:
addEqin interfaceSemiringTensorMixin<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>> - Specified by:
addEqin interfaceTensorOverSemiring<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>[], V extends Ring<V>> - Parameters:
b- Scalar field value in sum.
-
mult
Multiplies a scalar value to each entry of this tensor.- Specified by:
multin interfaceSemiringTensorMixin<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>> - Specified by:
multin interfaceTensorOverSemiring<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>[], V extends Ring<V>> - Parameters:
b- Scalar value in product.- Returns:
- The product of this tensor with
b.
-
multEq
Multiplies a scalar value to each entry of this tensor and stores the result in this tensor.- Specified by:
multEqin interfaceSemiringTensorMixin<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>> - Specified by:
multEqin interfaceTensorOverSemiring<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>[], V extends Ring<V>> - Parameters:
b- Scalar value in product.
-
isZeros
default boolean isZeros()Checks if this tensor only contains zeros.- Specified by:
isZerosin interfaceSemiringTensorMixin<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>> - Specified by:
isZerosin interfaceTensorOverSemiring<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>[], V extends Ring<V>> - Returns:
trueif this tensor only contains zeros;falseotherwise.
-
isOnes
default boolean isOnes()Checks if this tensor only contains ones. If this tensor is sparse, only the non-zero data are considered.- Specified by:
isOnesin interfaceSemiringTensorMixin<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>> - Specified by:
isOnesin interfaceTensorOverSemiring<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>[], V extends Ring<V>> - Returns:
trueif this tensor only contains ones;falseotherwise.
-
sum
Computes the sum of all values in this tensor.- Specified by:
sumin interfaceSemiringTensorMixin<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>> - Specified by:
sumin interfaceTensorOverSemiring<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>[], V extends Ring<V>> - Returns:
- The sum of all values in this tensor.
-
prod
Computes the product of all values in this tensor (or non-zero values if this tensor is sparse).- Specified by:
prodin interfaceSemiringTensorMixin<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>> - Specified by:
prodin interfaceTensorOverSemiring<T extends RingTensorMixin<T,U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>[], V extends Ring<V>> - Returns:
- The product of all values (or non-zero values if sparse) in this tensor.
-
norm
default double norm()Computes the Euclidean norm of this vector.- Returns:
- The Euclidean norm of this vector.
-
norm
default double norm(double p) Computes the p-norm of this vector.- Parameters:
p-pvalue in the p-norm.- Returns:
- The Euclidean norm of this vector.
-