Class TensorInternals
- java.lang.Object
-
- org.tensorics.core.tensor.operations.TensorInternals
-
public final class TensorInternals extends java.lang.Object
Utility methods for tensors which are not exposed to the public API
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <S> Tensor<S>
createFrom(Shape shape, java.util.function.Function<Position,S> function)
static <S> Tensor<S>
createFrom(Shape shape, java.util.function.Supplier<S> supplier)
static <T> java.util.Set<java.util.Map.Entry<Position,T>>
entrySetOf(Tensor<T> tensor)
static <V> java.util.Map<Position,V>
mapFrom(Tensor<V> tensor)
Returns a map representing the content of the given tensor.static <T> OngoingMapOut<T>
mapOut(Tensor<T> tensor)
static <S> Tensor<S>
sameValues(Shape shape, S value)
-
-
-
Method Detail
-
mapOut
public static <T> OngoingMapOut<T> mapOut(Tensor<T> tensor)
-
entrySetOf
public static <T> java.util.Set<java.util.Map.Entry<Position,T>> entrySetOf(Tensor<T> tensor)
-
createFrom
public static <S> Tensor<S> createFrom(Shape shape, java.util.function.Supplier<S> supplier)
-
createFrom
public static <S> Tensor<S> createFrom(Shape shape, java.util.function.Function<Position,S> function)
-
mapFrom
public static <V> java.util.Map<Position,V> mapFrom(Tensor<V> tensor)
Returns a map representing the content of the given tensor. The concrete instance of the map might differ depending on the implementation of the passed in tensor: Tensor implementations can offer a more efficient way to retrieve a map from them, by implementing theMappable
interface. If this interface is present, then itsMappable.asMap()
method will be called. Otherwise, as a fallback, a new immutable map will be created from information from the shape of the passed in tensor and its values.- Parameters:
tensor
- the tensor from which a map should be returned- Returns:
- a map representing the content of the tensor
- Throws:
java.lang.NullPointerException
- in case the passed in tensor isnull
-
-