Interface FieldTensorMixin<T extends FieldTensorMixin<T,U,V>,U extends FieldTensorMixin<U,U,V>,V extends Field<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. Satisfiesfieldaxioms.
- All Superinterfaces:
RingTensorMixin<T,,U, V> SemiringTensorMixin<T,,U, V> TensorOverField<T,,U, V[], V> TensorOverRing<T,,U, V[], V> TensorOverSemiring<T,U, V[], V>
- All Known Implementing Classes:
AbstractCooFieldMatrix,AbstractCooFieldTensor,AbstractCooFieldVector,AbstractCsrFieldMatrix,AbstractDenseFieldMatrix,AbstractDenseFieldTensor,AbstractDenseFieldVector,CMatrix,CooCMatrix,CooCTensor,CooCVector,CooFieldMatrix,CooFieldTensor,CooFieldVector,CsrCMatrix,CsrFieldMatrix,CTensor,CVector,FieldMatrix,FieldTensor,FieldVector
public interface FieldTensorMixin<T extends FieldTensorMixin<T,U,V>,U extends FieldTensorMixin<U,U,V>,V extends Field<V>>
extends TensorOverField<T,U,V[],V>, RingTensorMixin<T,U,V>
This interface provides default functionality for all tensors whose data are elements of a
Field. 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 Tadd(double b) Adds a primitive scalar value to each entry of this tensor.default TAdds a scalar value to each entry of this tensor.default voidaddEq(double b) Adds a primitive scalar value to each entry of this tensor and stores the result in 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 Tdiv(double b) Divides each element of this tensor by a primitive scalar value.default TDivides each element of this tensor by a scalar value.default voiddivEq(double b) Divides each element of this tensor by a primitive scalar value and stores the result in this tensor.default voidDivides each element of this tensor by a scalar value and stores the result in 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 Tmult(double b) Multiplies a primitive scalar value to each entry of this tensor.default TMultiplies a scalar value to each entry of this tensor.default voidmultEq(double b) Multiplies a primitive scalar value to each entry of this tensor and stores the result in 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 Trecip()Computes the element-wise reciprocals of this tensor.default Tsub(double b) Subtracts a primitive scalar value from each entry of this tensor.default TSubtracts a scalar value from each entry of this tensor.default voidsubEq(double b) Subtracts a scalar primitive value from each entry of this tensor and stores the result in 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.Methods inherited from interface org.flag4j.arrays.backend.field_arrays.TensorOverField
div, isFinite, isInfinite, isNaN, sqrt
-
Method Details
-
makeEmptyDataArray
Creates an empty array of the same type as the data array of this tensor.- Specified by:
makeEmptyDataArrayin interfaceRingTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
makeEmptyDataArrayin interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<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.- Specified by:
subin interfaceRingTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
subin interfaceTensorOverRing<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<V>> - Parameters:
b- Scalar value in difference.- Returns:
- The difference of this tensor and the scalar
b.
-
subEq
Subtracts a scalar value from each entry of this tensor and stores the result in this tensor.- Specified by:
subEqin interfaceRingTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
subEqin interfaceTensorOverRing<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<V>> - Parameters:
b- Scalar value in difference.
-
conj
Computes the element-wise conjugation of this tensor.- Specified by:
conjin interfaceRingTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
conjin interfaceTensorOverRing<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<V>> - Returns:
- The element-wise conjugation of this tensor.
-
recip
-
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 interfaceRingTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
minin interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
minin interfaceTensorOverRing<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<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 interfaceRingTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
maxin interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
maxin interfaceTensorOverRing<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<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 interfaceRingTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
argminin interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
argminin interfaceTensorOverRing<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<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 interfaceRingTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
argmaxin interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
argmaxin interfaceTensorOverRing<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<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 interfaceRingTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
argminAbsin interfaceTensorOverRing<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<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 interfaceRingTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
argmaxAbsin interfaceTensorOverRing<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<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.- Specified by:
minAbsin interfaceRingTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
minAbsin interfaceTensorOverRing<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<V>> - Returns:
- The minimum value, in absolute value, in this tensor.
-
maxAbs
default double maxAbs()Finds the maximum absolute value in this tensor.- Specified by:
maxAbsin interfaceRingTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
maxAbsin interfaceTensorOverRing<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<V>> - Returns:
- The maximum absolute value in this tensor.
-
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 interfaceRingTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
addin interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
addin interfaceTensorOverSemiring<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<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 interfaceRingTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
addEqin interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
addEqin interfaceTensorOverSemiring<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<V>> - Parameters:
b- Scalar field value in sum.
-
mult
Multiplies a scalar value to each entry of this tensor.- Specified by:
multin interfaceRingTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
multin interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
multin interfaceTensorOverSemiring<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<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 interfaceRingTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
multEqin interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
multEqin interfaceTensorOverSemiring<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<V>> - Parameters:
b- Scalar value in product.
-
isZeros
default boolean isZeros()Checks if this tensor only contains zeros.- Specified by:
isZerosin interfaceRingTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
isZerosin interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
isZerosin interfaceTensorOverSemiring<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<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 interfaceRingTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
isOnesin interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
isOnesin interfaceTensorOverSemiring<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<V>> - Returns:
trueif this tensor only contains ones;falseotherwise.
-
sum
Computes the sum of all values in this tensor.- Specified by:
sumin interfaceRingTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
sumin interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
sumin interfaceTensorOverSemiring<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<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 interfaceRingTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
prodin interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
prodin interfaceTensorOverSemiring<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<V>> - Returns:
- The product of all values (or non-zero values if sparse) in this tensor.
-
add
Adds a primitive 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. -
addEq
default void addEq(double b) Adds a primitive scalar value to each entry of this tensor and stores the result in this tensor. -
mult
Multiplies a primitive scalar value to each entry of this tensor. -
multEq
default void multEq(double b) Multiplies a primitive scalar value to each entry of this tensor and stores the result in this tensor. -
sub
Subtracts a primitive scalar value from each entry of this tensor. -
subEq
default void subEq(double b) Subtracts a scalar primitive value from each entry of this tensor and stores the result in this tensor. -
div
Divides each element of this tensor by a scalar value. -
divEq
Divides each element of this tensor by a scalar value and stores the result in this tensor. -
div
Divides each element of this tensor by a primitive scalar value. -
divEq
default void divEq(double b) Divides each element of this tensor by a primitive scalar value and stores the result in this tensor. -
norm
default double norm()Computes the Euclidean norm of this vector.- Specified by:
normin interfaceRingTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Returns:
- The Euclidean norm of this vector.
-
norm
default double norm(double p) Computes the p-norm of this vector.- Specified by:
normin interfaceRingTensorMixin<T extends FieldTensorMixin<T,U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Parameters:
p-pvalue in the p-norm.- Returns:
- The Euclidean norm of this vector.
-