MutableStructure1D

A mutable structure that is guaranteed to be one-dimensional

Functions

Link copied to clipboard

Represent a StructureND as Structure1D. Throw error in case of dimension mismatch.

Link copied to clipboard

Represents a StructureND as Structure2D. Throws runtime error in case of dimension mismatch.

Link copied to clipboard

Creates an iterable that returns all elements from this Buffer.

Link copied to clipboard

Creates an n × 1 VirtualMatrix, where n is the size of the given buffer.

Link copied to clipboard
fun <T> Buffer<T>.asND(): Structure1D<T>

Represent this buffer as 1D structure

Link copied to clipboard

Convert this buffer to read-only buffer.

Link copied to clipboard

Creates a sequence that returns all elements from this Buffer.

Link copied to clipboard
inline fun <T1, T2, R> Buffer<T1>.combineToBuffer(other: Buffer<T2>, bufferFactory: BufferFactory<R>, crossinline transform: (T1, T2) -> R): Buffer<R>

Zip two buffers using given transform.

Link copied to clipboard
abstract fun copy(): MutableBuffer<T>

Returns a shallow copy of the buffer.

Link copied to clipboard
fun <T> Buffer<T>.cumulativeSum(ring: Ring<T>): Buffer<T>
Link copied to clipboard
operator fun Point<Double>.div(value: Double): DoubleBuffer

open operator override fun StructureND<Double>.div(arg: Double): DoubleBufferND

Divides an ND structure by an element of it.

open operator override fun StructureND<Double>.div(k: Number): DoubleBufferND
open operator fun Buffer<Double>.div(k: Number): Buffer<Double>

Division of this element by scalar.

open operator override fun StructureND<Double>.div(arg: StructureND<Double>): DoubleBufferND
open operator fun Buffer<Double>.div(arg: Buffer<Double>): Buffer<Double>

Division of two elements.

Link copied to clipboard

Returns the sequence of all the elements associated by their indices.

Link copied to clipboard
fun <T> Buffer<T>.expand(range: IntRange, defaultValue: T): BufferView<T>

Resize original buffer to a given range using given range, filling additional segments with defaultValue. Range left border could be negative to designate adding new blank segment to the beginning of the buffer

Link copied to clipboard
fun <T> Buffer<T>.first(): T
Link copied to clipboard
inline fun <T, R> Buffer<T>.fold(initial: R, operation: (acc: R, T) -> R): R

Fold given buffer according to operation

Link copied to clipboard
inline fun <T : Any, R> Buffer<T>.foldIndexed(initial: R, operation: (index: Int, acc: R, T) -> R): R

Fold given buffer according to indexed operation

Link copied to clipboard
open operator override fun get(index: IntArray): T

Returns the value at the specified indices.

abstract operator fun get(index: Int): T

Gets element at given index.

Link copied to clipboard
operator fun <T> StructureND<T>.get(vararg index: Int): T

Returns the value at the specified indices.

operator fun StructureND<Double>.get(vararg index: Int): Double
operator fun StructureND<Int>.get(vararg index: Int): Int
operator fun <T> Buffer<T>.get(index: UInt): T
Link copied to clipboard

Optimized method to access primitive without boxing if possible

Non-boxing access to primitive Double

Link copied to clipboard
open override fun <F : StructureFeature> getFeature(type: KClass<out F>): F?

Feature is some additional structure information that allows to access it special properties or hints. If the feature is not present, null is returned.

Link copied to clipboard

Non-boxing access to primitive Int

Link copied to clipboard
fun <T> Buffer<T>.getOrNull(index: Int): T?

if index is in range of buffer, return the value. Otherwise, return null.

Link copied to clipboard

Return a new array filled with buffer indices. Indices order is defined by sorting associated buffer value. This feature allows sorting buffer values without reordering its content.

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

Iterates over all elements.

Link copied to clipboard
fun <T> Buffer<T>.last(): T
Link copied to clipboard
@PerformancePitfall(message = "Very slow on remote execution algebras")
open fun StructureND<Int>.map(transform: IntRing.(Int) -> Int): StructureND<Int>

Maps elements from one structure to another one by applying transform to them.

@PerformancePitfall(message = "Very slow on remote execution algebras")
open fun StructureND<Short>.map(transform: ShortRing.(Short) -> Short): StructureND<Short>

Maps elements from one structure to another one by applying transform to them.

