Interface TensorOverSemiring<T extends TensorOverSemiring<T,U,V,W>,U extends TensorOverSemiring<U,U,V,W>,V,W>         
- Type Parameters:
- T- Type of this tensor.
- U- Type of dense tensor equivalent to- T. If- Tis dense, then this should be the same type as- T. This parameter required because some ops between two sparse tensors may result in a dense tensor.
- V- Storage for data of this tensor.
- W- Type (or wrapper) of an element of this tensor. Should satisfy the axioms of a semiring as stated.
- All Known Subinterfaces:
- FieldTensorMixin<T,,- U, - V> - RingTensorMixin<T,,- U, - V> - SemiringTensorMixin<T,,- U, - V> - TensorOverField<T,,- U, - V, - W> - TensorOverRing<T,- U, - V, - W> 
- All Known Implementing Classes:
- AbstractCooFieldMatrix,- AbstractCooFieldTensor,- AbstractCooFieldVector,- AbstractCooRingMatrix,- AbstractCooRingTensor,- AbstractCooRingVector,- AbstractCooSemiringMatrix,- AbstractCooSemiringTensor,- AbstractCooSemiringVector,- AbstractCsrFieldMatrix,- AbstractCsrRingMatrix,- AbstractCsrSemiringMatrix,- AbstractDenseDoubleTensor,- AbstractDenseFieldMatrix,- AbstractDenseFieldTensor,- AbstractDenseFieldVector,- AbstractDenseRingMatrix,- AbstractDenseRingTensor,- AbstractDenseRingVector,- AbstractDenseSemiringMatrix,- AbstractDenseSemiringTensor,- AbstractDenseSemiringVector,- AbstractDoubleTensor,- CMatrix,- CooCMatrix,- CooCTensor,- CooCVector,- CooFieldMatrix,- CooFieldTensor,- CooFieldVector,- CooMatrix,- CooRingMatrix,- CooRingTensor,- CooRingVector,- CooSemiringMatrix,- CooSemiringTensor,- CooSemiringVector,- CooTensor,- CooVector,- CsrCMatrix,- CsrFieldMatrix,- CsrMatrix,- CsrRingMatrix,- CsrSemiringMatrix,- CTensor,- CVector,- FieldMatrix,- FieldTensor,- FieldVector,- Matrix,- RingMatrix,- RingTensor,- RingVector,- SemiringMatrix,- SemiringTensor,- SemiringVector,- Tensor,- Vector
To allow for primitive types, the elements of this tensor do not necessarily have to implement
 Semiring.
 
Formally, an semiring is a set R with the binary ops addition (+) and multiplication (*) defined such that for elements a, b, c in R the following are satisfied:
- Addition and multiplication are associative: a + (b + c) = (a + b) + c and a * (b * c) = (a * b) * c.
- Addition is commutative: a + b = b + a
- Existence of additive and multiplicative identities: There exists two distinct elements 0 and 1 in R such that a + 0 = 0 and a * 1 = 1 (called the additive and multiplicative identities respectively).
- Distributivity of multiplication over addition: a * (b + c) = (a * b) + (a * c).
- 
Method SummaryModifier and TypeMethodDescriptionComputes the element-wise sum between two tensors of the same shape.Adds a scalar value to each entry of this tensor.voidAdds a scalar value to each entry of this tensor and stores the result in this tensor.Computes the element-wise multiplication of two tensors of the same shape.getData()Gets the data of this tensor.intgetRank()Gets the rank of this tensor.getShape()Gets the shape of this tensor.booleanisOnes()Checks if this tensor only contains ones.booleanisZeros()Checks if this tensor only contains zeros.makeLikeTensor(Shape shape, V entries) Constructs a tensor of the same type as this tensor with the given theshapeanddata.Multiplies a scalar value to each entry of this tensor.voidMultiplies a scalar value to each entry of this tensor and stores the result in this tensor.prod()Computes the product of all values in this tensor.sum()Computes the sum of all values in this tensor.default AbstractTensor<?, V, W> Computes the tensor dot product of this tensor with a second tensor.default AbstractTensor<?, V, W> Computes the tensor contraction of this tensor with a specified tensor over the specified axes.AbstractTensor<?, V, W> Computes the tensor contraction of this tensor with a specified tensor over the specified set of axes.default AbstractTensor<?, V, W> Computes the tensor contraction of this tensor with a specified tensor over the specified axes.default TensorOverSemiring<?, ?, ?, W> tensorTr()Computes the generalized tensor trace of this tensor along first and second axes.TensorOverSemiring<?, ?, ?, W> tensorTr(int axis1, int axis2) Computes the generalized trace of this tensor along the specified axes.
- 
Method Details- 
getData
- 
makeLikeTensorConstructs a tensor of the same type as this tensor with the given theshapeanddata. The resulting tensor will also have the same non-zero indices as this tensor.- Parameters:
- shape- Shape of the tensor to construct.
- entries- Entries of the tensor to construct.
- Returns:
- A tensor of the same type and with the same non-zero indices as this tensor with the given the shapeanddata.
 
- 
getShape
- 
getRankint getRank()Gets the rank of this tensor.- Returns:
- The rank of this tensor.
 
