ndarray
Creates the 1-dimension array from arg of Number type.
Example:
mk.ndarray(mk[1, 2, 3]
Return
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
list of elements.
Creates the 1-dimension array from arg of Complex type.
Example:
mk.ndarray(mk[1, 2, 3]
Return
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
list of elements.
Creates the 2-dimension array from arg of Number type.
Return
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
list of rows.
Creates the 2-dimension array from arg of Complex type.
Return
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
list of rows.
Creates the 3-dimension array from arg of Number type.
Return
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
elements.
Creates the 3-dimension array from arg of Complex type.
Return
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
elements.
Creates the 4-dimension array from arg of Number type.
Return
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
elements.
Creates the 4-dimension array from arg of Complex type.
Return
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
elements.
Returns a new array given shape from collection.
Return
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
collection of elements.
array shape.
Returns a new array given shape and dimension from collection.
Note: Generic type of dimension D must match dim.
Return
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
collection of elements.
array shape.
array dimension.
Returns a new 1-dimension array given shape from a collection.
Return
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
collection of number elements.
Returns a new 1-dimension array given shape from a collection.
Return
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
collection of complex elements.
Returns a new 1-dimension array from ByteArray.
Return
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
ByteArray of elements.
Returns a new 1-dimension array from ShortArray.
Return
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
ShortArray of elements.
Returns a new 1-dimension array from IntArray.
Return
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
IntArray of elements.
Returns a new 1-dimension array from LongArray.
Return
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
LongArray of elements.
Returns a new 1-dimension array from FloatArray.
Return
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
FloatArray of elements.
Returns a new 1-dimension array from DoubleArray.
Return
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
DoubleArray of elements.
Returns a new 1-dimension array from ComplexFloatArray.
Return
Parameters
ComplexFloatArray of elements.
Returns a new 1-dimension array from ComplexDoubleArray.
Return
Parameters
ComplexDoubleArray of elements.
Returns a new 2-dimensions array given shape from a collection.
Return
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
collection of elements.
value of 1-dimension.
value of 1-dimension.
Returns a new 2-dimensions array from ByteArray.
Return
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
Returns a new 2-dimensions array from ShortArray.
Return
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
Returns a new 2-dimensions array from IntArray.
Return
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
Returns a new 2-dimensions array from LongArray.
Return
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
Returns a new 2-dimensions array from FloatArray.
Return
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
Returns a new 2-dimensions array from DoubleArray.
Return
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
Returns a new 2-dimensions array from ComplexFloatArray.
Return
Parameters
Returns a new 2-dimensions array from ComplexDoubleArray.
Return
Parameters
Returns a new 3-dimensions array given shape from a collection.
Return
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
collection of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
Returns a new 3-dimensions array from ByteArray.
Return
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
ByteArray of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
Returns a new 3-dimensions array from ShortArray.
Return
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
ShortArray of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
Returns a new 3-dimensions array from IntArray.
Return
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
IntArray of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
Returns a new 3-dimensions array from LongArray.
Return
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
LongArray of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
Returns a new 3-dimensions array from FloatArray.
Return
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
FloatArray of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
Returns a new 3-dimensions array from DoubleArray.
Return
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
DoubleArray of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
Returns a new 3-dimensions array from ComplexFloatArray.
Return
Parameters
ComplexFloatArray of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
Returns a new 3-dimensions array from ComplexDoubleArray.
Return
Parameters
ComplexDoubleArray of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
Returns a new 4-dimensions array given shape from a collection.
Return
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
collection of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
value of 4-dimension.
Returns a new 4-dimensions array from ByteArray.
Return
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
ByteArray of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
value of 4-dimension.
Returns a new 4-dimensions array from ShortArray.
Return
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
ShortArray of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
value of 4-dimension.
Returns a new 4-dimensions array from IntArray.
Return
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
IntArray of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
value of 4-dimension.
Returns a new 4-dimensions array from LongArray.
Return
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
LongArray of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
value of 4-dimension.
Returns a new 4-dimensions array from FloatArray.
Return
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
FloatArray of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
value of 4-dimension.
Returns a new 4-dimensions array from DoubleArray.
Return
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
DoubleArray of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
value of 4-dimension.
Returns a new 4-dimensions array from ComplexFloatArray.
Return
Parameters
ComplexFloatArray of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
value of 4-dimension.
Returns a new 4-dimensions array from ComplexDoubleArray.
Return
Parameters
ComplexDoubleArray of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
value of 4-dimension.
Returns a new n-dimension array given shape from a collection.
Return
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
collection of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
value of 4-dimension.
values of other dimensions.
Returns a new n-dimension array from ByteArray.
Return
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
ByteArray of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
value of 4-dimension.
values of other dimensions.
Returns a new n-dimension array from ShortArray.
Return
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
ShortArray of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
value of 4-dimension.
values of other dimensions.
Returns a new n-dimension array from IntArray.
Return
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
IntArray of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
value of 4-dimension.
values of other dimensions.
Returns a new n-dimension array from LongArray.
Return
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
LongArray of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
value of 4-dimension.
values of other dimensions.
Returns a new n-dimension array from FloatArray.
Return
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
FloatArray of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
value of 4-dimension.
values of other dimensions.
Returns a new n-dimension array from DoubleArray.
Return
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
DoubleArray of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
value of 4-dimension.
values of other dimensions.
Returns a new n-dimension array from ComplexFloatArray.
Return
Parameters
ComplexFloatArray of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
value of 4-dimension.
values of other dimensions.
Returns a new n-dimension array from ComplexDoubleArray.
Return
Parameters
ComplexDoubleArray of elements.
value of 1-dimension.
value of 2-dimension.
value of 3-dimension.
value of 4-dimension.
values of other dimensions.
Returns an D2Array from Array
Returns an D2Array from Array
Returns an D2Array from Array
Returns an D2Array from Array
Returns an D2Array from Array
Returns an D2Array from Array