public class F64Array
A strided n-dimensional array stored in a DoubleArray.
The term strided means that unlike regular DoubleArray the
elements of an class F64Array can be at arbitrary index intervals
(strides) from each other. For example
data = [0, 1, 2, 3, 4, 5]
offset = 1
shape = [2]
strides = [3]
corresponds to a 1-D array with elements
[1, 4]
Due to instantiation contracts, the actual instance of this exact class will always be non-flat, i.e.
have at least two dimensions. One-dimensional array will be class F64FlatArray (or possibly a descendant of that),
and zero-dimensional (singleton) arrays are not allowed.
Method tags:
"in-place": this operation will modify the array
"copying": this operation creates a copy fully independent from the original array
"viewer": this operation creates a new array which shares data with the original one; modifications to one will be seen through the other, and no copying is performed
class F64Array,
class F64FlatArray| Modifier and Type | Class and Description |
|---|---|
static class |
F64Array.Companion |
static class |
F64Array.Viewer |
| Modifier and Type | Field and Description |
|---|---|
static F64Array.Companion |
Companion |
| Modifier | Constructor and Description |
|---|---|
protected |
F64Array(kotlin.Array[] data,
int offset,
kotlin.Array[] strides,
kotlin.Array[] shape,
int unrollDim,
int unrollStride,
int unrollSize)
A strided n-dimensional array stored in a DoubleArray.
|
| Modifier and Type | Method and Description |
|---|---|
kotlin.sequences.Sequence<org.jetbrains.bio.viktor.F64Array> |
along(int axis)
Returns a sequence of views along the specified
axis. |
F64Array |
append(F64Array other,
int axis)
Appends this array to another array.
|
int |
argMax()
Returns the index of the maximum element.
|
int |
argMin()
Returns the index of the minimum element.
|
boolean |
contains(double other) |
F64Array |
copy()
Returns a copy of this array.
|
void |
copyTo(F64Array other)
Copies elements in this array to
other array. |
void |
cumSum()
Computes cumulative sum of the elements.
|
F64Array |
div(F64Array other) |
F64Array |
div(double update) |
void |
divAssign(F64Array other) |
void |
divAssign(double update) |
double |
dot(kotlin.Array[] other)
Computes a dot product between two vectors.
|
double |
dot(kotlin.Array[] other)
Computes a dot product between two vectors.
|
double |
dot(kotlin.Array[] other)
Computes a dot product between two vectors.
|
double |
dot(F64Array other)
Computes a dot product between two vectors.
|
boolean |
equals(java.lang.Object other) |
F64Array |
exp()
A copying version of
expInPlace. |
void |
expInPlace()
Replaces each element x of this array with its exponent exp(x).
|
F64Array |
expm1()
A copying version of
expm1InPlace. |
void |
expm1InPlace()
Replaces each element x of this array with exp(x) - 1.
|
void |
fill(double init)
Fills this array with a given
init value. |
F64FlatArray |
flatten()
Flattens the array into a 1D view in O(1) time.
|
double |
get(int... indices)
Generic getter.
|
double |
get(int pos) |
double |
get(int r,
int c) |
double |
get(int d,
int r,
int c) |
kotlin.Array[] |
getData()
Raw data array.
|
int |
getNDim()
Number of axes in this array.
|
int |
getOffset()
Offset of the first vector element in the raw data array.
|
kotlin.Array[] |
getShape()
Number of elements along each axis.
|
int |
getSize()
Number of elements along the first axis.
|
kotlin.Array[] |
getStrides()
Indexing steps along each axis.
|
F64Array.Viewer |
getV()
A broadcasted viewer for this array.
|
int |
hashCode() |
boolean |
isFlattenable()
Returns
true if this array can be flattened using flatten. |
F64Array |
log()
A copying version of
logInPlace. |
F64Array |
log1p()
A copying version of
log1pInPlace. |
void |
log1pInPlace()
Replaces each element x of this array with log(1 + x).
|
F64Array |
logAddExp(F64Array other)
Computes elementwise
|
void |
logAddExpAssign(F64Array other)
Plus-assign for values stored as logarithms.
|
void |
logInPlace()
Replaces each element x of this array with its natural logarithm log(x).
|
void |
logRescale()
Rescales the elements so that the sum of their exponents is 1.0.
|
double |
logSumExp()
Computes
|
double |
max()
Returns the maximum element.
|
double |
mean()
Computes the mean of the elements.
|
double |
min()
Returns the minimum element.
|
F64Array |
minus(F64Array other) |
F64Array |
minus(double update) |
void |
minusAssign(F64Array other) |
void |
minusAssign(double update) |
F64Array |
plus(F64Array other) |
F64Array |
plus(double update) |
void |
plusAssign(F64Array other) |
void |
plusAssign(double update) |
void |
reorder(kotlin.Array[] indices,
int axis)
Applies a given permutation of indices to the elements in the array.
|
void |
rescale()
Rescales the elements so that the sum is 1.0.
|
F64Array |
reshape(int... shape)
Reshapes this array.
|
double |
sd()
Computes the unbiased standard deviation of the elements.
|
void |
set(kotlin.Array[] indices,
double value)
Generic setter.
|
void |
set(int pos,
double value) |
void |
set(int r,
int c,
double value) |
void |
set(int d,
int r,
int c,
double value) |
F64Array |
slice(int from,
int to,
int step,
int axis)
Creates a sliced view of this array in O(1) time.
|
double |
sum()
Returns the sum of the elements.
|
F64Array |
times(F64Array other) |
F64Array |
times(double update) |
void |
timesAssign(F64Array other) |
void |
timesAssign(double update) |
java.lang.Object |
toArray()
Converts this array to a conventional Kotlin structure.
|
kotlin.Array[] |
toDoubleArray()
Converts this vector to a DoubleArray.
|
java.lang.Object[] |
toGenericArray()
Converts this array to an Array.
|
java.lang.String |
toString(int maxDisplay,
java.text.DecimalFormat format)
Creates a String representation of the given array.
|
java.lang.String |
toString() |
F64Array |
transform(kotlin.jvm.functions.Function1<? super java.lang.Double,java.lang.Double> op)
A copying version of
transformInPlace. |
void |
transformInPlace(kotlin.jvm.functions.Function1<? super java.lang.Double,java.lang.Double> op)
Replaces each element x of this array with op(x) for the given unary operation
op. |
F64Array |
unaryMinus() |
F64Array |
unaryPlus() |
F64Array |
view(int index,
int axis)
Returns a view of this array along the specified
axis. |
public static F64Array.Companion Companion
protected F64Array(@NotNull
kotlin.Array[] data,
int offset,
@NotNull
kotlin.Array[] strides,
@NotNull
kotlin.Array[] shape,
int unrollDim,
int unrollStride,
int unrollSize)
A strided n-dimensional array stored in a DoubleArray.
The term strided means that unlike regular DoubleArray the
elements of an class F64Array can be at arbitrary index intervals
(strides) from each other. For example
data = [0, 1, 2, 3, 4, 5]
offset = 1
shape = [2]
strides = [3]
corresponds to a 1-D array with elements
[1, 4]
Due to instantiation contracts, the actual instance of this exact class will always be non-flat, i.e.
have at least two dimensions. One-dimensional array will be class F64FlatArray (or possibly a descendant of that),
and zero-dimensional (singleton) arrays are not allowed.
Method tags:
"in-place": this operation will modify the array
"copying": this operation creates a copy fully independent from the original array
"viewer": this operation creates a new array which shares data with the original one; modifications to one will be seen through the other, and no copying is performed
data - Raw data array.offset - Offset of the first vector element in the raw data array.strides - Indexing steps along each axis.shape - Number of elements along each axis.unrollDim - The maximum number of dimensions suitable for unrolling, see unrollOnce.unrollStride - The stride of the maximum unrolled subarray sequence, see unrollOnce.unrollSize - The size of the maximum unrolled subarray sequence, see unrollOnce.class F64Array,
class F64FlatArraypublic int getNDim()
Number of axes in this array.
public int getSize()
Number of elements along the first axis.
public boolean isFlattenable()
Returns true if this array can be flattened using flatten.
Flattenable array's elements are laid out with a constant stride. This allows using simple loops when iterating.
Calling flatten on a non-flattenable array will produce an IllegalStateException.
A particular case of a flattenable array is a dense array whose elements occupy a contiguous block of memory. Large dense arrays employ native SIMD optimizations, see F64LargeDenseArray.
flatten,
flatten,
IllegalStateExceptionpublic double get(@NotNull
int... indices)
Generic getter.
Note that it could be at least 1.5x slower than specialized versions for 1, 2 or 3 dimensions.
public double get(int pos)
public double get(int r,
int c)
public double get(int d,
int r,
int c)
public void set(@NotNull
kotlin.Array[] indices,
double value)
Generic setter.
Note that it could be at least 1.5x slower than specialized versions for 1, 2 or 3 dimensions.
public void set(int pos,
double value)
public void set(int r,
int c,
double value)
public void set(int d,
int r,
int c,
double value)
@NotNull public kotlin.sequences.Sequence<org.jetbrains.bio.viktor.F64Array> along(int axis)
Returns a sequence of views along the specified axis.
For example, for a 2D array axis = 0 means "for each row",
and axis = 1 "for each column".
The array must have at least two dimensions.
Viewer method.
axis@NotNull public F64Array view(int index, int axis)
@NotNull public F64Array.Viewer getV()
A broadcasted viewer for this array.
The main difference between
a...
and
a.V...
is that the array's getter/setter methods deal with scalar Double values, while the viewer's methods
deal with class F64Arrays. Another difference is that the viewer's methods can skip dimensions by providing
class _I object instead of an index.
Consider a matrix (2D array) a. Then the following invocations have the following effect:
a4 // fails, since it doesn't reference a scalar
a4,2 // returns a Double
a.V4 // returns 4th row
a.V_I,2 // returns 2nd column
a.V4,2 // fails, since it doesn't reference an array
@NotNull public F64Array copy()
Returns a copy of this array.
The copy has the same shape as the original, but not necessary the same strides, since the copy is always flattenable and dense, even if the original array is not.
Copying method.
@NotNull public F64Array reshape(@NotNull int... shape)
Reshapes this array.
The original and the new array contain the same elements in the same order, if both are enumerated row-major.
For example, F64Array.of(1.0, 2.0, 3.0, 4.0, 5.0, 6.0).reshape(2, 3) produces a 2x3 matrix: [ 1.0,2.0,3.0, 4.0,5.0,6.0 ]
Only supported for flattenable arrays.
Viewer method.
@NotNull public F64Array append(@NotNull F64Array other, int axis)
Appends this array to another array.
axis - the axis along which the arrays are appended.@NotNull public F64FlatArray flatten()
Flattens the array into a 1D view in O(1) time.
Only implemented for flattenable arrays.
Viewer method.
@NotNull public F64Array slice(int from, int to, int step, int axis)
Creates a sliced view of this array in O(1) time.
public boolean contains(double other)
public void fill(double init)
Fills this array with a given init value.
In-place method.
initpublic void reorder(@NotNull
kotlin.Array[] indices,
int axis)
Applies a given permutation of indices to the elements in the array.
In-place method.
public double dot(@NotNull
kotlin.Array[] other)
Computes a dot product between two vectors.
Only implemented for flat arrays.
public double dot(@NotNull
kotlin.Array[] other)
Computes a dot product between two vectors.
Only implemented for flat arrays.
public double dot(@NotNull
kotlin.Array[] other)
Computes a dot product between two vectors.
Only implemented for flat arrays. Optimized for dense arrays.
public double dot(@NotNull
F64Array other)
Computes a dot product between two vectors.
Only implemented for flat arrays. Optimized for dense arrays.
public double mean()
Computes the mean of the elements.
Optimized for dense arrays.
public double sd()
Computes the unbiased standard deviation of the elements.
Optimized for dense arrays.
public double sum()
Returns the sum of the elements.
Optimized for dense arrays.
public void cumSum()
Computes cumulative sum of the elements.
In-place method. Only implemented for flat arrays.
public double max()
Returns the maximum element.
If any of array elements is NaN, the result is undefined but will be one of the array elements.
Optimized for dense arrays.
public int argMax()
Returns the index of the maximum element.
If any of array elements is NaN, the result is undefined but will be a valid index.
Only implemented for flat arrays.
public double min()
Returns the minimum element.
If any of array elements is NaN, the result is undefined but will be one of the array elements.
Optimized for dense arrays.
public int argMin()
Returns the index of the minimum element.
If any of array elements is NaN, the result is undefined but will be a valid index.
Only implemented for flat arrays.
public void transformInPlace(@NotNull
kotlin.jvm.functions.Function1<? super java.lang.Double,java.lang.Double> op)
Replaces each element x of this array with op(x) for the given unary operation op.
If you need to apply one of the exp, expm1, log, log1p, use the appropriate specialized method instead
(see the list below); these will generally be much more efficient.
In-place method.
op - the unary operation to be applied.op,
expInPlace@NotNull public F64Array transform(@NotNull kotlin.jvm.functions.Function1<? super java.lang.Double,java.lang.Double> op)
A copying version of transformInPlace.
If you need to apply one of the exp, expm1, log, log1p, use the appropriate specialized method instead
(see the list below); these will generally be much more efficient.
Copying method.
op - the unary operation to be applied.transformInPlace,
exppublic void expInPlace()
Replaces each element x of this array with its exponent exp(x).
In-place method. Optimized for dense arrays.
@NotNull public F64Array exp()
A copying version of expInPlace.
Copying method. Optimized for dense arrays.
expInPlacepublic void expm1InPlace()
Replaces each element x of this array with exp(x) - 1.
In-place method. Optimized for dense arrays.
@NotNull public F64Array expm1()
A copying version of expm1InPlace.
Copying method. Optimized for dense arrays.
expm1InPlacepublic void logInPlace()
Replaces each element x of this array with its natural logarithm log(x).
In-place method. Optimized for dense arrays.
@NotNull public F64Array log()
A copying version of logInPlace.
Copying method. Optimized for dense arrays.
logInPlacepublic void log1pInPlace()
Replaces each element x of this array with log(1 + x).
In-place method. Optimized for dense arrays.
@NotNull public F64Array log1p()
A copying version of log1pInPlace.
Copying method. Optimized for dense arrays.
log1pInPlacepublic void rescale()
Rescales the elements so that the sum is 1.0.
In-place method.
public void logRescale()
Rescales the elements so that the sum of their exponents is 1.0.
In-place method.
public double logSumExp()
Computes
log(Σ_x exp(x))
in a numerically stable way.
public void logAddExpAssign(@NotNull
F64Array other)
Plus-assign for values stored as logarithms.
In other words, the same as invoking
this[*i] = log(exp(this[*i]) + exp(other[*i]))
for every valid i.
In-place method.
@NotNull public F64Array logAddExp(@NotNull F64Array other)
Computes elementwise
log(exp(this[*i]) + exp(other[*i]))
in a numerically stable way.
Copying method.
@NotNull public F64Array unaryPlus()
@NotNull public F64Array unaryMinus()
public void plusAssign(@NotNull
F64Array other)
public void plusAssign(double update)
@NotNull public F64Array plus(double update)
public void minusAssign(@NotNull
F64Array other)
public void minusAssign(double update)
@NotNull public F64Array minus(double update)
public void timesAssign(@NotNull
F64Array other)
public void timesAssign(double update)
@NotNull public F64Array times(double update)
public void divAssign(@NotNull
F64Array other)
public void divAssign(double update)
@NotNull public F64Array div(double update)
@NotNull public java.lang.Object toArray()
Converts this array to a conventional Kotlin structure.
For example, a vector will be converted to a DoubleArray, a matrix will become Array etc.
Copying method.
@NotNull public java.lang.Object[] toGenericArray()
Converts this array to an Array.
For example, a matrix will become Array etc.
Copying method. Not implemented for flat arrays.
@NotNull public kotlin.Array[] toDoubleArray()
Converts this vector to a DoubleArray.
Copying method. Only implemented for flat arrays.
@NotNull
public java.lang.String toString(int maxDisplay,
@NotNull
java.text.DecimalFormat format)
Creates a String representation of the given array.
At most maxDisplay elements are printed for each dimension.
maxDisplay@NotNull public java.lang.String toString()
public boolean equals(@Nullable
java.lang.Object other)
public int hashCode()
@NotNull public kotlin.Array[] getData()
Raw data array.
public int getOffset()
Offset of the first vector element in the raw data array.
@NotNull public kotlin.Array[] getStrides()
Indexing steps along each axis.
@NotNull public kotlin.Array[] getShape()
Number of elements along each axis.