ndarray

@JvmName(name = "ndarray1D")
inline fun <T : Number> Multik.ndarray(arg: List<T>): D1Array<T>

Creates the 1-dimension array from arg of Number type.

Example:

mk.ndarray(mk[1, 2, 3]

Return

D1Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val ndarray = mk.ndarray(mk[1, 2, 3])
println("shape=(${ndarray.shape.joinToString()}), dim=${ndarray.dim.d}") // shape=(3), dim=1
println(ndarray) // [1, 2, 3] 
   //sampleEnd
}

Parameters

arg

list of elements.


@JvmName(name = "ndarrayComplex1D")
inline fun <T : Complex> Multik.ndarray(arg: List<T>): D1Array<T>

Creates the 1-dimension array from arg of Complex type.

Example:

mk.ndarray(mk[1, 2, 3]

Return

D1Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val ndarray = mk.ndarray(mk[1, 2, 3])
println("shape=(${ndarray.shape.joinToString()}), dim=${ndarray.dim.d}") // shape=(3), dim=1
println(ndarray) // [1, 2, 3] 
   //sampleEnd
}

Parameters

arg

list of elements.


@JvmName(name = "ndarray2D")
inline fun <T : Number> Multik.ndarray(arg: List<List<T>>): D2Array<T>

Creates the 2-dimension array from arg of Number type.

Return

D2Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val ndarray = mk.ndarray(mk[mk[1, 2], mk[3, 4]])
println("shape=(${ndarray.shape.joinToString()}), dim=${ndarray.dim.d}") // shape=(2, 2), dim=2
println(ndarray)
/*
[[1, 2],
[3, 4]]
 */ 
   //sampleEnd
}

Parameters

arg

list of rows.


@JvmName(name = "ndarrayComplex2D")
inline fun <T : Complex> Multik.ndarray(arg: List<List<T>>): D2Array<T>

Creates the 2-dimension array from arg of Complex type.

Return

D2Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val ndarray = mk.ndarray(mk[mk[1, 2], mk[3, 4]])
println("shape=(${ndarray.shape.joinToString()}), dim=${ndarray.dim.d}") // shape=(2, 2), dim=2
println(ndarray)
/*
[[1, 2],
[3, 4]]
 */ 
   //sampleEnd
}

Parameters

arg

list of rows.


@JvmName(name = "ndarray3D")
inline fun <T : Number> Multik.ndarray(arg: List<List<List<T>>>): D3Array<T>

Creates the 3-dimension array from arg of Number type.

Return

D3Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val ndarray = mk.ndarray(mk[mk[mk[1, 2], mk[3, 4]], mk[mk[5, 6], mk[7, 8]]])
println("shape=(${ndarray.shape.joinToString()}), dim=${ndarray.dim.d}") // shape=(2, 2, 2), dim=3
println(ndarray)
/*
[[[1, 2],
[3, 4]],

[[5, 6],
[7, 8]]]
 */ 
   //sampleEnd
}

Parameters

arg

elements.


@JvmName(name = "ndarrayComplex3D")
inline fun <T : Complex> Multik.ndarray(arg: List<List<List<T>>>): D3Array<T>

Creates the 3-dimension array from arg of Complex type.

Return

D3Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val ndarray = mk.ndarray(mk[mk[mk[1, 2], mk[3, 4]], mk[mk[5, 6], mk[7, 8]]])
println("shape=(${ndarray.shape.joinToString()}), dim=${ndarray.dim.d}") // shape=(2, 2, 2), dim=3
println(ndarray)
/*
[[[1, 2],
[3, 4]],

[[5, 6],
[7, 8]]]
 */ 
   //sampleEnd
}

Parameters

arg

elements.


@JvmName(name = "ndarray4D")
inline fun <T : Number> Multik.ndarray(arg: List<List<List<List<T>>>>): D4Array<T>

Creates the 4-dimension array from arg of Number type.

Return

D4Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val ndarray = mk.ndarray(mk[mk[mk[mk[1, 2], mk[3, 4]], mk[mk[5, 6], mk[7, 8]]]])
println("shape=(${ndarray.shape.joinToString()}), dim=${ndarray.dim.d}") // shape=(1, 2, 2, 2), dim=4
println(ndarray)
/*
[[[[1, 2],
[3, 4]],

[[5, 6],
[7, 8]]]]
 */ 
   //sampleEnd
}

