api / koma.extensions / reshape

reshape

@JvmName("reshapeDouble") funNDArray<Double>.reshape(rows:Int, cols:Int):Matrix<Double> @JvmName("reshapeFloat") funNDArray<Float>.reshape(rows:Int, cols:Int):Matrix<Float> @JvmName("reshapeGeneric") inline fun <reified T>Matrix<T>.reshape(rows:Int, cols:Int):Matrix<T> @JvmName("reshapeInt") funNDArray<Int>.reshape(rows:Int, cols:Int):Matrix<Int>

Returns a new Matrix with the given shape, populated with the data in this array.

Parameters

rows - The number of rows in the desired matrix

cols - The number of columns in the desired matrix

Exceptions

IllegalArgumentException - when rows * cols does not equal size

Returns A copy of the elements in this array, shaped to the given number of rows and columns, such that this.toList() == this.reshape(rows, cols).toList()

@JvmName("reshapeByte") funNDArray<Byte>.reshape(vararg dims:Int):NDArray<Byte> @JvmName("reshapeDouble") funNDArray<Double>.reshape(vararg dims:Int):NDArray<Double> @JvmName("reshapeFloat") funNDArray<Float>.reshape(vararg dims:Int):NDArray<Float> @JvmName("reshapeGeneric") inline fun <reified T>NDArray<T>.reshape(vararg dims:Int):NDArray<T> @JvmName("reshapeInt") funNDArray<Int>.reshape(vararg dims:Int):NDArray<Int> @JvmName("reshapeLong") funNDArray<Long>.reshape(vararg dims:Int):NDArray<Long> @JvmName("reshapeShort") funNDArray<Short>.reshape(vararg dims:Int):NDArray<Short>

Returns a new NDArray with the given shape, populated with the data in this array.

Parameters

dims - Desired dimensions of the output array.

Exceptions

IllegalArgumentException - when the product of all of the given dims does not equal size

Returns A copy of the elements in this array, shaped to the given number of rows and columns, such that this.toList() == this.reshape(*dims).toList()