koblas

StridedMatrixView

class StridedMatrixView @JvmOverloads constructor(val rows: Int, val cols: Int, val data: DoubleArray, val offset: Int = 0, val leadingDimension: Int = maxOf(1, rows)) : Matrix(source)

A mutable live column-major matrix view. Entry (i, j) is at offset + i + j * leadingDimension in data, so panels can retain their parent's physical column stride. The view never copies data, so mutations through the view or any other reference to the array are visible to each other.

Constructors

StridedMatrixView

constructor(rows: Int, cols: Int, data: DoubleArray, offset: Int = 0, leadingDimension: Int = maxOf(1, rows))(source)

Properties

cols

open override val cols: Int(source)

Number of columns.

data

leadingDimension

Physical distance between the starts of adjacent columns.

offset

Physical buffer index of entry (0, 0).

rows

open override val rows: Int(source)

Number of rows.

Functions

column

Live column j, contiguous even when this view is a panel.

get

open operator override fun get(i: Int, j: Int): Double(source)

The entry at row (i), column (j). Throws IndexOutOfBoundsException outside the shape, whatever the storage.

overlaps

Whether this matrix and other address at least one common buffer entry.

Every strided product checks this before it runs, so the cheap answers come first: a different buffer, then physical spans that do not meet, then, where the two lie on one grid of columns, a rectangle intersection. Only views whose leading dimensions differ, or whose columns wrap across that grid, are walked entry by entry.


Whether this matrix and other address at least one common buffer entry.

row

Live row i, strided by leadingDimension.

set

operator fun set(i: Int, j: Int, value: Double)(source)

Writes value at row i, column j.

toArray

open override fun toArray(): Array<DoubleArray>(source)

Materialise into a fresh Array<DoubleArray> of rows, independent of the internal storage.

toString

open override fun toString(): String(source)

view

fun view(row: Int, rows: Int, column: Int, cols: Int): StridedMatrixView(source)

A live submatrix retaining this view's physical leadingDimension.

Link copied to clipboard
fun Matrix.gemvInto(x: Vector, destination: DoubleArray)

gemvInto with alpha = 1, beta = 0, so destination receives A * x.

fun Matrix.gemvInto(alpha: Double, x: Vector, beta: Double, destination: DoubleArray)

y = alpha * A * x + beta * y (BLAS dgemv) into destination, for any Matrix against any Vector. beta == 0.0 overwrites destination without reading it, so a destination left holding NaN still yields a clean product.

Link copied to clipboard
@JvmName(name = "multiply")
operator fun Matrix.times(x: Vector): DenseVector

Matrix-vector product into a fresh dense result for any Matrix against any Vector. gemvInto writes into a destination the caller owns, and provides the alpha and beta scalars.