identity
Returns the identity array.
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 identNDArray = mk.identity<Long>(3)
println(identNDArray)
/*
[[1, 0, 0],
[0, 1, 0],
[0, 0, 1]]
*/
//sampleEnd
}
Parameters
n
number of rows and columns.
Returns the identity array.
Note: Generic type of elements must match dtype.
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 identNDArray = mk.identity<Long>(3, DataType.LongDataType)
println(identNDArray)
/*
[[1, 0, 0],
[0, 1, 0],
[0, 0, 1]]
*/
//sampleEnd
}
Parameters
n
number of rows and columns.
dtype
array type.