open override fun StructureND<Double>.map(transform: DoubleField.(Double) -> Double): BufferND<Double>

Maps elements from one structure to another one by applying transform to them.

inline override fun Buffer<Double>.map(block: DoubleField.(Double) -> Double): DoubleBuffer
Link copied to clipboard
@PerformancePitfall(message = "Very slow on remote execution algebras")
open fun StructureND<Double>.mapIndexed(transform: DoubleField.(index: IntArray, Double) -> Double): StructureND<Double>

Maps elements from one structure to another one by applying transform to them alongside with their indices.

@PerformancePitfall(message = "Very slow on remote execution algebras")
open fun StructureND<Int>.mapIndexed(transform: IntRing.(index: IntArray, Int) -> Int): StructureND<Int>

Maps elements from one structure to another one by applying transform to them alongside with their indices.

@PerformancePitfall(message = "Very slow on remote execution algebras")
open fun StructureND<Short>.mapIndexed(transform: ShortRing.(index: IntArray, Short) -> Short): StructureND<Short>

Maps elements from one structure to another one by applying transform to them alongside with their indices.

inline override fun Buffer<Double>.mapIndexed(block: DoubleField.(index: Int, arg: Double) -> Double): DoubleBuffer
Link copied to clipboard
inline fun <T, R> Buffer<T>.mapIndexedToBuffer(bufferFactory: BufferFactory<R>, crossinline block: (index: Int, value: T) -> R): Buffer<R>

Create a new buffer from this one with the given mapping (indexed) function. Provided bufferFactory is used to construct the new buffer.

Link copied to clipboard
inline fun <T, R> Buffer<T>.mapToBuffer(bufferFactory: BufferFactory<R>, crossinline block: (T) -> R): Buffer<R>

Create a new buffer from this one with the given mapping function. Provided bufferFactory is used to construct the new buffer.

Link copied to clipboard
open operator override fun Point<Double>.minus(other: Point<Double>): DoubleBuffer

Vector subtraction

open operator override fun StructureND<Double>.minus(arg: Double): StructureND<Double>
open operator fun StructureND<Int>.minus(arg: Int): StructureND<Int>
open operator fun StructureND<Short>.minus(arg: Short): StructureND<Short>

Subtracts an element from ND structure of it.

open operator override fun StructureND<Double>.minus(arg: StructureND<Double>): DoubleBufferND
open operator override fun Buffer<Double>.minus(arg: Buffer<Double>): DoubleBuffer
open operator fun StructureND<Int>.minus(arg: StructureND<Int>): StructureND<Int>

Subtraction of two elements.

Link copied to clipboard
fun <T> MutableStructureND<T>.permute(newShape: ShapeND = shape, permutation: (IntArray) -> IntArray): PermutedMutableStructureND<T>

Created a permuted view of given buffer using provided indices

Created a permuted mutable view of given buffer using provided indices

Link copied to clipboard
open operator override fun Point<Double>.plus(other: Point<Double>): DoubleBuffer

Vector sum

open operator override fun StructureND<Double>.plus(arg: Double): DoubleBufferND
open operator fun StructureND<Int>.plus(arg: Int): StructureND<Int>
open operator fun StructureND<Short>.plus(arg: Short): StructureND<Short>

Adds an ND structure to an element of it.

open operator override fun StructureND<Double>.plus(arg: StructureND<Double>): DoubleBufferND
open operator override fun Buffer<Double>.plus(arg: Buffer<Double>): DoubleBuffer
open operator fun StructureND<Int>.plus(arg: StructureND<Int>): StructureND<Int>

Addition of two elements.

Link copied to clipboard
open infix fun StructureND<Double>.pow(pow: Number): StructureND<Double>

Raises this value to the power pow.

open infix fun Buffer<Double>.pow(pow: Number): Buffer<Double>

Raises this value to the power pow.

Link copied to clipboard
inline fun <T> Buffer<T>.reduce(operation: (left: T, value: T) -> T): T

Reduce a buffer from left to right according to operation

Link copied to clipboard

Checks that the Buffer is sorted (ascending) and throws IllegalArgumentException if it is not.

Link copied to clipboard
fun <T> StructureND<T>.roll(axis: Int, step: Int = 1): StructureND<T>
fun <T> StructureND<T>.roll(pair: Pair<Int, Int>, vararg others: Pair<Int, Int>): StructureND<T>
Link copied to clipboard
open operator override fun set(index: IntArray, value: T)

