Class BroadcastMissingDimensionsStrategy
- java.lang.Object
-
- org.tensorics.core.tensor.options.BroadcastMissingDimensionsStrategy
-
- All Implemented Interfaces:
ManipulationOption
,Option<ManipulationOption>
,BroadcastingStrategy
public class BroadcastMissingDimensionsStrategy extends java.lang.Object implements BroadcastingStrategy
A broadcasting strategies that broadcasts all dimensions which are not available in one tensor to the shape of the second tensor. For example, lets assume tensors of double values:- the left tensor has one dimension X with two entries {[x1]=1.0, [x2]=2.0},
- the right tensor has one dimension Y with two entries {[y1]=0.1, [y2]=0.2},
- broadcasted left: {[x1,y1]=1.0, [x1,y2]=1.0, [x2,y1]=2.0, [x2,y2]=2.0},
- broadcasted left: {[x1,y1]=0.1, [x1,y2]=0.2, [x2,y1]=0.1, [x2,y2]=0.2}.
The reason for this important difference to numpy, is that we consider this as more consistent in the general case: If a dimension is not present in a tensor, we treat it as 'applicable for all' while if the dimension is present with one entry, then it is clearly defined where the values are positioned in this dimension and it would be dangerous to assume they would be applicable everywhere.
-
-
Constructor Summary
Constructors Constructor Description BroadcastMissingDimensionsStrategy()
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <V> TensorPair<V>
broadcast(Tensor<V> left, Tensor<V> right, java.util.Set<java.lang.Class<?>> excludedDimensions)
Has to broadcast the given to tensors into a new pair of tensors, that are consistent according to the broadcasting strategy in question.static BroadcastMissingDimensionsStrategy
get()
java.lang.Class<BroadcastingStrategy>
getMarkerInterface()
-
-
-
Constructor Detail
-
BroadcastMissingDimensionsStrategy
@Deprecated public BroadcastMissingDimensionsStrategy()
Deprecated.use factory methodget()
-
-
Method Detail
-
get
public static BroadcastMissingDimensionsStrategy get()
-
broadcast
public <V> TensorPair<V> broadcast(Tensor<V> left, Tensor<V> right, java.util.Set<java.lang.Class<?>> excludedDimensions)
Description copied from interface:BroadcastingStrategy
Has to broadcast the given to tensors into a new pair of tensors, that are consistent according to the broadcasting strategy in question.- Specified by:
broadcast
in interfaceBroadcastingStrategy
- Parameters:
left
- the left tensor to broadcastright
- the right tensor to broadcastexcludedDimensions
- a set of dimensions, which should be excluded from broadcasting- Returns:
- the result of the broadcasting
-
getMarkerInterface
public java.lang.Class<BroadcastingStrategy> getMarkerInterface()
- Specified by:
getMarkerInterface
in interfaceOption<ManipulationOption>
-
-