koblas

Companion

Factories for dense matrices.

Functions

diagonal

Create a square identity matrix of the given size, scaled by diagonal.

ofRows

Copy an Array<DoubleArray> of rows into a fresh dense matrix, so rows(i) is row i.

wrap

fun wrap(rows: Int, cols: Int, values: DoubleArray, offset: Int = 0, leadingDimension: Int = rows): DenseMatrix(source)

Borrows values without copying, with unit row stride and optional column padding. All logical entries must fit and leadingDimension must be at least rows. For an empty shape, offset can be any boundary in 0..values.size. Bounds use overflow-safe arithmetic.

zero

fun zero(rows: Int, cols: Int = rows): DenseMatrix(source)

Create a zero matrix of shape rows x cols, square when cols is omitted.