api / koma.extensions / mapIndexed

mapIndexed

@JvmName("mapIndexedDouble") inline funMatrix<Double>.mapIndexed(f: (row:Int, col:Int, ele:Double) ->Double):Matrix<Double> @JvmName("mapIndexedFloat") inline funMatrix<Float>.mapIndexed(f: (row:Int, col:Int, ele:Float) ->Float):Matrix<Float> @JvmName("mapIndexedGeneric") fun <T>Matrix<T>.mapIndexed(f: (row:Int, col:Int, ele:T) ->T):Matrix<T> @JvmName("mapIndexedInt") inline funMatrix<Int>.mapIndexed(f: (row:Int, col:Int, ele:Int) ->Int):Matrix<Int>

Takes each element in a matrix, passes them through f, and puts the output of f into an output matrix. This process is done in row-major order.

Parameters

f - A function that takes in an element and returns an element. Function also takes in the row, col index of the element's location.

Return the new matrix after each element is mapped through f

@JvmName("mapIndexedByte") inline funNDArray<Byte>.mapIndexed(f: (idx:Int, ele:Byte) ->Byte):NDArray<Byte> @JvmName("mapIndexedDouble") inline funNDArray<Double>.mapIndexed(f: (idx:Int, ele:Double) ->Double):NDArray<Double> @JvmName("mapIndexedFloat") inline funNDArray<Float>.mapIndexed(f: (idx:Int, ele:Float) ->Float):NDArray<Float> @JvmName("mapIndexedGeneric") fun <T>NDArray<T>.mapIndexed(f: (idx:Int, ele:T) ->T):DefaultGenericNDArray<T> @JvmName("mapIndexedInt") inline funNDArray<Int>.mapIndexed(f: (idx:Int, ele:Int) ->Int):NDArray<Int> @JvmName("mapIndexedLong") inline funNDArray<Long>.mapIndexed(f: (idx:Int, ele:Long) ->Long):NDArray<Long> @JvmName("mapIndexedShort") inline funNDArray<Short>.mapIndexed(f: (idx:Int, ele:Short) ->Short):NDArray<Short>

Takes each element in a NDArray, passes them through f, and puts the output of f into an output NDArray. Index given to f is a linear index, depending on the underlying storage major dimension.

Parameters

f - A function that takes in an element and returns an element. Function also takes in the linear index of the element's location.

Return the new NDArray after each element is mapped through f