Parameters

arg

elements.


@JvmName(name = "ndarrayComplex4D")
inline fun <T : Complex> Multik.ndarray(arg: List<List<List<List<T>>>>): D4Array<T>

Creates the 4-dimension array from arg of Complex type.

Return

D4Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val ndarray = mk.ndarray(mk[mk[mk[mk[1, 2], mk[3, 4]], mk[mk[5, 6], mk[7, 8]]]])
println("shape=(${ndarray.shape.joinToString()}), dim=${ndarray.dim.d}") // shape=(1, 2, 2, 2), dim=4
println(ndarray)
/*
[[[[1, 2],
[3, 4]],

[[5, 6],
[7, 8]]]]
 */ 
   //sampleEnd
}

Parameters

arg

elements.


inline fun <T : Number, D : Dimension> Multik.ndarray(elements: Collection<T>, shape: IntArray): NDArray<T, D>
@JvmName(name = "ndarrayComplex")
inline fun <T : Complex, D : Dimension> Multik.ndarray(elements: Collection<T>, shape: IntArray): NDArray<T, D>

Returns a new array given shape from collection.

Return

NDArray of D dimension.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val set = setOf(1, 2, 3, 4)
val dims = intArrayOf(2, 1, 2)
val ndarray = mk.ndarray<Int, D3>(set, dims)
println("shape=(${ndarray.shape.joinToString()}), dim=${ndarray.dim.d}") // shape=(2, 1, 2), dim=3
println(ndarray)
/*
[[[1, 2]],

[[3, 4]]]
 */ 
   //sampleEnd
}

Parameters

elements

collection of elements.

shape

array shape.


fun <T : Number, D : Dimension> Multik.ndarray(    elements: Collection<T>,     shape: IntArray,     dim: D): NDArray<T, D>
@JvmName(name = "ndarrayComplex")
fun <T : Complex, D : Dimension> Multik.ndarray(    elements: Collection<T>,     shape: IntArray,     dim: D): NDArray<T, D>

Returns a new array given shape and dimension from collection.

Note: Generic type of dimension D must match dim.

Return

NDArray of D dimension.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val set = setOf(1, 2, 3, 4)
val dims = intArrayOf(2, 1, 2)
val ndarray = mk.ndarray(set, dims, D3)
println("shape=(${ndarray.shape.joinToString()}), dim=${ndarray.dim.d}") // shape=(2, 1, 2), dim=3
println(ndarray)
/*
[[[1, 2]],

[[3, 4]]]
 */ 
   //sampleEnd
}

Parameters

elements

collection of elements.

shape

array shape.

dim

array dimension.


fun <T : Number> Multik.ndarray(elements: Collection<T>): D1Array<T>

Returns a new 1-dimension array given shape from a collection.

Return

D1Array

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val set = setOf(1, 2, 3, 4)
val ndarray = mk.ndarray(set)
println("shape=(${ndarray.shape.joinToString()}), dim=${ndarray.dim.d}") // shape=(4), dim=1
println(ndarray) // [1, 2, 3, 4] 
   //sampleEnd
}

Parameters

elements

collection of number elements.


@JvmName(name = "ndarrayComplex")
fun <T : Complex> Multik.ndarray(elements: Collection<T>): D1Array<T>

Returns a new 1-dimension array given shape from a collection.

Return

D1Array

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val set = setOf(1, 2, 3, 4)
val ndarray = mk.ndarray(set)
println("shape=(${ndarray.shape.joinToString()}), dim=${ndarray.dim.d}") // shape=(4), dim=1
println(ndarray) // [1, 2, 3, 4] 
   //sampleEnd
}

Parameters

elements

collection of complex elements.


fun Multik.ndarray(args: ByteArray): D1Array<Byte>

Returns a new 1-dimension array from ByteArray.

Return

D1Array

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val byteArray = byteArrayOf(1, 2, 3)
val ndarray = mk.ndarray(byteArray)
println(ndarray) // [1, 2, 3] 
   //sampleEnd
}

