public abstract class Indexer extends Object
Subclasses have create()
factory methods for arrays, buffers, and pointers.
The latter ones feature a direct
argument that, when set to false
,
instructs the method to create a large enough array, fill its content with the data
from the pointer, and return an array-backed indexer, with the release()
method overridden to write back changes to the pointer. This double the memory
usage, but is the only way to get acceptable performance on some implementations,
such as Android. When direct == true
, a buffer-backed indexer is returned.
Modifier and Type | Field and Description |
---|---|
protected int[] |
sizes
The number of elements in each dimension.
|
protected int[] |
strides
The number of elements to skip to reach the next element in a given dimension.
|
Modifier | Constructor and Description |
---|---|
protected |
Indexer(int[] sizes,
int[] strides)
|
Modifier and Type | Method and Description |
---|---|
Object |
array() |
Buffer |
buffer() |
int |
channels() |
int |
cols() |
abstract double |
getDouble(int... indices)
Calls
get(int...indices) and returns the value as a double. |
int |
height() |
int |
index(int... indices)
Computes the linear index as the dot product of indices and strides.
|
abstract void |
release()
Makes sure changes are reflected onto the backing memory and releases any references.
|
int |
rows() |
int[] |
sizes() |
int[] |
strides() |
String |
toString() |
int |
width() |
protected int[] sizes
protected int[] strides
strides[i] > strides[i + 1] && strides[strides.length - 1] == 1
must hold.public int[] sizes()
sizes
public int[] strides()
strides
public int rows()
sizes[0]
public int cols()
sizes[1]
public int width()
sizes[1]
public int height()
sizes[0]
public int channels()
sizes[2]
public int index(int... indices)
indices
- of each dimensionpublic Object array()
null
if nonepublic Buffer buffer()
null
if nonepublic abstract void release()
public abstract double getDouble(int... indices)
get(int...indices)
and returns the value as a double.Copyright © 2014. All Rights Reserved.