org.tribuo.math.la

Interface Tensor

• Method Summary

All Methods
Modifier and Type Method and Description
`void` `foreachInPlace(DoubleUnaryOperator f)`
`int[]` `getShape()`
Returns an int array specifying the shape of this `Tensor`.
`default void` `hadamardProductInPlace(Tensor other)`
`void` ```hadamardProductInPlace(Tensor other, DoubleUnaryOperator f)```
Updates this `Tensor` with the Hadamard product (i.e., a term by term multiply) of this and `other`.
`default void` `intersectAndAddInPlace(Tensor other)`
`void` ```intersectAndAddInPlace(Tensor other, DoubleUnaryOperator f)```
Updates this `Tensor` by adding all the values from the intersection with `other`.
`Tensor` `reshape(int[] shape)`
Reshapes the Tensor to the supplied shape.
`default void` `scalarAddInPlace(double scalar)`
Adds `scalar` to each element of this `Tensor`.
`default void` `scaleInPlace(double coefficient)`
Scales each element of this `Tensor` by `coefficient`.
`static boolean` ```shapeCheck(Tensor first, Tensor second)```
`static int` `shapeSum(int[] shape)`
`double` `twoNorm()`
Calculates the euclidean norm for this vector.
• Method Detail

• shapeSum

`static int shapeSum(int[] shape)`
• shapeCheck

```static boolean shapeCheck(Tensor first,
Tensor second)```
• getShape

`int[] getShape()`
Returns an int array specifying the shape of this `Tensor`.
Returns:
An int array.
• reshape

`Tensor reshape(int[] shape)`
Reshapes the Tensor to the supplied shape. Throws `IllegalArgumentException` if the shape isn't compatible.
Parameters:
`shape` - The desired shape.
Returns:
A Tensor of the desired shape.

```void intersectAndAddInPlace(Tensor other,
DoubleUnaryOperator f)```
Updates this `Tensor` by adding all the values from the intersection with `other`.

The function `f` is applied to all values from `other` before the addition.

Each value is updated as value += f(otherValue).

Parameters:
`other` - The other `Tensor`.
`f` - A function to apply.

```void hadamardProductInPlace(Tensor other,
DoubleUnaryOperator f)```
Updates this `Tensor` with the Hadamard product (i.e., a term by term multiply) of this and `other`.

The function `f` is applied to all values from `other` before the addition.

Each value is updated as value *= f(otherValue).

Parameters:
`other` - The other `Tensor`.
`f` - A function to apply.
• scaleInPlace

`default void scaleInPlace(double coefficient)`
Scales each element of this `Tensor` by `coefficient`.
Parameters:
`coefficient` - The coefficient of scaling.
`default void scalarAddInPlace(double scalar)`
Adds `scalar` to each element of this `Tensor`.
`scalar` - The scalar to add.
`double twoNorm()`