Parameters

args

ByteArray of elements.


fun Multik.ndarray(args: ShortArray): D1Array<Short>

Returns a new 1-dimension array from ShortArray.

Return

D1Array

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val shortArray = shortArrayOf(1, 2, 3)
val ndarray = mk.ndarray(shortArray)
println(ndarray) // [1, 2, 3] 
   //sampleEnd
}

Parameters

args

ShortArray of elements.


fun Multik.ndarray(args: IntArray): D1Array<Int>

Returns a new 1-dimension array from IntArray.

Return

D1Array

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val intArray = intArrayOf(1, 2, 3)
val ndarray = mk.ndarray(intArray)
println(ndarray) // [1, 2, 3] 
   //sampleEnd
}

Parameters

args

IntArray of elements.


fun Multik.ndarray(args: LongArray): D1Array<Long>

Returns a new 1-dimension array from LongArray.

Return

D1Array

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val longArray = longArrayOf(1, 2, 3)
val ndarray = mk.ndarray(longArray)
println(ndarray) // [1, 2, 3] 
   //sampleEnd
}

Parameters

args

LongArray of elements.


fun Multik.ndarray(args: FloatArray): D1Array<Float>

Returns a new 1-dimension array from FloatArray.

Return

D1Array

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val floatArray = floatArrayOf(1f, 2f, 3f)
val ndarray = mk.ndarray(floatArray)
println(ndarray) // [1.0, 2.0, 3.0] 
   //sampleEnd
}

Parameters

args

FloatArray of elements.


fun Multik.ndarray(args: DoubleArray): D1Array<Double>

Returns a new 1-dimension array from DoubleArray.

Return

D1Array

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val doubleArray = doubleArrayOf(1.0, 2.0, 3.0)
val ndarray = mk.ndarray(doubleArray)
println(ndarray) // [1.0, 2.0, 3.0] 
   //sampleEnd
}

Parameters

args

DoubleArray of elements.


fun Multik.ndarray(args: ComplexFloatArray): D1Array<ComplexFloat>

Returns a new 1-dimension array from ComplexFloatArray.

Return

D1Array

Parameters

args

ComplexFloatArray of elements.


fun Multik.ndarray(args: ComplexDoubleArray): D1Array<ComplexDouble>

Returns a new 1-dimension array from ComplexDoubleArray.

Return

D1Array

Parameters

args

ComplexDoubleArray of elements.


fun <T : Number> Multik.ndarray(    elements: Collection<T>,     dim1: Int,     dim2: Int): D2Array<T>
@JvmName(name = "ndarrayComplex")
fun <T : Complex> Multik.ndarray(    elements: Collection<T>,     dim1: Int,     dim2: Int): D2Array<T>

Returns a new 2-dimensions array given shape from a collection.

Return

D2Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val set = setOf(1, 2, 3, 4)
val ndarray = mk.ndarray(set, 2, 2)
println(ndarray)
/*
[[1, 2],
[3, 4]]
 */ 
   //sampleEnd
}

Parameters

elements

collection of elements.

dim1

value of 1-dimension.

dim2

value of 1-dimension.


fun Multik.ndarray(    args: ByteArray,     dim1: Int,     dim2: Int): D2Array<Byte>

Returns a new 2-dimensions array from ByteArray.

Return

D2Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val byteArray = byteArrayOf(1, 2, 3, 4)
val ndarray = mk.ndarray(byteArray, 2, 2)
println(ndarray)
/*
[[1, 2],
[3, 4]]
 */ 
   //sampleEnd
}

Parameters

args

ByteArray of elements.

dim1

value of 1-dimension.

dim2

value of 1-dimension.


fun Multik.ndarray(    args: ShortArray,     dim1: Int,     dim2: Int): D2Array<Short>

Returns a new 2-dimensions array from ShortArray.

Return

D2Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val shortArray = shortArrayOf(1, 2, 3, 4)
val ndarray = mk.ndarray(shortArray, 2, 2)
println(ndarray)
/*
[[1, 2],
[3, 4]]
 */ 
   //sampleEnd
}

Parameters

args

ShortArray of elements.

dim1

value of 1-dimension.

dim2

value of 1-dimension.