- 
add
- 
addEqAdds a scalar value to each entry of this tensor and stores the result in this tensor.- Parameters:
- b- Scalar field value in sum.
 
- 
addComputes the element-wise sum between two tensors of the same shape.- Parameters:
- b- Second tensor in the element-wise sum.
- Returns:
- The sum of this tensor with b.
- Throws:
- TensorShapeException- If this tensor and- bdo not have the same shape.
 
- 
mult
- 
multEqMultiplies a scalar value to each entry of this tensor and stores the result in this tensor.- Parameters:
- b- Scalar value in product.
 
- 
elemMultComputes the element-wise multiplication of two tensors of the same shape.- Parameters:
- b- Second tensor in the element-wise product.
- Returns:
- The element-wise product between this tensor and b.
- Throws:
- IllegalArgumentException- If this tensor and- bdo not have the same shape.
 
- 
tensorDotComputes the tensor contraction of this tensor with a specified tensor over the specified axes. Ifaxes=N, then the product sums will be computed along the lastNdimensions of this tensor and the firstNdimensions of thesrc2tensor.- Parameters:
- src2- Tensor to contract with this tensor.
- axes- Axes specifying the number of axes to compute the tensor dot product over. If- axes=N, then the product sums will be computed along the last- Ndimensions of this tensor and the first- Ndimensions of.
- Returns:
- The tensor dot product over the specified axes.
- Throws:
- IllegalArgumentException- If the two tensors shapes do not match along the specified axes- aAxisand- bAxis.
- IllegalArgumentException- If either axis is out of bounds of the corresponding tensor.
 
- 
tensorDotComputes the tensor contraction of this tensor with a specified tensor over the specified axes. That is, computes the sum of products between the two tensors along the specified axes.- Parameters:
- src2- Tensor to contract with this tensor.
- aAxis- Axis along which to compute products for this tensor.
- bAxis- Axis along which to compute products for- src2tensor.
- Returns:
- The tensor dot product over the specified axes.
- Throws:
- IllegalArgumentException- If the two tensors shapes do not match along the specified axes- aAxisand- bAxis.
- IllegalArgumentException- If either axis is out of bounds of the corresponding tensor.
 
- 
tensorDotComputes the tensor contraction of this tensor with a specified tensor over the specified set of axes. That is, computes the sum of products between the two tensors along the specified set of axes.- Parameters:
- src2- Tensor to contract with this tensor.
- aAxes- Axes along which to compute products for this tensor.
- bAxes- Axes along which to compute products for- src2tensor.
- Returns:
- The tensor dot product over the specified axes.
- Throws:
- IllegalArgumentException- If the two tensors shapes do not match along the specified axes pairwise in- aAxesand- bAxes.
- IllegalArgumentException- If- aAxesand- bAxesdo not match in length, or if any of the axes are out of bounds for the corresponding tensor.
 
- 
tensorDotComputes the tensor dot product of this tensor with a second tensor. That is, sums the product of two tensor elements over the last axis of this tensor and the second-to-last axis ofsrc2. If both tensors are rank 2, this is equivalent to matrix multiplication.- Parameters:
- src2- Tensor to compute dot product with this tensor.
- Returns:
- The tensor dot product over the last axis of this tensor and the second to last axis of src2.
- Throws:
- IllegalArgumentException- If this tensors shape along the last axis does not match- src2shape along the second-to-last axis.
 
- 
tensorTrComputes the generalized tensor trace of this tensor along first and second axes. The generalized tensor trace is the sum along the diagonal values of the 2D sub-arrays of this tensor specified by the first and second axes. The shape of the resulting tensor is equal to this tensor with the first and second axes removed. - Returns:
- The generalized trace of this tensor along first and second axes.
 
- 
tensorTrComputes the generalized trace of this tensor along the specified axes. The generalized tensor trace is the sum along the diagonal values of the 2D sub-arrays of this tensor specified by axis1andaxis2. The shape of the resulting tensor is equal to this tensor with theaxis1andaxis2removed.- Parameters:
- axis1- First axis for 2D sub-array.
- axis2- Second axis for 2D sub-array.
- Returns:
- The generalized trace of this tensor along axis1andaxis2.
- Throws:
- IndexOutOfBoundsException- If the two axes are not both larger than zero and less than this tensors rank.
- IllegalArgumentException- If- axis1 == axis2or- this.shape.get(axis1) != this.shape.get(axis1)(i.e. the axes are equal or the tensor does not have the same length along the two axes.)
 
- 
isZerosboolean isZeros()Checks if this tensor only contains zeros.- Returns:
- trueif this tensor only contains zeros;- falseotherwise.
 
- 
isOnesboolean isOnes()Checks if this tensor only contains ones. If this tensor is sparse, only the non-zero data are considered.- Returns:
- trueif this tensor only contains ones;- falseotherwise.
 
- 
sumW sum()Computes the sum of all values in this tensor.- Returns:
- The sum of all values in this tensor.
 
- 
prodW prod()Computes the product of all values in this tensor.- Returns:
- The product of all values in this tensor.
 
 
-