Class Tensorbackeds


  • public final class Tensorbackeds
    extends java.lang.Object
    Contains (public) utility methods for tensor backed objects.
    • Method Detail

      • builderFor

        public static <V,​TB extends Tensorbacked<V>> SimpleTensorbackedBuilder<V,​TB> builderFor​(java.lang.Class<TB> tensorbackedClass)
        Creates a new builder for the given tensor backed class. The builder will allow to add content to the tensor backed object and construct it at the end. Only coordinates wich are compatible with the dimensions as annotated in the tensor backed class are allowed.
        Parameters:
        tensorbackedClass - the type of tensor backed object to be created.
        Returns:
        a builder for the tensor backed object
      • builderFor2D

        public static <C1,​C2,​V,​TB extends Tensorbacked2d<C1,​C2,​V>> Tensorbacked2dBuilder<C1,​C2,​V,​TB> builderFor2D​(java.lang.Class<TB> tensorbackedClass)
      • builderFor3D

        public static <C1,​C2,​C3,​V,​TB extends Tensorbacked3d<C1,​C2,​C3,​V>> Tensorbacked3dBuilder<C1,​C2,​C3,​V,​TB> builderFor3D​(java.lang.Class<TB> tensorbackedClass)
      • builderFor4D

        public static <C1,​C2,​C3,​C4,​V,​TB extends Tensorbacked4d<C1,​C2,​C3,​C4,​V>> Tensorbacked4dBuilder<C1,​C2,​C3,​C4,​V,​TB> builderFor4D​(java.lang.Class<TB> tensorbackedClass)
      • builderFor5D

        public static <C1,​C2,​C3,​C4,​C5,​V,​TB extends Tensorbacked5d<C1,​C2,​C3,​C4,​C5,​V>> Tensorbacked5dBuilder<C1,​C2,​C3,​C4,​C5,​V,​TB> builderFor5D​(java.lang.Class<TB> tensorbackedClass)
      • dimensionsOf

        public static <T extends Tensorbacked<?>> java.util.Set<java.lang.Class<?>> dimensionsOf​(java.lang.Class<T> tensorBackedClass)
        Retrieves the dimensions from the given class inheriting from tensor backed. This is done by inspecting the Dimensions annotation.
        Parameters:
        tensorBackedClass - the class for which to determine the dimensions
        Returns:
        the set of dimensions (classes of coordinates) which are required to create an instance of the given class.
      • sizeOf

        public static <TB extends Tensorbacked<?>> int sizeOf​(TB tensorbacked)
        A convenience method to retrieve the size (number of entries) of a tensor backed object. This is nothing else than a shortcut to the size of the underlaying tensor.
        Parameters:
        tensorbacked - the tensor backed object for which to retrieve the size
        Returns:
        the size (number of entries) of the object
      • dimensionalityOf

        public static <TB extends Tensorbacked<?>> int dimensionalityOf​(TB tensorbacked)
        A convenience method to retrieve the number of dimensions of a tensor backed object. This is a shortcut to retrieving the dimensionality of the underlaying tensor of the tensor backed object.
        Parameters:
        tensorbacked - the tensor backed object from which to retrieve the dimensions
        Returns:
        the number of dimensions of the tensor backed object
      • empty

        public static <V,​TB extends Tensorbacked<V>> TB empty​(java.lang.Class<TB> tensorbackedClass)
        Creates a new empty instance of a tensorbacked class of the given type. This is simply a convenience method for calling SimpleTensorbackedBuilder.build() on an empty builder.
        Parameters:
        tensorbackedClass - the class of the tensor backed object to create
        Returns:
        a new empty instance of the tensorbacked object.
      • construct

        public static <V,​TB extends Tensorbacked<V>> OngoingTensorbackedConstruction<V,​TB> construct​(java.lang.Class<TB> tensorbackedClass)
        Starting point for a fluent clause to construct tensor backed objects by different means from other objects. For example:
         
             // Assume that Orbit and OrbitTimeseries are tensorbacked objects
             List<> orbits = new ArrayList<>();
             // assume the list is filled
             OrbitTimeseries orbitTimeseries = construct(OrbitTimeseries.class).byMerging(orbits);
         
         
        Parameters:
        tensorbackedClass - the type of the tensorbacked object that should be constructed
        Returns:
        an object which provides further methods to define the construction of the object
      • validitiesOf

        public static <S> Tensor<java.lang.Boolean> validitiesOf​(Tensorbacked<QuantifiedValue<S>> tensorbacked)
        Retrieves the validities from a tensorbacked object which contains quantities as values. This is a convenience method to calling the QuantityTensors.validitiesOf(Tensor) method on the tensor contained in the tensorbacked.
        Parameters:
        tensorbacked - the tensorbacked class from which to get the validities
        Returns:
        a tensor containing only the validities of the values of the tensorbacked class
      • valuesOf

        public static <S> Tensor<S> valuesOf​(Tensorbacked<QuantifiedValue<S>> tensorbacked)
        Retrieves the values of a tensorbacked object which contains quantities as values. This is a convenience method to calling QuantityTensors.valuesOf(Tensor) on the tensor backing the tensorbacked object.
        Parameters:
        tensorbacked - the tensorbacked object from which to retrieve the values
        Returns:
        a tensor containing the values of quantities in the tensorbacked object
      • errorsOf

        public static <S> Tensor<com.google.common.base.Optional<S>> errorsOf​(Tensorbacked<QuantifiedValue<S>> tensorbacked)
        Retrieves the errors from the tensorbacked object. This is a convenience method to calling QuantityTensors.errorsOf(Tensor) on the tensor backing the tensorbacked object.
        Parameters:
        tensorbacked - the tensorbacked object from which to retrieve the errors
        Returns:
        a tensor containing the errors of the quantities within the tensorbacked object
      • unitOf

        public static <S> Unit unitOf​(Tensorbacked<QuantifiedValue<S>> tensorbacked)
        Retrieves the base of a tensorbacked object by looking at the underlaying tensor.
        Parameters:
        tensorbacked - the tensorbacked object from which to retrieve the base
        Returns:
        the base
        Throws:
        java.lang.IllegalArgumentException - if the base cannot be determined
      • positionsOf

        public static java.util.Set<Position> positionsOf​(Tensorbacked<?> tensorbacked)
        Retrieves a set of all positions within a tensorbacked class.
        Parameters:
        tensorbacked - the tensor backed object
        Returns:
        a set containing all positions of the tensorbacked object
      • shapeOf

        public static final Shape shapeOf​(Tensorbacked<?> tensorbacked)
        Retrieves the shape of the tensor backed object.
        Parameters:
        tensorbacked - the tensorbacke object from which to retrieve the shape
        Returns:
        the shape of the internal tensor of the object
      • shapesOf

        public static final <TB extends Tensorbacked<?>> java.lang.Iterable<Shape> shapesOf​(java.lang.Iterable<TB> tensorbackeds)
        Retrieves all the shapes of the given tensorbacked objects. The order of the shapes is conserved from the iteration order of the input iterable and the returned iterable will have the same number of elements than the input collection.
        Parameters:
        tensorbackeds - the tensorbacked objects from which to get the shapes
        Returns:
        an iterable contining the shapes of the tensor backed objects
      • flatten

        public static final <S> OngoingFlattening<S> flatten​(Tensorbacked<S> tensorbacked)
        Starting for a fluent clause, that allows to flatten one or multiple dimensions of the internal tensor of the tensor backed object into maps or tensors of lists.
        Parameters:
        tensorbacked - the tensor backed object whose internal tensor is subject to flattening of values
        Returns:
        an object which allows to further specify the flattening operation
      • tensorsOf

        public static final <S> java.lang.Iterable<Tensor<S>> tensorsOf​(java.lang.Iterable<? extends Tensorbacked<S>> tensorbackeds)
        Retrieves the tensor from each tensorbacked in the given iterable and returns them in a new iterable. The order of iteration is conserved from the input iterable and also duplicated entries are returned in a duplicated manner.
        Parameters:
        tensorbackeds - the iterable of tensorbackeds from which to retrieve the tensors
        Returns:
        an iterable containing the tensors from the given iterable of tensorbackeds
      • complete

        public static final <S,​TB extends Tensorbacked<S>> OngoingTensorbackedCompletion<TB,​S> complete​(TB tensorbacked)
        Starting point for a fluent clause to complete a tensorbacked object with other values.
        Parameters:
        tensorbacked - the tensor backed object to complete
        Returns:
        an intermediate object that will allow to specify details on how the object shall be completed
      • mergeTo

        @Deprecated
        public static <TB extends Tensorbacked<E>,​TBOUT extends Tensorbacked<E>,​E> TBOUT mergeTo​(java.lang.Iterable<TB> toBeMerged,
                                                                                                             java.lang.Class<TBOUT> classToReturn)
        Deprecated.
        use construct(classToReturn).byMergingTb(toBeMerged);
        Merges the given Tensorbackeds into one Tensorbacked of the given class. The resulting dimensions must match the dimensions required by the resulting object's class.

        Parameters:
        toBeMerged - the tensor backed objects that shall be merged into one
        classToReturn - the type of the tensor backed that should be resulting from the merge
        Returns:
        a new tensor backed object resulting from the the merge of the tensors
        See Also:
        construct(Class)
      • stripContext

        public static final <V,​TB extends Tensorbacked<V>> TB stripContext​(TB tensorbacked)
      • setContext

        public static <V,​TB extends Tensorbacked<V>> TB setContext​(TB tensorbacked,
                                                                         Position context)