Class OngoingTensorManipulation<V>

  • Type Parameters:
    V - the type of the values of the tensor

    public class OngoingTensorManipulation<V>
    extends java.lang.Object
    Part of the tensoric fluent API which provides methods to describe misc manipulations on a given tensor.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      OngoingEitherGet<V> either​(V defaultValue)
      Deprecated.
      use rather optional(Object...).orElse(...);
      Tensor<V> extract​(java.lang.Object... coordinates)  
      Tensor<V> extract​(Position position)  
      <C1> java.util.Set<C1> extractCoordinatesOfType​(java.lang.Class<C1> coordinateType)
      Retrieves all the unique coordinates of the given type.
      Tensor<V> extractWhereTrue​(Tensor<java.lang.Boolean> mask)
      Extracts from the tensor only those elements where the values in the given mask is true.
      V get​(java.lang.Object... coordinates)  
      V get​(Position position)  
      <C> java.util.List<V> list​(java.util.List<C> listCoordinateValues, java.lang.Object... otherCoordinates)  
      <C> java.util.List<V> list​(java.util.List<C> listCoordinateValues, Position otherCoordinates)  
      <C> java.util.Map<C,​V> map​(java.lang.Class<C> mapKeyType, java.lang.Object... otherCoordinates)  
      <C> java.util.Map<C,​V> map​(java.lang.Class<C> mapKeyType, Position otherCoordinates)  
      java.util.Optional<V> optional​(java.lang.Object... coordinates)  
      java.util.Optional<V> optional​(Position position)
      Returns an optional containing the value at the given position in the tensor, if the tensor contains the position, or an empty optional otherwise.
      <C> OngoingDimensionReduction<C,​V> reduce​(java.lang.Class<C> dimension)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • extractWhereTrue

        public Tensor<V> extractWhereTrue​(Tensor<java.lang.Boolean> mask)
        Extracts from the tensor only those elements where the values in the given mask is true. The resulting tensors will then have the same dimensionality as the original tensor, but will only have that many elements as there are true elements in the mask tensor.
        Parameters:
        mask - the mask which determines which elements shall be present in the new tensor.
        Returns:
        A tensor which will contain only those elements which have true flags in the mask
      • extractCoordinatesOfType

        public <C1> java.util.Set<C1> extractCoordinatesOfType​(java.lang.Class<C1> coordinateType)
        Retrieves all the unique coordinates of the given type.
        Parameters:
        coordinateType - the type of the coordinate to extract
        Returns:
        a set of extracted coordinates
      • get

        public V get​(java.lang.Object... coordinates)
      • optional

        public java.util.Optional<V> optional​(Position position)
        Returns an optional containing the value at the given position in the tensor, if the tensor contains the position, or an empty optional otherwise. However, if the dimension of the position are incompatible with the tensor dimensions, then an IllegalArgumentException is thrown.
        Parameters:
        position - the position for which the optional value shall be queried.
        Returns:
        an optional containing the value, if it is contained in the tensor and the dimensions are correct.
        Throws:
        java.lang.IllegalArgumentException - if the dimensions of the tensor and the position do not match.
      • optional

        public java.util.Optional<V> optional​(java.lang.Object... coordinates)
      • list

        public <C> java.util.List<V> list​(java.util.List<C> listCoordinateValues,
                                          Position otherCoordinates)
      • list

        public <C> java.util.List<V> list​(java.util.List<C> listCoordinateValues,
                                          java.lang.Object... otherCoordinates)
      • map

        public <C> java.util.Map<C,​V> map​(java.lang.Class<C> mapKeyType,
                                                Position otherCoordinates)
      • map

        public <C> java.util.Map<C,​V> map​(java.lang.Class<C> mapKeyType,
                                                java.lang.Object... otherCoordinates)
      • extract

        public Tensor<V> extract​(java.lang.Object... coordinates)