fromArray

fun fromArray(array: ReadonlyArray<Double>, startingIndex: Int? = definedExternally, result: Matrix2? = definedExternally): Matrix2(source)

Creates a Matrix2 from 4 consecutive elements in an array.

// Create the Matrix2:
// [1.0, 2.0]
// [1.0, 2.0]

const v = [1.0, 1.0, 2.0, 2.0];
const m = Matrix2.fromArray(v);

// Create same Matrix2 with using an offset into an array
const v2 = [0.0, 0.0, 1.0, 1.0, 2.0, 2.0];
const m2 = Matrix2.fromArray(v2, 2);

Return

The modified result parameter or a new Matrix2 instance if one was not provided.

Parameters

array

The array whose 4 consecutive elements correspond to the positions of the matrix. Assumes column-major order.

startingIndex

The offset into the array of the first element, which corresponds to first column first row position in the matrix. Default value - 0

result

The object onto which to store the result.

See also