zeros
Returns a new zero array of 1 dim of type T with dim1 size.
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.zeros<Int>(5)
println(ndarray) // [0, 0, 0, 0, 0]
//sampleEnd
}
Returns a new zero array of 2 dim of type T with (dim1, dim2) shape.
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.zeros<Float>(2, 2)
println(ndarray)
/*
[[0.0, 0.0],
[0.0, 0.0]]
*/
//sampleEnd
}
inline fun <T : Any> Multik.zeros( dim1: Int, dim2: Int, dim3: Int): D3Array<T>
Content copied to clipboard
Returns a new zero array of 3 dim of type T with (dim1, dim2, dim3) shape.
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.zeros<Double>(2, 2, 2)
println(ndarray)
/*
[[[0.0, 0.0],
[0.0, 0.0]],
[[0.0, 0.0],
[0.0, 0.0]]]
*/
//sampleEnd
}
inline fun <T : Any> Multik.zeros( dim1: Int, dim2: Int, dim3: Int, dim4: Int): D4Array<T>
Content copied to clipboard
Returns a new zero array of 4 dim of type T with (dim1, dim2, dim3, dim4) shape.
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.zeros<Double>(2, 1, 2, 1)
println(ndarray)
/*
[[[[0.0],
[0.0]]],
[[[0.0],
[0.0]]]]
*/
//sampleEnd
}
inline fun <T : Any> Multik.zeros( dim1: Int, dim2: Int, dim3: Int, dim4: Int, vararg dims: Int): NDArray<T, DN>
Content copied to clipboard
Returns a new zero array of N dim of type T with (dim1, dim2, dim3, dim4, dims) shape.
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.zeros<Double>(1, 1, 1, 2, 2)
println(ndarray)
/*
[[[[[0.0, 0.0],
[0.0, 0.0]]]]]
*/
//sampleEnd
}
fun <T, D : Dimension> Multik.zeros(dims: IntArray, dtype: DataType): NDArray<T, D>
Content copied to clipboard
Returns a new zero array of type T with specify shape.
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 dims = intArrayOf(3, 2)
val ndarray = mk.zeros<Float, D2>(dims, DataType.FloatDataType)
println(ndarray)
/*
[[0.0, 0.0],
[0.0, 0.0],
[0.0, 0.0]]
*/
//sampleEnd
}