invoke

open operator override fun <T> invoke(original: Matrix<T>): Matrix<T>

Create a copy of the parameter using the copyOf member function.

Return

The copy (from copyOf), depending on the type this may be the same object as the original.

Parameters

original

The matrix to create a copy of


open operator override fun <T> invoke(width: Int, height: Int, initValue: T): Matrix<T>

A matrix that is contains the given "initial" value. The implementation is immutable.

Return

The resulting matrix.

Parameters

width

The width of the matrix

height

The height of the matrix

initValue

The value for each cell in the matrix.


open inline operator override fun <T> invoke(width: Int, height: Int, init: (Int, Int) -> T): Matrix<T>

A simple array-like matrix that contains the values given by the function. The values are assigned at construction.

val multiplicationTable = Matrix(12, 12) { x, y ->
(x * y).toString()
}

Return

The resulting matrix (storing all values)

Parameters

width

The width of the matrix

height

The height of the matrix

init

Function that allows setting each cell in the matrix. Its parameters are the x and y coordinates.