Inserts an item at the specified indices.

abstract operator fun set(index: Int, value: T)

Sets the array element at the specified index to the specified value.

Link copied to clipboard
operator fun <T> MutableStructureND<T>.set(vararg index: Int, value: T)

Set value at specified indices

Link copied to clipboard
fun <T> Buffer<T>.slice(range: IntRange): BufferView<T>

Zero-copy select a slice inside the original buffer

Link copied to clipboard

Create a zero-copy virtual buffer that contains the same elements but in ascending order

Link copied to clipboard
fun <V, C : Comparable<C>> Buffer<V>.sortedBy(selector: (V) -> C): Buffer<V>
Link copied to clipboard
fun <V, C : Comparable<C>> Buffer<V>.sortedByDescending(selector: (V) -> C): Buffer<V>
Link copied to clipboard

Create a zero-copy virtual buffer that contains the same elements but in descending order

Link copied to clipboard
open operator override fun Point<Double>.times(value: Double): DoubleBuffer

Multiplies a vector by its element.

open operator override fun StructureND<Double>.times(k: Number): DoubleBufferND
open operator fun Buffer<Double>.times(k: Number): Buffer<Double>

Multiplication of this element by a scalar.

open operator override fun StructureND<Double>.times(arg: StructureND<Double>): DoubleBufferND
open operator fun StructureND<Int>.times(arg: StructureND<Int>): StructureND<Int>
open operator fun Buffer<Double>.times(arg: Buffer<Double>): Buffer<Double>

Multiplies this element by scalar.

open operator fun StructureND<Double>.times(arg: Double): StructureND<Double>
open operator fun StructureND<Int>.times(arg: Int): StructureND<Int>
open operator fun StructureND<Short>.times(arg: Short): StructureND<Short>

Multiplies an ND structure by an element of it.

Link copied to clipboard
Link copied to clipboard

Returns a new ByteArray containing all the elements of this Buffer.

Link copied to clipboard

Returns a new DoubleArray containing all the elements of this Buffer.

Link copied to clipboard

Represent this buffer as DoubleBuffer. Does not guarantee that changes in the original buffer are reflected on this buffer.

Link copied to clipboard

Returns a new FloatArray containing all the elements of this Buffer.

Link copied to clipboard

Returns a new IntArray containing all the elements of this Buffer.

Link copied to clipboard
fun <T> Buffer<T>.toList(): List<T>

Returns a new List containing all elements of this buffer.

Link copied to clipboard

Returns a new LongArray containing all the elements of this Buffer.

Link copied to clipboard

Returns a new MutableList filled with all elements of this buffer. NOTE: this method uses a protective copy, so it should not be used in performance-critical code.

Link copied to clipboard

Returns a new ShortArray containing all the elements of this Buffer.

Link copied to clipboard

Returns a new Array containing all elements of this buffer. NOTE: this method uses a protective copy, so it should not be used in performance-critical code.

Link copied to clipboard
open operator fun Point<Double>.unaryMinus(): Point<Double>

open operator override fun StructureND<Int>.unaryMinus(): StructureND<Int>
open operator override fun StructureND<Short>.unaryMinus(): StructureND<Short>
open operator override fun StructureND<Double>.unaryMinus(): DoubleBufferND
open operator override fun Buffer<Double>.unaryMinus(): DoubleBuffer

The negation of this element.

Link copied to clipboard
open operator override fun StructureND<Double>.unaryPlus(): DoubleBufferND
open operator fun StructureND<Int>.unaryPlus(): StructureND<Int>
open operator fun Buffer<Double>.unaryPlus(): Buffer<Double>

Returns this value.

Link copied to clipboard
inline override fun Buffer<Double>.zip(other: Buffer<Double>, block: DoubleField.(left: Double, right: Double) -> Double): DoubleBuffer

Properties

Link copied to clipboard
open override val dimension: Int

The count of dimensions in this structure. It should be equal to size of shape.

Link copied to clipboard
Link copied to clipboard

Returns an IntRange of the valid indices for this Buffer.

Link copied to clipboard
abstract override val shape: ShapeND

The shape of structure i.e., non-empty sequence of non-negative integers that specify sizes of dimensions of this structure.

Link copied to clipboard
abstract override val size: Int

The size of this buffer.