StructureND

interface StructureND<out T> : Featured<StructureFeature> , WithShape

Represents n-dimensional structure i.e., multidimensional container of items of the same type and size. The number of dimensions and items in an array is defined by its shape, which is a sequence of non-negative integers that specify the sizes of each dimension.

StructureND is in general identity-free. StructureND.contentEquals should be used in tests to compare contents.

Parameters

T

the type of items.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open fun elements(): Sequence<Pair<IntArray, T>>

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

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

Returns the value at the specified indices.

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.

Properties

Link copied to clipboard
open val dimension: Int

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

Link copied to clipboard
open val indices: ShapeIndexer
Link copied to clipboard
abstract override val shape: Shape

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

Inheritors

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Extensions

Link copied to clipboard
fun <T> StructureND<T>.as1D(): Structure1D<T>

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

Link copied to clipboard
fun <T> StructureND<T>.as2D(): Structure2D<T>

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

Link copied to clipboard
open operator override fun StructureND<Double>.div(arg: StructureND<Double>): DoubleBufferND

Division of two elements.

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

Division of this element by scalar.

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

Returns the value at the specified indices.

Link copied to clipboard
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.

@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.

Link copied to clipboard
@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.

@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.

Link copied to clipboard
inline fun <T, R : Any> StructureND<T>.mapToBuffer(factory: BufferFactory<R>, crossinline transform: (T) -> R): BufferND<R>

Transform structure to a new structure using provided BufferFactory and optimizing if argument is BufferND

inline fun <T, R : Any> StructureND<T>.mapToBuffer(crossinline transform: (T) -> R): BufferND<R>

Transform structure to a new structure using inferred BufferFactory

Link copied to clipboard
open operator fun StructureND<Short>.minus(arg: Short): StructureND<Short>
open operator override fun StructureND<Double>.minus(arg: Double): StructureND<Double>

Subtracts an element from ND structure of it.

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

Subtraction of two elements.

Link copied to clipboard
open operator fun StructureND<Short>.plus(arg: Short): StructureND<Short>
open operator override fun StructureND<Double>.plus(arg: Double): DoubleBufferND

Adds an ND structure to an element of it.

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

Addition of two elements.

Link copied to clipboard
open operator fun StructureND<Short>.times(arg: Short): StructureND<Short>
open operator fun StructureND<Double>.times(arg: Double): StructureND<Double>

Multiplies an ND structure by an element of it.

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

Multiplies this element by scalar.

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

Multiplication of this element by a scalar.

Link copied to clipboard
open override fun StructureND<Double>.toBufferND(): DoubleBufferND
open fun StructureND<Short>.toBufferND(): BufferND<Short>
Link copied to clipboard
open operator override fun StructureND<Double>.unaryMinus(): DoubleBufferND
open operator override fun StructureND<Short>.unaryMinus(): StructureND<Short>

The negation of this element.

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

Returns this value.

Link copied to clipboard
inline fun <T : Any> StructureND<T>.zip(struct: StructureND<T>, crossinline block: (T, T) -> T): StructureND<T>

Sources

Link copied to clipboard