fun Multik.ndarray(    args: IntArray,     dim1: Int,     dim2: Int): D2Array<Int>

Returns a new 2-dimensions array from IntArray.

Return

D2Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val intArray = intArrayOf(1, 2, 3, 4)
val ndarray = mk.ndarray(intArray, 2, 2)
println(ndarray)
/*
[[1, 2],
[3, 4]]
 */ 
   //sampleEnd
}

Parameters

args

IntArray of elements.

dim1

value of 1-dimension.

dim2

value of 1-dimension.


fun Multik.ndarray(    args: LongArray,     dim1: Int,     dim2: Int): D2Array<Long>

Returns a new 2-dimensions array from LongArray.

Return

D2Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val longArray = longArrayOf(1, 2, 3, 4)
val ndarray = mk.ndarray(longArray, 2, 2)
println(ndarray)
/*
[[1, 2],
[3, 4]]
 */ 
   //sampleEnd
}

Parameters

args

LongArray of elements.

dim1

value of 1-dimension.

dim2

value of 1-dimension.


fun Multik.ndarray(    args: FloatArray,     dim1: Int,     dim2: Int): D2Array<Float>

Returns a new 2-dimensions array from FloatArray.

Return

D2Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val floatArray = floatArrayOf(1f, 2f, 3f, 4f)
val ndarray = mk.ndarray(floatArray, 2, 2)
println(ndarray)
/*
[[1.0, 2.0],
[3.0, 4.0]]
 */ 
   //sampleEnd
}

Parameters

args

FloatArray of elements.

dim1

value of 1-dimension.

dim2

value of 1-dimension.


fun Multik.ndarray(    args: DoubleArray,     dim1: Int,     dim2: Int): D2Array<Double>

Returns a new 2-dimensions array from DoubleArray.

Return

D2Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val doubleArray = doubleArrayOf(1.0, 2.0, 3.0, 4.0)
val ndarray = mk.ndarray(doubleArray, 2, 2)
println(ndarray)
/*
[[1.0, 2.0],
[3.0, 4.0]]
 */ 
   //sampleEnd
}

Parameters

args

DoubleArray of elements.

dim1

value of 1-dimension.

dim2

value of 1-dimension.


fun Multik.ndarray(    args: ComplexFloatArray,     dim1: Int,     dim2: Int): D2Array<ComplexFloat>

Returns a new 2-dimensions array from ComplexFloatArray.

Return

D2Array.

Parameters

args

ComplexFloatArray of elements.

dim1

value of 1-dimension.

dim2

value of 1-dimension.


fun Multik.ndarray(    args: ComplexDoubleArray,     dim1: Int,     dim2: Int): D2Array<ComplexDouble>

Returns a new 2-dimensions array from ComplexDoubleArray.

Return

D2Array.

Parameters

args

ComplexDoubleArray of elements.

dim1

value of 1-dimension.

dim2

value of 1-dimension.


fun <T : Number> Multik.ndarray(    elements: Collection<T>,     dim1: Int,     dim2: Int,     dim3: Int): D3Array<T>
@JvmName(name = "ndarrayComplex")
fun <T : Complex> Multik.ndarray(    elements: Collection<T>,     dim1: Int,     dim2: Int,     dim3: Int): D3Array<T>

Returns a new 3-dimensions array given shape from a collection.

Return

D3Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val set = setOf(1, 2, 3, 4, 5, 6, 7, 8)
val ndarray = mk.ndarray(set, 2, 2, 2)
println(ndarray)
/*
[[[1, 2],
[3, 4]],

[[5, 6],
[7, 8]]]
 */ 
   //sampleEnd
}

Parameters

elements

collection of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.


fun Multik.ndarray(    args: ByteArray,     dim1: Int,     dim2: Int,     dim3: Int): D3Array<Byte>

Returns a new 3-dimensions array from ByteArray.

Return

D3Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val byteArray = byteArrayOf(1, 2, 3, 4, 5, 6, 7, 8)
val ndarray = mk.ndarray(byteArray, 2, 2, 2)
println(ndarray)
/*
[[[1, 2],
[3, 4]],

[[5, 6],
[7, 8]]]
 */ 
   //sampleEnd
}

