public interface Tensor extends Serializable
Modifier and Type | Method and Description |
---|---|
void |
foreachInPlace(DoubleUnaryOperator f)
Applies a
DoubleUnaryOperator elementwise to this Tensor . |
int[] |
getShape()
Returns an int array specifying the shape of this
Tensor . |
default void |
hadamardProductInPlace(Tensor other)
Same as
hadamardProductInPlace(org.tribuo.math.la.Tensor, java.util.function.DoubleUnaryOperator) , but applies the identity function. |
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)
Same as
intersectAndAddInPlace(org.tribuo.math.la.Tensor, java.util.function.DoubleUnaryOperator) , but applies the identity function. |
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.
|
static int shapeSum(int[] shape)
int[] getShape()
Tensor
.Tensor reshape(int[] shape)
IllegalArgumentException
if the shape isn't compatible.shape
- The desired shape.void intersectAndAddInPlace(Tensor other, DoubleUnaryOperator f)
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).
other
- The other Tensor
.f
- A function to apply.default void intersectAndAddInPlace(Tensor other)
intersectAndAddInPlace(org.tribuo.math.la.Tensor, java.util.function.DoubleUnaryOperator)
, but applies the identity function.
Each value is updated as value += otherValue.
other
- The other Tensor
.void hadamardProductInPlace(Tensor other, DoubleUnaryOperator f)
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).
other
- The other Tensor
.f
- A function to apply.default void hadamardProductInPlace(Tensor other)
hadamardProductInPlace(org.tribuo.math.la.Tensor, java.util.function.DoubleUnaryOperator)
, but applies the identity function.
Each value is updated as value *= otherValue.
other
- The other Tensor
.void foreachInPlace(DoubleUnaryOperator f)
DoubleUnaryOperator
elementwise to this Tensor
.f
- The function to apply.default void scaleInPlace(double coefficient)
Tensor
by coefficient
.coefficient
- The coefficient of scaling.default void scalarAddInPlace(double scalar)
scalar
to each element of this Tensor
.scalar
- The scalar to add.double twoNorm()
Copyright © 2015–2021 Oracle and/or its affiliates. All rights reserved.