Class MixedTensor

  • All Implemented Interfaces:
    Tensor

    public class MixedTensor
    extends java.lang.Object
    implements Tensor
    A mixed tensor type. This is class is currently suitable for serialization and deserialization, not yet for computation. A mixed tensor has a combination of mapped and indexed dimensions. By reordering the mapped dimensions before the indexed dimensions, one can think of mixed tensors as the mapped dimensions mapping to a dense tensor. This dense tensor is called a dense subspace.
    Author:
    lesters
    • Method Detail

      • size

        public long size()
        Returns the size of the tensor measured in number of cells
        Specified by:
        size in interface Tensor
      • get

        public double get​(TensorAddress address)
        Returns the value at the given address
        Specified by:
        get in interface Tensor
      • cellIterator

        public java.util.Iterator<Tensor.Cell> cellIterator()
        Returns an iterator over the cells of this tensor. Cells are returned in order of increasing indexes in the indexed dimensions, increasing indexes of later dimensions in the dimension type before earlier. No guarantee is given for the order of sparse dimensions.
        Specified by:
        cellIterator in interface Tensor
      • valueIterator

        public java.util.Iterator<java.lang.Double> valueIterator()
        Returns an iterator over the values of this tensor. The iteration order is the same as for cellIterator.
        Specified by:
        valueIterator in interface Tensor
      • cells

        public java.util.Map<TensorAddress,​java.lang.Double> cells()
        Description copied from interface: Tensor
        Returns an immutable map of the cells of this in no particular order. This may be expensive for some implementations - avoid when possible
        Specified by:
        cells in interface Tensor
      • withType

        public Tensor withType​(TensorType other)
        Description copied from interface: Tensor
        Returns this tensor with the given type if types are compatible
        Specified by:
        withType in interface Tensor
      • remove

        public Tensor remove​(java.util.Set<TensorAddress> addresses)
        Description copied from interface: Tensor
        Returns a new tensor where existing cells in this tensor have been removed according to the given set of addresses. Only valid for sparse or mixed tensors. For mixed tensors, addresses are assumed to only contain the sparse dimensions, as the entire dense subspace is removed.
        Specified by:
        remove in interface Tensor
        Parameters:
        addresses - list of addresses to remove
        Returns:
        a new tensor where cells have been removed
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Description copied from interface: Tensor
        Returns this tensor on the tensor literal form with type included.
        Specified by:
        toString in interface Tensor
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object other)
        Description copied from interface: Tensor
        Returns whether this tensor and the given tensor is mathematically equal: That they have the same dimension *names* and the same content.
        Specified by:
        equals in interface Tensor
        Overrides:
        equals in class java.lang.Object
      • denseSubspaceSize

        public long denseSubspaceSize()
        Returns the size of dense subspaces