Parameters

args

ByteArray of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.


fun Multik.ndarray(    args: ShortArray,     dim1: Int,     dim2: Int,     dim3: Int): D3Array<Short>

Returns a new 3-dimensions array from ShortArray.

Return

D3Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val shortArray = shortArrayOf(1, 2, 3, 4, 5, 6, 7, 8)
val ndarray = mk.ndarray(shortArray, 2, 2, 2)
println(ndarray)
/*
[[[1, 2],
[3, 4]],

[[5, 6],
[7, 8]]]
 */ 
   //sampleEnd
}

Parameters

args

ShortArray of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.


fun Multik.ndarray(    args: IntArray,     dim1: Int,     dim2: Int,     dim3: Int): D3Array<Int>

Returns a new 3-dimensions array from IntArray.

Return

D3Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val intArray = intArrayOf(1, 2, 3, 4, 5, 6, 7, 8)
val ndarray = mk.ndarray(intArray, 2, 2, 2)
println(ndarray)
/*
[[[1, 2],
[3, 4]],

[[5, 6],
[7, 8]]]
 */ 
   //sampleEnd
}

Parameters

args

IntArray of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.


fun Multik.ndarray(    args: LongArray,     dim1: Int,     dim2: Int,     dim3: Int): D3Array<Long>

Returns a new 3-dimensions array from LongArray.

Return

D3Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val longArray = longArrayOf(1, 2, 3, 4, 5, 6, 7, 8)
val ndarray = mk.ndarray(longArray, 2, 2, 2)
println(ndarray)
/*
[[[1, 2],
[3, 4]],

[[5, 6],
[7, 8]]]
 */ 
   //sampleEnd
}

Parameters

args

LongArray of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.


fun Multik.ndarray(    args: FloatArray,     dim1: Int,     dim2: Int,     dim3: Int): D3Array<Float>

Returns a new 3-dimensions array from FloatArray.

Return

D3Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val floatArray = floatArrayOf(1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f)
val ndarray = mk.ndarray(floatArray, 2, 2, 2)
println(ndarray)
/*
[[[1.0, 2.0],
[3.0, 4.0]],

[[5.0, 6.0],
[7.0, 8.0]]]
 */ 
   //sampleEnd
}

Parameters

args

FloatArray of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.


fun Multik.ndarray(    args: DoubleArray,     dim1: Int,     dim2: Int,     dim3: Int): D3Array<Double>

Returns a new 3-dimensions array from DoubleArray.

Return

D3Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val doubleArray = doubleArrayOf(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0)
val ndarray = mk.ndarray(doubleArray, 2, 2, 2)
println(ndarray)
/*
[[[1.0, 2.0],
[3.0, 4.0]],

[[5.0, 6.0],
[7.0, 8.0]]]
 */ 
   //sampleEnd
}

Parameters

args

DoubleArray of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.


fun Multik.ndarray(    args: ComplexFloatArray,     dim1: Int,     dim2: Int,     dim3: Int): D3Array<ComplexFloat>

Returns a new 3-dimensions array from ComplexFloatArray.

Return

D3Array.

Parameters

args

ComplexFloatArray of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.


fun Multik.ndarray(    args: ComplexDoubleArray,     dim1: Int,     dim2: Int,     dim3: Int): D3Array<ComplexDouble>

Returns a new 3-dimensions array from ComplexDoubleArray.

Return

D3Array.

Parameters

args

ComplexDoubleArray of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.


fun <T : Number> Multik.ndarray(    elements: Collection<T>,     dim1: Int,     dim2: Int,     dim3: Int,     dim4: Int): D4Array<T>
@JvmName(name = "ndarrayComplex")
fun <T : Complex> Multik.ndarray(    elements: Collection<T>,     dim1: Int,     dim2: Int,     dim3: Int,     dim4: Int): D4Array<T>

Returns a new 4-dimensions array given shape from a collection.

Return

D4Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val set = setOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
val ndarray = mk.ndarray(set, 2, 2, 2, 2)
println(ndarray)
/*
[[[[1, 2],
[3, 4]],

[[5, 6],
[7, 8]]],


[[[9, 10],
[11, 12]],

[[13, 14],
[15, 16]]]]
 */ 
   //sampleEnd
}

