SparseMatrix
Compressed-sparse-column form: column j occupies colPointers(j) until colPointers(j + 1) of rowIndices and values, rows strictly ascending. A stored zero is preserved, and a 64-bit-index host library needs a widening copy.
Use copyColumnPointers, copyRowIndices, or forEachInColumn for safe structural access. colPointers and rowIndices are live zero-copy escape hatches for specialized kernels and require UnsafeKoblasApi; mutating them can invalidate the CSC structure. values remains live so coefficients can be updated without rebuilding the pattern; do not use the matrix as a hash-map key while mutating it. Inserting an entry through set or changing the pattern through Matrix.copyFrom replaces the buffers; obtain current arrays from the accessors after structural writes.
Properties
colPointers
Live column pointers; structural writes may replace this buffer. Do not mutate it.
cols
nnz
rowIndices
Live row positions; structural writes may replace this buffer. Do not mutate it.
rows
values
Live coefficients; structural writes may replace this buffer.
Functions
columnView
A writable view of column, indexed from zero within this matrix. Changes through the vector update the matrix. The view borrows storage; use Vector.copy for an independent result. The vector follows this column after structural changes, including writes through other views.
copyColumnPointers
A copy of the CSC column start offsets, of length cols + 1.
copyRowIndices
A copy of the stored row indices, parallel to values.
equals
forEachColumns
Visits writable column views in column order, including empty columns. Returns no new matrix.
forEachInColumn
get
hashCode
set
toArray
Materialises into a fresh rows × cols array of rows; unstored entries stay zero.
toString
A writable vector view of column. Mutations update this matrix; the vector's indices are local rows. Built-in containers return DenseVector or SparseVector; other implementations use Matrix.get and Matrix.set. Use Vector.copy for independent storage.
Visits writable column views in column order, including empty columns. Mutations through a callback's vector update this matrix. Concrete containers retain their dense or sparse callback type for calls to KoblasEngine; through Matrix, callbacks use the generic Vector contract. Returns no new matrix.
Visits stored entries as (row, column, value), columns first and rows ascending within each column. SparseMatrix visits only stored positions, including stored zeros; other implementations visit every entry. Dense views report local indices and exclude padding. Empty matrices invoke no callbacks.
Matrix norm of type: Norm.Frobenius is the rescaled square root of the sum of squared entries, Norm.One is the largest absolute column sum, Norm.Infinity is the largest absolute row sum, and Norm.MaxAbs is the maximum absolute entry. A matrix with either dimension empty has norm zero.
Plain sum of all entries. Dense storage uses KoblasEngine.sum through the default koblas engine, sparse storage sums only its stored values, and custom matrices are read through Matrix.get. An empty matrix sums to zero. Summation order and rounding depend on the storage and engine.
Sums along axis into a fresh dense vector: axis = 0 reduces rows and returns Matrix.cols column sums; axis = 1 reduces columns and returns Matrix.rows row sums. A zero-length reduced dimension contributes zero to each result. The result owns its storage.
Fresh transposed matrix. Sparse storage remains CSC and preserves stored zeros; other implementations produce dense storage. Views transpose only their logical entries. For products, prefer the transpose flags on KoblasEngine.gemv and KoblasEngine.gemm to avoid materializing the transpose.