NDArray

class NDArray<T, D : Dimension>(    data: ImmutableMemoryView<T>,     val offset: Int = 0,     val shape: IntArray,     val strides: IntArray = computeStrides(shape),     val dim: D,     val base: MultiArray<T, out Dimension>? = null) : MutableMultiArray<T, D>

A class that implements multidimensional arrays. This implementation is based on primitive arrays. With the help of offset, shape, strides there is a multidimensionality representation over a sequential homogeneous array.

Native code uses GetPrimitiveArrayCritical for calculation.

Parameters

T

type of stored values.

D

dimension.

Constructors

Link copied to clipboard
fun <T, D : Dimension> NDArray(    data: ImmutableMemoryView<T>,     offset: Int = 0,     shape: IntArray,     strides: IntArray = computeStrides(shape),     dim: D,     base: MultiArray<T, out Dimension>? = null)

Functions

Link copied to clipboard
fun asD1Array(): D1Array<T>
Link copied to clipboard
fun asD2Array(): D2Array<T>
Link copied to clipboard
fun asD3Array(): D3Array<T>
Link copied to clipboard
fun asD4Array(): D4Array<T>
Link copied to clipboard
fun asDNArray(): NDArray<T, DN>
Link copied to clipboard
inline fun <E : Number> asType(): NDArray<E, D>
fun <E : Number> asType(dataType: DataType): NDArray<E, D>
Link copied to clipboard
open infix override fun cat(other: MultiArray<T, D>): NDArray<T, D>

Concatenates this ndarray with other.

open override fun cat(other: List<MultiArray<T, D>>, axis: Int): NDArray<T, D>

Concatenates this ndarray with a list of other ndarrays.

open override fun cat(other: MultiArray<T, D>, axis: Int): NDArray<T, D>

Concatenates this ndarray with other along the specified axis.

Link copied to clipboard
open override fun copy(): NDArray<T, D>

Returns new MultiArray which is a copy of the original ndarray.

Link copied to clipboard
open override fun deepCopy(): NDArray<T, D>

Returns new MultiArray which is a deep copy of the original ndarray.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun flatten(): MultiArray<T, D1>

Returns new one-dimensional ndarray which is a copy of the original ndarray.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun isEmpty(): Boolean

Returns true if this ndarray is empty.

Link copied to clipboard
open override fun isNotEmpty(): Boolean

Returns true if this ndarray is not empty.

Link copied to clipboard
open override fun isScalar(): Boolean

Returns true if the array contains only one element, otherwise false.

Link copied to clipboard
open operator override fun iterator(): Iterator<T>
Link copied to clipboard
open override fun reshape(dim1: Int): D1Array<T>

Returns an ndarray with a new (dim1) shape without changing data.

open override fun reshape(dim1: Int, dim2: Int): D2Array<T>

Returns an ndarray with a new (dim1, dim2) shape without changing data.

open override fun reshape(    dim1: Int,     dim2: Int,     dim3: Int): D3Array<T>

Returns an ndarray with a new (dim1, dim2, dim3) shape without changing data.

open override fun reshape(    dim1: Int,     dim2: Int,     dim3: Int,     dim4: Int): D4Array<T>

Returns an ndarray with a new (dim1, dim2, dim3, dim4) shape without changing data.

open override fun reshape(    dim1: Int,     dim2: Int,     dim3: Int,     dim4: Int,     vararg dims: Int): NDArray<T, DN>

Returns an ndarray with a new (dim1, dim2, dim3, dim4, dims) shape without changing data.

Link copied to clipboard
open override fun squeeze(vararg axes: Int): NDArray<T, DN>

Returns an ndarray with all axes removed equal to one.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open override fun transpose(vararg axes: Int): NDArray<T, D>

Reverse or permute the axes of an array.

Link copied to clipboard
open override fun unsqueeze(vararg axes: Int): NDArray<T, DN>

Returns a new ndarray with a dimension of size one inserted at the specified axes.

Properties

Link copied to clipboard
open override val base: MultiArray<T, out Dimension>? = null

Base array if data is taken from other array. Otherwise - null.

Link copied to clipboard
open override val consistent: Boolean

indicates whether the array data is homogeneous.

Link copied to clipboard
open override val data: MemoryView<T>
Link copied to clipboard
open override val dim: D
Link copied to clipboard
open override val indices: IntRange

indices for a one-dimensional ndarray.

Link copied to clipboard
open override val multiIndices: MultiIndexProgression

indices for a n-dimensional ndarray.

Link copied to clipboard
open override val offset: Int = 0

Offset from the start of an ndarray's data.

Link copied to clipboard
open override val shape: IntArray

IntArray of an ndarray dimensions.

Link copied to clipboard
open override val size: Int

number of elements in an ndarray.

Link copied to clipboard
open override val strides: IntArray

IntArray indices to step in each dimension when iterating an ndarray.

Extensions

Link copied to clipboard
fun <T : Number, D : Dimension> NDArray<T, D>.inplace(init: InplaceOperation<T, D>.() -> Unit)