Parameters

elements

collection of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.

dim4

value of 4-dimension.


fun Multik.ndarray(    args: ByteArray,     dim1: Int,     dim2: Int,     dim3: Int,     dim4: Int): D4Array<Byte>

Returns a new 4-dimensions array from ByteArray.

Return

D4Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val byteArray = byteArrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
val ndarray = mk.ndarray(byteArray, 2, 2, 2, 2)
println(ndarray)
/*
[[[[1, 2],
[3, 4]],

[[5, 6],
[7, 8]]],


[[[9, 10],
[11, 12]],

[[13, 14],
[15, 16]]]]
 */ 
   //sampleEnd
}

Parameters

args

ByteArray of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.

dim4

value of 4-dimension.


fun Multik.ndarray(    args: ShortArray,     dim1: Int,     dim2: Int,     dim3: Int,     dim4: Int): D4Array<Short>

Returns a new 4-dimensions array from ShortArray.

Return

D4Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val shortArray = shortArrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
val ndarray = mk.ndarray(shortArray, 2, 2, 2, 2)
println(ndarray)
/*
[[[[1, 2],
[3, 4]],

[[5, 6],
[7, 8]]],


[[[9, 10],
[11, 12]],

[[13, 14],
[15, 16]]]]
 */ 
   //sampleEnd
}

Parameters

args

ShortArray of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.

dim4

value of 4-dimension.


fun Multik.ndarray(    args: IntArray,     dim1: Int,     dim2: Int,     dim3: Int,     dim4: Int): D4Array<Int>

Returns a new 4-dimensions array from IntArray.

Return

D4Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val intArray = intArrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
val ndarray = mk.ndarray(intArray, 2, 2, 2, 2)
println(ndarray)
/*
[[[[1, 2],
[3, 4]],

[[5, 6],
[7, 8]]],


[[[9, 10],
[11, 12]],

[[13, 14],
[15, 16]]]]
 */ 
   //sampleEnd
}

Parameters

args

IntArray of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.

dim4

value of 4-dimension.


fun Multik.ndarray(    args: LongArray,     dim1: Int,     dim2: Int,     dim3: Int,     dim4: Int): D4Array<Long>

Returns a new 4-dimensions array from LongArray.

Return

D4Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val longArray = longArrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
val ndarray = mk.ndarray(longArray, 2, 2, 2, 2)
println(ndarray)
/*
[[[[1, 2],
[3, 4]],

[[5, 6],
[7, 8]]],


[[[9, 10],
[11, 12]],

[[13, 14],
[15, 16]]]]
 */ 
   //sampleEnd
}

Parameters

args

LongArray of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.

dim4

value of 4-dimension.


fun Multik.ndarray(    args: FloatArray,     dim1: Int,     dim2: Int,     dim3: Int,     dim4: Int): D4Array<Float>

Returns a new 4-dimensions array from FloatArray.

Return

D4Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val floatArray = floatArrayOf(1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f, 9f, 10f, 11f, 12f, 13f, 14f, 15f, 16f)
val ndarray = mk.ndarray(floatArray, 2, 2, 2, 2)
println(ndarray)
/*
[[[[1.0, 2.0],
[3.0, 4.0]],

[[5.0, 6.0],
[7.0, 8.0]]],


[[[9.0, 10.0],
[11.0, 12.0]],

[[13.0, 14.0],
[15.0, 16.0]]]]
 */ 
   //sampleEnd
}

Parameters

args

FloatArray of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.

dim4

value of 4-dimension.


fun Multik.ndarray(    args: DoubleArray,     dim1: Int,     dim2: Int,     dim3: Int,     dim4: Int): D4Array<Double>

Returns a new 4-dimensions array from DoubleArray.

Return

D4Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val doubleArray =
    doubleArrayOf(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0)
val ndarray = mk.ndarray(doubleArray, 2, 2, 2, 2)
println(ndarray)
/*
[[[[1.0, 2.0],
[3.0, 4.0]],

[[5.0, 6.0],
[7.0, 8.0]]],


[[[9.0, 10.0],
[11.0, 12.0]],

[[13.0, 14.0],
[15.0, 16.0]]]]
 */ 
   //sampleEnd
}

