Class TensorAddress

java.lang.Object
com.yahoo.tensor.TensorAddress
All Implemented Interfaces:
Comparable<TensorAddress>
Direct Known Subclasses:
TensorAddressAny

public abstract class TensorAddress extends Object implements Comparable<TensorAddress>
An immutable address to a tensor cell. This simply supplies a value to each dimension in a particular tensor type. By itself it is just a list of cell labels, it's meaning depends on its accompanying type.
Author:
bratseth
  • Constructor Details

    • TensorAddress

      public TensorAddress()
  • Method Details

    • of

      public static TensorAddress of(String[] labels)
    • ofLabels

      public static TensorAddress ofLabels(String... labels)
    • of

      public static TensorAddress of(long... labels)
    • of

      public static TensorAddress of(int... labels)
    • size

      public abstract int size()
      Returns the number of labels in this
    • label

      public abstract String label(int i)
      Returns the i'th label in this
      Throws:
      IllegalArgumentException - if there is no label at this index
    • numericLabel

      public abstract long numericLabel(int i)
      Returns the i'th label in this as a long. Prefer this if you know that this is a numeric address, but not otherwise.
      Throws:
      IllegalArgumentException - if there is no label at this index
    • withLabel

      public abstract TensorAddress withLabel(int labelIndex, long label)
    • isEmpty

      public final boolean isEmpty()
    • compareTo

      public int compareTo(TensorAddress other)
      Specified by:
      compareTo in interface Comparable<TensorAddress>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toString

      public final String toString(TensorType type)
      Returns this as a string on the appropriate form given the type
    • labelToString

      public static String labelToString(String label)
      Returns a label as a string with appropriate quoting/escaping when necessary
    • partialCopy

      public TensorAddress partialCopy(int[] indexMap)
      Returns an address with only some of the dimension. Ordering will also be according to indexMap
    • fullAddressOf

      public TensorAddress fullAddressOf(List<TensorType.Dimension> dimensions, int[] densePart)
      Creates a complete address by taking the mapped dimmensions from this and the indexed from the indexedPart
    • mappedPartialAddress

      public TensorAddress mappedPartialAddress(TensorType mappedType, List<TensorType.Dimension> dimensions)
      Returns an address containing the mapped dimensions of this.
      Parameters:
      mappedType - the type of the mapped subset of the type this is an address of; which is also the type of the returned address
      dimensions - all the dimensions of the type this is an address of