Class TensorStructurals


  • public final class TensorStructurals
    extends java.lang.Object
    Structural manipulations of tensors (which do not require any knowledge about the mathematical behaviour of the elements).
    • Method Detail

      • merge

        public static <E> Tensor<E> merge​(java.lang.Iterable<Tensor<E>> tensors)
        Merges the given set of the Tensors based on information in their context and dimensions. This operation is only possible, if the following preconditions are fulfilled:
        • The contexts of all the tensors have THE SAME dimensions AND
        • The dimensions of all the tensors are THE SAME (first found tensor dimension is taken as an reference)
        Parameters:
        tensors - to be merged.
        Returns:
        a merged tensor.
        Throws:
        java.lang.IllegalArgumentException - if zero or one tensor is put to be merged OR if tensors dimensionality and their context positions dimensionality is not equal OR tensor context is empty.
      • transformEntries

        public static <S,​T> Tensor<T> transformEntries​(Tensor<S> tensor,
                                                             java.util.function.Function<java.util.Map.Entry<Position,​S>,​T> function)
      • transformScalars

        public static <S,​T> Tensor<T> transformScalars​(Tensor<S> tensor,
                                                             java.util.function.Function<S,​T> function)
      • transformScalars

        public static <S,​T> Tensor<T> transformScalars​(Tensor<S> tensor,
                                                             java.util.function.BiFunction<Position,​S,​T> function)
      • consumeScalars

        public static <S> void consumeScalars​(Tensor<S> tensor,
                                              java.util.function.Consumer<S> consumer)
      • consumeScalars

        public static <S> void consumeScalars​(Tensor<S> tensor,
                                              java.util.function.BiConsumer<Position,​S> consumer)
      • stripContext

        public static <S> Tensor<S> stripContext​(Tensor<S> tensor)
      • mergeContextIntoShape

        public static <V> Tensor<V> mergeContextIntoShape​(Tensor<V> tensor)
      • completeWith

        public static <V> Tensor<V> completeWith​(Tensor<V> tensor,
                                                 Tensor<V> second)
      • resample

        public static <V> OngoingResamplingStart<V> resample​(Tensor<V> tensor)
        Starting point for a fluent clause to describe resampling in one or more dimensions. This resampling only provides options which do not require the knowledge of a field. For example:
         
         Tensoric<V> resampled = resample(aTensor)
                                   .repeat(Integer.class)
                                   .then().repeat(String.class)
                                   .toTensoric();
         
         
        Note: The order of the options is important, as the resampling will be performed in the given order!

        For options which require a field, (e.g. linear interpolation), see the version in TensorSupport.resample(Tensor).

        Parameters:
        tensor - the tensor to be resampled
        Returns:
        an object to define further the strategy for resampling.