Parameters

args

DoubleArray of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.

dim4

value of 4-dimension.


fun Multik.ndarray(    args: ComplexFloatArray,     dim1: Int,     dim2: Int,     dim3: Int,     dim4: Int): D4Array<ComplexFloat>

Returns a new 4-dimensions array from ComplexFloatArray.

Return

D4Array.

Parameters

args

ComplexFloatArray of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.

dim4

value of 4-dimension.


fun Multik.ndarray(    args: ComplexDoubleArray,     dim1: Int,     dim2: Int,     dim3: Int,     dim4: Int): D4Array<ComplexDouble>

Returns a new 4-dimensions array from ComplexDoubleArray.

Return

D4Array.

Parameters

args

ComplexDoubleArray of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.

dim4

value of 4-dimension.


fun <T : Number> Multik.ndarray(    elements: Collection<T>,     dim1: Int,     dim2: Int,     dim3: Int,     dim4: Int,     vararg dims: Int): NDArray<T, DN>
@JvmName(name = "ndarrayComplex")
fun <T : Complex> Multik.ndarray(    elements: Collection<T>,     dim1: Int,     dim2: Int,     dim3: Int,     dim4: Int,     vararg dims: Int): NDArray<T, DN>

Returns a new n-dimension array given shape from a collection.

Return

NDArray of DN dimension.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val set = setOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
val ndarray = mk.ndarray(set, 2, 2, 1, 2, 2)
println(ndarray)
/*
[[[[[1, 2],
[3, 4]]],


[[[5, 6],
[7, 8]]]],



[[[[9, 10],
[11, 12]]],


[[[13, 14],
[15, 16]]]]]
 */ 
   //sampleEnd
}

Parameters

elements

collection of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.

dim4

value of 4-dimension.

dims

values of other dimensions.


fun Multik.ndarray(    args: ByteArray,     dim1: Int,     dim2: Int,     dim3: Int,     dim4: Int,     vararg dims: Int): NDArray<Byte, DN>

Returns a new n-dimension array from ByteArray.

Return

NDArray of DN dimension.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val byteArray = byteArrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
val ndarray = mk.ndarray(byteArray, 2, 2, 1, 2, 2)
println(ndarray)
/*
[[[[[1, 2],
[3, 4]]],


[[[5, 6],
[7, 8]]]],



[[[[9, 10],
[11, 12]]],


[[[13, 14],
[15, 16]]]]]
 */ 
   //sampleEnd
}

Parameters

args

ByteArray of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.

dim4

value of 4-dimension.

dims

values of other dimensions.


fun Multik.ndarray(    args: ShortArray,     dim1: Int,     dim2: Int,     dim3: Int,     dim4: Int,     vararg dims: Int): NDArray<Short, DN>

Returns a new n-dimension array from ShortArray.

Return

NDArray of DN dimension.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val shortArray = shortArrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
val ndarray = mk.ndarray(shortArray, 2, 2, 1, 2, 2)
println(ndarray)
/*
[[[[[1, 2],
[3, 4]]],


[[[5, 6],
[7, 8]]]],



[[[[9, 10],
[11, 12]]],


[[[13, 14],
[15, 16]]]]]
 */ 
   //sampleEnd
}

Parameters

args

ShortArray of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.

dim4

value of 4-dimension.

dims

values of other dimensions.


fun Multik.ndarray(    args: IntArray,     dim1: Int,     dim2: Int,     dim3: Int,     dim4: Int,     vararg dims: Int): NDArray<Int, DN>

Returns a new n-dimension array from IntArray.

Return

NDArray of DN dimension.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val intArray = intArrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
val ndarray = mk.ndarray(intArray, 2, 2, 1, 2, 2)
println(ndarray)
/*
[[[[[1, 2],
[3, 4]]],


[[[5, 6],
[7, 8]]]],



[[[[9, 10],
[11, 12]]],


[[[13, 14],
[15, 16]]]]]
 */ 
   //sampleEnd
}

Parameters

args

IntArray of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.

dim4

value of 4-dimension.

dims

values of other dimensions.


