V
- the type of the values of the tensorpublic final class BroadcastedTensorView<V> extends AbstractTensor<V>
The values are broadcasted such that the values will be the same for all coordinates of the new dimensions.
The resulting view will still be backed by the original tensor. Since the broadcasted shape will never be updated from the original tensor, the results might be unpredictable, if the original tensor would be mutable.
Constructor and Description |
---|
BroadcastedTensorView(Tensor<V> originalTensor,
Shape extendingShape)
Constructs a view of the given original tensor, broadcasted to the additional shape.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(Position position)
Returns
true if the tensoric object contains the given position, false otherwise. |
Position |
context()
Retrieves the context of the tensor, which is nothing else than a position.
|
V |
get(java.lang.Object... coordinates) |
V |
get(Position position) |
Shape |
shape()
Retrieves the shape of the tensor.
|
java.lang.String |
toString() |
equals, hashCode
public BroadcastedTensorView(Tensor<V> originalTensor, Shape extendingShape)
originalTensor
- the original tensorextendingShape
- the shape by which the original tensor shape has to be enlargedpublic V get(Position position)
position
- the position in the N-dimensional space where to find the value.public V get(java.lang.Object... coordinates)
coordinates
- form N-dimensional space where to find the value.public Shape shape()
Tensor
Implementations have to take care that the returned value here is never null
.
public Position context()
Tensor
Implementations have to guarantee that the returned value here is never null
.
public java.lang.String toString()
toString
in class java.lang.Object
public boolean contains(Position position)
Tensoric
true
if the tensoric object contains the given position, false
otherwise.position
- the position to be checkedtrue
if the position is contained in the tensoric object, false
otherwise.