Package com.yahoo.tensor
Class TensorAddress
java.lang.Object
com.yahoo.tensor.TensorAddress
- All Implemented Interfaces:
Comparable<TensorAddress>
- Direct Known Subclasses:
TensorAddressAny
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, its meaning depends on its accompanying type.
- Author:
- bratseth
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder of a tensor addressstatic classBuilder of an address to a subset of the dimensions of a tensor type -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(TensorAddress other) fullAddressOf(List<TensorType.Dimension> dimensions, int[] indexedPart) Creates a complete address by taking the mapped dimensions of this and adding the indexed from the indexedPartfinal booleanisEmpty()abstract Stringlabel(int i) Returns the i'th label in thisstatic StringlabelToString(String label) Returns a label as a string with appropriate quoting/escaping when necessarymappedPartialAddress(TensorType mappedType, List<TensorType.Dimension> dimensions) Returns an address containing the mapped dimensions of this.abstract longnumericLabel(int i) Returns the i'th label in this as a long.abstract LabelobjectLabel(int i) Returns the i'th label object in thisstatic TensorAddressof(int... labels) static TensorAddressof(long... labels) static TensorAddressstatic TensorAddresspartialCopy(int[] indexMap) Returns an address with only some of the dimension.abstract intsize()Returns the number of labels in thistoString()final StringtoString(TensorType type) Returns this as a string on the appropriate form given the typeabstract TensorAddresswithLabel(int labelIndex, long label)
-
Constructor Details
-
TensorAddress
public TensorAddress()
-
-
Method Details
-
of
-
ofLabels
-
of
-
of
-
size
public abstract int size()Returns the number of labels in this -
objectLabel
Returns the i'th label object in this- Throws:
IllegalArgumentException- if there is no label at this index
-
label
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
-
isEmpty
public final boolean isEmpty() -
compareTo
- Specified by:
compareToin interfaceComparable<TensorAddress>
-
toString
-
toString
Returns this as a string on the appropriate form given the type -
labelToString
Returns a label as a string with appropriate quoting/escaping when necessary -
partialCopy
Returns an address with only some of the dimension. Ordering will also be according to indexMap -
fullAddressOf
Creates a complete address by taking the mapped dimensions of this and adding 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 addressdimensions- all the dimensions of the type this is an address of
-