fun Multik.ndarray(    args: LongArray,     dim1: Int,     dim2: Int,     dim3: Int,     dim4: Int,     vararg dims: Int): NDArray<Long, DN>

Returns a new n-dimension array from LongArray.

Return

NDArray of DN dimension.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val longArray = longArrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
val ndarray = mk.ndarray(longArray, 2, 2, 1, 2, 2)
println(ndarray)
/*
[[[[[1, 2],
[3, 4]]],


[[[5, 6],
[7, 8]]]],



[[[[9, 10],
[11, 12]]],


[[[13, 14],
[15, 16]]]]]
 */ 
   //sampleEnd
}

Parameters

args

LongArray of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.

dim4

value of 4-dimension.

dims

values of other dimensions.


fun Multik.ndarray(    args: FloatArray,     dim1: Int,     dim2: Int,     dim3: Int,     dim4: Int,     vararg dims: Int): NDArray<Float, DN>

Returns a new n-dimension array from FloatArray.

Return

NDArray of DN dimension.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val floatArray = floatArrayOf(1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f, 9f, 10f, 11f, 12f, 13f, 14f, 15f, 16f)
val ndarray = mk.ndarray(floatArray, 2, 2, 1, 2, 2)
println(ndarray)
/*
[[[[[1.0, 2.0],
[3.0, 4.0]]],


[[[5.0, 6.0],
[7.0, 8.0]]]],



[[[[9.0, 10.0],
[11.0, 12.0]]],


[[[13.0, 14.0],
[15.0, 16.0]]]]]
 */ 
   //sampleEnd
}

Parameters

args

FloatArray of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.

dim4

value of 4-dimension.

dims

values of other dimensions.


fun Multik.ndarray(    args: DoubleArray,     dim1: Int,     dim2: Int,     dim3: Int,     dim4: Int,     vararg dims: Int): NDArray<Double, DN>

Returns a new n-dimension array from DoubleArray.

Return

NDArray of DN dimension.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val doubleArray =
    doubleArrayOf(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0)
val ndarray = mk.ndarray(doubleArray, 2, 2, 1, 2, 2)
println(ndarray)
/*
[[[[[1.0, 2.0],
[3.0, 4.0]]],


[[[5.0, 6.0],
[7.0, 8.0]]]],



[[[[9.0, 10.0],
[11.0, 12.0]]],


[[[13.0, 14.0],
[15.0, 16.0]]]]]
 */ 
   //sampleEnd
}

Parameters

args

DoubleArray of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.

dim4

value of 4-dimension.

dims

values of other dimensions.


fun Multik.ndarray(    args: ComplexFloatArray,     dim1: Int,     dim2: Int,     dim3: Int,     dim4: Int,     vararg dims: Int): NDArray<ComplexFloat, DN>

Returns a new n-dimension array from ComplexFloatArray.

Return

NDArray of DN dimension.

Parameters

args

ComplexFloatArray of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.

dim4

value of 4-dimension.

dims

values of other dimensions.


fun Multik.ndarray(    args: ComplexDoubleArray,     dim1: Int,     dim2: Int,     dim3: Int,     dim4: Int,     vararg dims: Int): NDArray<ComplexDouble, DN>

Returns a new n-dimension array from ComplexDoubleArray.

Return

NDArray of DN dimension.

Parameters

args

ComplexDoubleArray of elements.

dim1

value of 1-dimension.

dim2

value of 2-dimension.

dim3

value of 3-dimension.

dim4

value of 4-dimension.

dims

values of other dimensions.


fun Multik.ndarray(args: Array<ByteArray>): D2Array<Byte>

Returns an D2Array from Array.


fun Multik.ndarray(args: Array<ShortArray>): D2Array<Short>

Returns an D2Array from Array.


fun Multik.ndarray(args: Array<IntArray>): D2Array<Int>

Returns an D2Array from Array.


fun Multik.ndarray(args: Array<LongArray>): D2Array<Long>

Returns an D2Array from Array.


fun Multik.ndarray(args: Array<FloatArray>): D2Array<Float>

Returns an D2Array from Array.


fun Multik.ndarray(args: Array<DoubleArray>): D2Array<Double>

Returns an D2Array from Array.