Modifier and Type | Class and Description |
---|---|
static class |
IndexedTensor.BoundBuilder
A bound builder can create the double array directly
|
static class |
IndexedTensor.Builder |
private class |
IndexedTensor.CellIterator |
private static class |
IndexedTensor.EmptyIndexes |
private static class |
IndexedTensor.EqualSizeMultiDimensionIndexes
In this case we can reuse the source index computation for the iteration index
|
private static class |
IndexedTensor.EqualSizeSingleDimensionIndexes
In this case we only need to keep track of one index
|
static class |
IndexedTensor.Indexes
An array of indexes into this tensor which are able to find the next index in the value order.
|
private static class |
IndexedTensor.LazyCell
A Cell which does not compute its TensorAddress unless it really has to
|
private static class |
IndexedTensor.MultiDimensionIndexes |
private static class |
IndexedTensor.SingleDimensionIndexes
In this case we can keep track of indexes using a step instead of using the more elaborate computation
|
private static class |
IndexedTensor.SingleValueIndexes |
class |
IndexedTensor.SubspaceIterator
An iterator over a subspace of this tensor.
|
private class |
IndexedTensor.SuperspaceIterator |
private static class |
IndexedTensor.UnboundBuilder
A builder used when we don't know the size of the dimensions up front.
|
private class |
IndexedTensor.ValueIterator |
Tensor.Cell
Modifier and Type | Field and Description |
---|---|
private DimensionSizes |
dimensionSizes
The sizes of the dimensions of this in the order of the dimensions of the type
|
private TensorType |
type
The prescribed and possibly abstract type this is an instance of
|
private double[] |
values |
Modifier | Constructor and Description |
---|---|
private |
IndexedTensor(TensorType type,
DimensionSizes dimensionSizes,
double[] values) |
Modifier and Type | Method and Description |
---|---|
Iterator<Tensor.Cell> |
cellIterator()
Returns an iterator over the cells of this.
|
IndexedTensor.SubspaceIterator |
cellIterator(PartialAddress partialAddress,
DimensionSizes iterationSizes)
Returns an iterator over all the cells in this tensor which matches the given partial address
|
Map<TensorAddress,Double> |
cells()
Returns an immutable map of the cells of this in no particular order.
|
DimensionSizes |
dimensionSizes() |
boolean |
equals(Object other)
Returns whether this tensor and the given tensor is mathematically equal:
That they have the same dimension *names* and the same content.
|
double |
get(int... indexes)
Returns the value at the given indexes
|
private double |
get(int valueIndex) |
double |
get(TensorAddress address)
Returns the value at this address, or NaN if there is no value at this address
|
int |
hashCode() |
private static int |
productOfDimensionsAfter(int afterIndex,
DimensionSizes sizes) |
int |
size()
Returns the number of cells in this
|
Iterator<IndexedTensor.SubspaceIterator> |
subspaceIterator(Set<String> dimensions)
Returns a subspace iterator having the sizes of the dimensions of this tensor
|
Iterator<IndexedTensor.SubspaceIterator> |
subspaceIterator(Set<String> dimensions,
DimensionSizes sizes)
Returns an iterator over value iterators where the outer iterator is over each unique value of the dimensions
given and the inner iterator is over each unique value of the rest of the dimensions, in the same order as
other iterator.
|
String |
toString()
Returns this tensor on the form
{address1:value1,address2:value2,...}
where each address is on the form {dimension1:label1,dimension2:label2,...} ,
and values are numbers. |
private static int |
toValueIndex(int[] indexes,
DimensionSizes sizes) |
private static int |
toValueIndex(TensorAddress address,
DimensionSizes sizes) |
TensorType |
type() |
Iterator<Double> |
valueIterator()
Returns an iterator over the values of this.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
add, approxEqual, approxEquals, approxEquals, argmax, argmin, asDouble, atan2, avg, avg, concat, concat, contentToString, count, count, diag, divide, equal, equals, fmod, from, from, from, generate, isEmpty, join, l1Normalize, l2Normalize, larger, largerOrEqual, ldexp, map, matmul, max, max, max, min, min, min, multiply, notEqual, pow, prod, prod, random, range, reduce, reduce, rename, rename, smaller, smallerOrEqual, softmax, subtract, sum, sum, toStandardString, xwPlusB
private final TensorType type
private final DimensionSizes dimensionSizes
private final double[] values
private IndexedTensor(TensorType type, DimensionSizes dimensionSizes, double[] values)
public int size()
Tensor
public Iterator<Tensor.Cell> cellIterator()
cellIterator
in interface Tensor
public IndexedTensor.SubspaceIterator cellIterator(PartialAddress partialAddress, DimensionSizes iterationSizes)
public Iterator<Double> valueIterator()
valueIterator
in interface Tensor
public Iterator<IndexedTensor.SubspaceIterator> subspaceIterator(Set<String> dimensions, DimensionSizes sizes)
dimensions
- the names of the dimensions of the superspacesizes
- the size of each dimension in the space we are returning values for, containing
one value per dimension of this tensor (in order). Each size may be the same or smaller
than the corresponding size of this tensorpublic Iterator<IndexedTensor.SubspaceIterator> subspaceIterator(Set<String> dimensions)
public double get(int... indexes)
indexes
- the indexes into the dimensions of this. Must be one number per dimension of thisIndexOutOfBoundsException
- if any of the indexes are out of bound or a wrong number of indexes are givenpublic double get(TensorAddress address)
private double get(int valueIndex)
private static int toValueIndex(int[] indexes, DimensionSizes sizes)
private static int toValueIndex(TensorAddress address, DimensionSizes sizes)
private static int productOfDimensionsAfter(int afterIndex, DimensionSizes sizes)
public TensorType type()
public DimensionSizes dimensionSizes()
public Map<TensorAddress,Double> cells()
Tensor
public String toString()
Tensor
{address1:value1,address2:value2,...}
where each address is on the form {dimension1:label1,dimension2:label2,...}
,
and values are numbers.
Cells are listed in the natural order of tensor addresses: Increasing size primarily and by element lexical order secondarily.
Note that while this is suggestive of JSON, it is not JSON.
Copyright © 2017. All rights reserved.