Class F64FlatArray
-
- All Implemented Interfaces:
public class F64FlatArray extends F64Array
An 1-dimensional specialization of F64Array.
- Since:
0.4.0
-
-
Method Summary
Modifier and Type Method Description Doubleget(Integer pos)Unitset(Integer pos, Double value)F64FlatArrayflatten()Flattens the array into a 1D view in O(1) time. Booleancontains(Double other)Voidalong(Integer axis)Returns a sequence of views along the specified axis. Voidview(Integer index, Integer axis)Returns a view of this array along the specified axis. UnitcopyTo(F64Array other)Copies elements in this array to other array. F64FlatArraycopy()Returns a copy of this array. Unitfill(Double init)Fills this array with a given init value. Unitreorder(IntArray indices, Integer axis)Applies a given permutation of indices to the elements in the array. Doubledot(ShortArray other)Computes a dot product between two vectors. Doubledot(IntArray other)Computes a dot product between two vectors. Doubledot(F64Array other)Computes a dot product between two vectors. Doublesum()Returns the sum of the elements. UnitcumSum()Computes cumulative sum of the elements. Doublemin()Returns the minimum element. IntegerargMin()Returns the index of the minimum element. Doublemax()Returns the maximum element. IntegerargMax()Returns the index of the maximum element. UnittransformInPlace(Function1<Double, Double> op)Replaces each element x of this array with op(x) for the given unary operation op. F64FlatArraytransform(Function1<Double, Double> op)A copying version of transformInPlace. <T extends Any> Tfold(T initial, Function2<T, Double, T> op)Folds the array using the provided initial value and the folding operation op. Doublereduce(Function2<Double, Double, Double> op)Reduces the array using the provided reduction operation op. UnitcombineInPlace(F64Array other, Function2<Double, Double, Double> op)Apply the binary operation op in-place. F64FlatArraycombine(F64Array other, Function2<Double, Double, Double> op)Apply the binary operation op and return a new array. F64FlatArrayexp()A copying version of expInPlace. F64FlatArrayexpm1()A copying version of expm1InPlace. F64FlatArraylog()A copying version of logInPlace. F64FlatArraylog1p()A copying version of log1pInPlace. DoublelogSumExp()Computes
in a numerically stable way.log(Σ_x exp(x))UnitlogAddExpAssign(F64Array other)Plus-assign for values stored as logarithms. F64FlatArraylogAddExp(F64Array other)Computes elementwise
in a numerically stable way.log(exp(this[*i]) + exp(other[*i]))UnitplusAssign(F64Array other)F64FlatArrayplus(F64Array other)UnitminusAssign(F64Array other)F64FlatArrayminus(F64Array other)UnittimesAssign(F64Array other)F64FlatArraytimes(F64Array other)UnitdivAssign(F64Array other)F64FlatArraydiv(F64Array other)F64Arrayreshape(Integer shape)Reshapes this array. DoubleArraytoArray()Converts this array to a conventional Kotlin structure. VoidtoGenericArray()Converts this array to an Array. DoubleArraytoDoubleArray()Converts this vector to a DoubleArray. StringtoString(Integer maxDisplay, DecimalFormat format)Creates a String representation of the given array. Booleanequals(Object other)<Error class: unknown class>hashCode()-
Methods inherited from class org.jetbrains.bio.viktor.F64Array
append, div, divAssign, dot, expInPlace, expm1InPlace, get, get, get, getData, getLength, getNDim, getOffset, getShape, getStrides, getV, isFlattenable, log1pInPlace, logInPlace, logRescale, mean, minus, minusAssign, plus, plusAssign, rescale, sd, set, set, set, slice, times, timesAssign, toString, unaryMinus, unaryPlus -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
flatten
F64FlatArray flatten()
Flattens the array into a 1D view in O(1) time.
Only implemented for flattenable arrays.
Viewer method.
-
along
Void along(Integer axis)
Returns a sequence of views along the specified axis.
For example, for a 2D array
axis = 0means "for each row", andaxis = 1"for each column".The array must have at least two dimensions.
Viewer method.
-
view
Void view(Integer index, Integer axis)
Returns a view of this array along the specified axis.
The array must have at least two dimensions. Consider using V with easier syntax.
Viewer method.
-
copy
F64FlatArray 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.
-
reorder
Unit reorder(IntArray indices, Integer axis)
Applies a given permutation of indices to the elements in the array.
In-place method.
-
dot
Double dot(ShortArray other)
Computes a dot product between two vectors.
Only implemented for flat arrays.
-
dot
Double dot(IntArray other)
Computes a dot product between two vectors.
Only implemented for flat arrays.
-
dot
Double dot(F64Array other)
Computes a dot product between two vectors.
Only implemented for flat arrays. Optimized for dense arrays.
-
cumSum
Unit cumSum()
Computes cumulative sum of the elements.
In-place method. Only implemented for flat arrays.
-
min
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.
-
argMin
Integer 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.
-
max
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.
-
argMax
Integer 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.
-
transformInPlace
Unit transformInPlace(Function1<Double, 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.
- Parameters:
op- the unary operation to be applied.- Since:
1.0.3
-
transform
F64FlatArray transform(Function1<Double, 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.
- Parameters:
op- the unary operation to be applied.- Since:
1.0.3
-
fold
<T extends Any> T fold(T initial, Function2<T, Double, T> op)
Folds the array using the provided initial value and the folding operation op.
Equivalent to the following pseudo-code:
var res = initial for (value in array) res = op(res, value) return resIf you need to fold using one of the
plus,max, orminwith standard initial values, use the appropriate specialized method instead (see the list below); these will generally be much more efficient.- Parameters:
initial- the starting value of the fold.op- the folding binary operation.- Since:
1.2.0
-
reduce
Double reduce(Function2<Double, Double, Double> op)
Reduces the array using the provided reduction operation op.
Equivalent to the following pseudo-code:
var res = first_element for (value in remaining_elements) res = op(res, value) return resIf you need to reduce using one of the
plus,max, ormin, use the appropriate specialized method instead (see the list below); these will generally be much more efficient.- Parameters:
op- the binary reduction operation.- Since:
1.2.0
-
combineInPlace
Unit combineInPlace(F64Array other, Function2<Double, Double, Double> op)
Apply the binary operation op in-place.
If you need to apply an arithmetic operation (including logAddExp), use the appropriate specialized method instead (see the list below); these will generally be more efficient.
In-place method.
- Parameters:
other- the array to combine with.op- the binary operation.- Since:
1.2.0
-
combine
F64FlatArray combine(F64Array other, Function2<Double, Double, Double> op)
Apply the binary operation op and return a new array.
If you need to apply an arithmetic operation (including logAddExp), use the appropriate specialized method instead (see the list below); these will generally be more efficient.
Copying method.
- Parameters:
other- the array to combine with.op- the binary operation.- Since:
1.2.0
-
exp
F64FlatArray exp()
A copying version of expInPlace.
Copying method. Optimized for dense arrays.
-
expm1
F64FlatArray expm1()
A copying version of expm1InPlace.
Copying method. Optimized for dense arrays.
-
log
F64FlatArray log()
A copying version of logInPlace.
Copying method. Optimized for dense arrays.
-
log1p
F64FlatArray log1p()
A copying version of log1pInPlace.
Copying method. Optimized for dense arrays.
-
logAddExpAssign
Unit logAddExpAssign(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.
-
logAddExp
F64FlatArray logAddExp(F64Array other)
Computes elementwise
log(exp(this[*i]) + exp(other[*i]))in a numerically stable way.
Copying method.
-
plusAssign
Unit plusAssign(F64Array other)
-
plus
F64FlatArray plus(F64Array other)
-
minusAssign
Unit minusAssign(F64Array other)
-
minus
F64FlatArray minus(F64Array other)
-
timesAssign
Unit timesAssign(F64Array other)
-
times
F64FlatArray times(F64Array other)
-
div
F64FlatArray div(F64Array other)
-
reshape
F64Array reshape(Integer 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.
-
toArray
DoubleArray toArray()
Converts this array to a conventional Kotlin structure.
For example, a vector will be converted to a DoubleArray, a matrix will become
Array<DoubleArray>etc.Copying method.
-
toGenericArray
Void toGenericArray()
Converts this array to an Array.
For example, a matrix will become
Array<DoubleArray>etc.Copying method. Not implemented for flat arrays.
-
toDoubleArray
DoubleArray toDoubleArray()
Converts this vector to a DoubleArray.
Copying method. Only implemented for flat arrays.
-
toString
String toString(Integer maxDisplay, DecimalFormat format)
Creates a String representation of the given array.
At most maxDisplay elements are printed for each dimension.
-
hashCode
<Error class: unknown class> hashCode()
-
-
-
-