Interface Tensor
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
DenseMatrix,DenseSparseMatrix,DenseVector,ShrinkingMatrix,ShrinkingVector,SparseVector
An interface for Tensors, currently Vectors and Matrices.
-
Method Summary
Modifier and TypeMethodDescriptionvoidApplies aDoubleUnaryOperatorelementwise to thisTensor.int[]getShape()Returns an int array specifying the shape of thisTensor.default voidhadamardProductInPlace(Tensor other) Same ashadamardProductInPlace(org.tribuo.math.la.Tensor, java.util.function.DoubleUnaryOperator), but applies the identity function.voidhadamardProductInPlace(Tensor other, DoubleUnaryOperator f) Updates thisTensorwith the Hadamard product (i.e., a term by term multiply) of this andother.default voidintersectAndAddInPlace(Tensor other) Same asintersectAndAddInPlace(org.tribuo.math.la.Tensor, java.util.function.DoubleUnaryOperator), but applies the identity function.voidintersectAndAddInPlace(Tensor other, DoubleUnaryOperator f) Updates thisTensorby adding all the values from the intersection withother.reshape(int[] shape) Reshapes the Tensor to the supplied shape.default voidscalarAddInPlace(double scalar) Addsscalarto each element of thisTensor.default voidscaleInPlace(double coefficient) Scales each element of thisTensorbycoefficient.static booleanshapeCheck(Tensor first, Tensor second) static intshapeSum(int[] shape) doubletwoNorm()Calculates the euclidean norm for this vector.
-
Method Details
-
shapeSum
-
shapeCheck
-
getShape
-
reshape
Reshapes the Tensor to the supplied shape. ThrowsIllegalArgumentExceptionif the shape isn't compatible.- Parameters:
shape- The desired shape.- Returns:
- A Tensor of the desired shape.
-
intersectAndAddInPlace
-
intersectAndAddInPlace
Same asintersectAndAddInPlace(org.tribuo.math.la.Tensor, java.util.function.DoubleUnaryOperator), but applies the identity function.Each value is updated as value += otherValue.
- Parameters:
other- The otherTensor.
-
hadamardProductInPlace
-
hadamardProductInPlace
Same ashadamardProductInPlace(org.tribuo.math.la.Tensor, java.util.function.DoubleUnaryOperator), but applies the identity function.Each value is updated as value *= otherValue.
- Parameters:
other- The otherTensor.
-
foreachInPlace
Applies aDoubleUnaryOperatorelementwise to thisTensor.- Parameters:
f- The function to apply.
-
scaleInPlace
Scales each element of thisTensorbycoefficient.- Parameters:
coefficient- The coefficient of scaling.
-
scalarAddInPlace
Addsscalarto each element of thisTensor.- Parameters:
scalar- The scalar to add.
-
twoNorm
-