T
- the parameterization lower bounded by ProtoSparseArray
itself.V
- the storage array type.E
- the element type.D
- the dense array type.public abstract class ProtoSparseArray<T extends ProtoSparseArray<T,V,E,D>,V,E,D extends Array<D,E>> extends Object implements Array<T,E>
Array.IndexingOrder
Modifier and Type | Field and Description |
---|---|
protected int[] |
dimOffsets
The dimension offsets.
|
protected int[] |
dims
The dimensions.
|
protected static int[] |
emptyIndices
An empty array of indices.
|
protected SparseArrayState<V> |
state
The
SparseArrayState . |
protected int[] |
strides
The strides.
|
Modifier | Constructor and Description |
---|---|
protected |
ProtoSparseArray(SparseArrayState<V> state,
int[] dims,
int[] strides,
int[] dimOffsets)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
T |
clone()
Copies this array.
|
T |
concat(int opDim,
T... srcs)
Concatenates this array with the given arrays along the given dimension.
|
protected static int[] |
createDimensionOffsets(int[] dims)
Creates dimension offsets from the given dimensions.
|
int[] |
dims()
Gets the dimensions.
|
protected abstract V |
empty()
Gets an empty array of values.
|
T |
insert(V values,
int... logicals)
Inserts values at the given logical indices, which are given in row major order.
|
protected abstract int |
length(V values)
Gets the length of the given array.
|
T |
map(T dst,
int... bounds)
Maps this array into a destination array.
|
int |
nDims()
Gets the number of dimensions.
|
Array.IndexingOrder |
order()
Gets the storage order of this array.
|
T |
reshape(int... dims)
Reshapes this array.
|
T |
reverse(int... opDims)
Reverses along the given dimensions.
|
T |
reverseOrder()
Creates an array where the storage order is reversed.
|
T |
shift(int... shifts)
Circularly shifts this array.
|
int |
size()
Gets the number of nonzero elements.
|
int |
size(int i)
Gets the size along the given dimension.
|
T |
slice(E value,
int[]... srcSlices)
Slices a value into this array.
|
T |
slice(int[]... srcSlices)
Gets a subarray specified by the given slicing indices.
|
T |
slice(int[][] srcSlices,
T dst,
int[][] dstSlices)
Slices this array into a destination array.
|
T |
slice(T dst,
int[]... dstSlices)
Slices this entire array into a destination array.
|
T |
splice(T dst,
int... slices)
A primitive slicing operation.
|
int |
stride(int i)
Gets the stride along the given dimension.
|
int[] |
strides()
Gets the strides.
|
T |
subarray(int... bounds)
Gets a subarray delimited by the given bounds.
|
T |
tile(int... repetitions)
Tiles this array according to the given number repetitions along each dimension.
|
abstract D |
toDense()
Converts this array to its dense form.
|
T |
transpose(int... permutation)
Transposes (permutes) the dimensions of this array.
|
protected abstract T |
wrap(E value,
int[] dims,
int[] strides,
int[] dimOffsets)
Allocates a new array initialized to the given value.
|
protected abstract T |
wrap(SparseArrayState<V> state,
int[] dims,
int[] strides,
int[] dimOffsets)
Allocates a new array.
|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getComponentType, toString
protected static final int[] emptyIndices
protected volatile SparseArrayState<V> state
SparseArrayState
.protected final int[] dims
protected final int[] strides
protected final int[] dimOffsets
protected ProtoSparseArray(SparseArrayState<V> state, int[] dims, int[] strides, int[] dimOffsets)
protected static final int[] createDimensionOffsets(int[] dims)
dims
- the dimensions.protected abstract T wrap(SparseArrayState<V> state, int[] dims, int[] strides, int[] dimOffsets)
state
- the SparseArrayState
.dims
- the dimensions.strides
- the strides.dimOffsets
- the dimension offsets.protected abstract T wrap(E value, int[] dims, int[] strides, int[] dimOffsets)
value
- the initial value.dims
- the dimensions.strides
- the strides.dimOffsets
- the dimension offsets.protected abstract int length(V values)
values
- the array.protected abstract V empty()
public abstract D toDense()
public T insert(V values, int... logicals)
values
- the values.logicals
- the logical indices.public int size()
public T map(T dst, int... bounds)
Array
map
in interface Array<T extends ProtoSparseArray<T,V,E,D>,E>
dst
- the destination array.bounds
- the mapping bounds as an array of three-tuples. Given the i
th tuple, the first component
denotes the source start, the second component denotes the destination start, and the third component
denotes the mapping size. Is very much the multidimensional analogy to
System.arraycopy(Object, int, Object, int, int)
.public T splice(T dst, int... slices)
Array
splice
in interface Array<T extends ProtoSparseArray<T,V,E,D>,E>
dst
- the destination array.slices
- the slicing specifications as an array of three-tuples. Given the i
th tuple, the first
component denotes the source index, the second component denotes the destination index, and the third
component denotes the dimension of interest. The sliced portion is the Cartesian product subarray
delineated by these specifications.public T slice(int[][] srcSlices, T dst, int[][] dstSlices)
Array
public T slice(T dst, int[]... dstSlices)
Array
public T slice(E value, int[]... srcSlices)
Array
public T slice(int[]... srcSlices)
Array
public T tile(int... repetitions)
Array
public T transpose(int... permutation)
Array
public T shift(int... shifts)
Array
public T subarray(int... bounds)
Array
public T reverse(int... opDims)
Array
public T concat(int opDim, T... srcs)
Array
public Array.IndexingOrder order()
Array
public int size(int i)
Array
public int stride(int i)
Array
public int nDims()
Array
public int[] dims()
Array
public int[] strides()
Array