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, it's meaning depends on its accompanying type.
- Author:
- bratseth
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Builder of a tensor addressstatic class
Builder of an address to a subset of the dimensions of a tensor type -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(TensorAddress other) fullAddressOf
(List<TensorType.Dimension> dimensions, int[] densePart) Creates a complete address by taking the mapped dimmensions from this and the indexed from the indexedPartfinal boolean
isEmpty()
abstract String
label
(int i) Returns the i'th label in thisstatic String
labelToString
(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 long
numericLabel
(int i) Returns the i'th label in this as a long.static TensorAddress
of
(int... labels) static TensorAddress
of
(long... labels) static TensorAddress
static TensorAddress
partialCopy
(int[] indexMap) Returns an address with only some of the dimension.abstract int
size()
Returns the number of labels in thistoString()
final String
toString
(TensorType type) Returns this as a string on the appropriate form given the typeabstract TensorAddress
withLabel
(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 -
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:
compareTo
in 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 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 addressdimensions
- all the dimensions of the type this is an address of
-