lacuna.array_api#
- lacuna.array_api.eye(n_rows, n_cols=None, k=0, *, dtype=None, device=None)[source]#
Create an identity matrix (Array API compliant).
- Parameters:
n_rows (int) – Number of rows (for square matrix, this is the size).
n_cols (int, optional) – Number of columns (if None, creates square matrix).
k (int, optional) – Diagonal offset (default: 0 for main diagonal).
dtype (dtype, optional) – Data type (default: float64).
device (str, optional) – Device (default: “cpu”).
- Returns:
Identity matrix using Rust backend.
- Return type:
Notes
Currently only supports k=0 (main diagonal) and square matrices.
Examples
>>> import lacuna.array_api as xp >>> I = xp.eye(5) >>> I.sum() 5.0
- lacuna.array_api.zeros(shape, *, dtype=None, device=None)[source]#
Create a sparse zero matrix (Array API compliant).
- Parameters:
- Returns:
Sparse zero matrix using Rust backend.
- Return type:
Examples
>>> import lacuna.array_api as xp >>> A = xp.zeros((10, 20)) >>> A.nnz 0
Modules