Skip to content

linalg · LinearOperator

6 accepted declarations. Python and Rust forms, contracts, evidence, failure boundaries, and checked usages are kept together below.

Worked example

The complete checked program Apply and multiply canonical sparse exact operators uses this API directly.

# SPDX-License-Identifier: MIT
# Copyright (c) 2026 Benjamin Antieau and Deven Manam
"""Apply and multiply canonical sparse exact operators."""

from noether import Z
from noether.linalg import SparseMatrix, Vector


def main() -> None:
    operator = SparseMatrix.from_triplets(
        Z,
        (3, 3),
        [(0, 0, 2), (0, 2, -1), (1, 1, 3), (2, 0, 4)],
    )
    vector = Vector.from_values(Z, [5, 7, 11])
    image = operator.apply(vector)
    assert image.to_values() == [-1, 21, 20]
    assert (operator @ operator).nnz == 4
    print(f"A v = {image.to_values()}; nnz(A^2) = {(operator @ operator).nnz}")


if __name__ == "__main__":
    main()

Run it with .venv/bin/python examples/05_sparse_exact_operators.py.

linalg.LinearOperator

A linear map acting on vectors or dense blocks over one context.

class LinearOperator

noether::linalg::LinearOperator · Direct Rust declaration

pub trait LinearOperator<R: Ring>: SemanticType { // Required methods fn ring(&self) -> &R; fn input_dimension(&self) -> usize; fn output_dimension(&self) -> usize; fn apply(&self, vector: &Vector<R>) -> Result<Vector<R>, LinalgError>; fn apply_block(&self, block: &Matrix<R>) -> Result<Matrix<R>, LinalgError>; }
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, flint-core, m4rst, m4rst-distributed, m4rste, mzs, pwvla, spar-core, sparla, sparb, lattice-enum
GIL attached / bounded

Executable usage: validation/unit/linalg/test_sparse_matrix_facade.py:37 · validation/unit/linalg/test_sparse_matrix_facade.py:9 · validation/unit/linalg/test_vector_facade.py:11 · validation/unit/linalg/test_vector_facade.py:49

linalg.LinearOperator.apply

Apply this LinearOperator to the supplied value.

(self, vector: Vector[R]) -> Vector[R]

noether::linalg::LinearOperator · Python projection

Python projection convenience over this Rust mathematical type
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, flint-core, m4rst, m4rst-distributed, m4rste, mzs, pwvla, spar-core, sparla, sparb, lattice-enum
GIL attached / bounded

Executable usage: examples/05_sparse_exact_operators.py:16 · validation/unit/commalg/test_local_algebra.py:94 · validation/unit/commalg/test_local_algebra.py:97 · validation/unit/commalg/test_polynomial_facade.py:199 · validation/unit/commalg/test_quotient_facade.py:186 · validation/unit/groups/test_weight_characters.py:39

linalg.LinearOperator.apply_block

Compute apply block for this LinearOperator.

(self, block: Matrix[R]) -> Matrix[R]

noether::linalg::LinearOperator · Python projection

Python projection convenience over this Rust mathematical type
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, flint-core, m4rst, m4rst-distributed, m4rste, mzs, pwvla, spar-core, sparla, sparb, lattice-enum
GIL attached / bounded

Executable usage: validation/unit/infra/test_discovery.py:198 · validation/unit/linalg/test_semilinear_facade.py:22 · validation/unit/linalg/test_sparse_matrix_facade.py:113 · validation/unit/linalg/test_sparse_matrix_facade.py:65 · validation/unit/linalg/test_vector_facade.py:54

linalg.LinearOperator.input_dimension

Return the input dimension recorded by this LinearOperator.

(self) -> int

noether::linalg::LinearOperator · Python projection

Python projection convenience over this Rust mathematical type
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, flint-core, m4rst, m4rst-distributed, m4rste, mzs, pwvla, spar-core, sparla, sparb, lattice-enum
GIL attached / bounded

Executable usage: validation/unit/linalg/test_vector_facade.py:50 · validation/parity/linalg/test_exact_solution_modules_parity.py:163 · validation/parity/linalg/test_exact_solution_modules_parity.py:177 · validation/parity/linalg/test_exact_solution_modules_parity.py:200 · validation/parity/linalg/test_exact_solution_modules_parity.py:210

linalg.LinearOperator.output_dimension

Return the output dimension recorded by this LinearOperator.

(self) -> int

noether::linalg::LinearOperator · Python projection

Python projection convenience over this Rust mathematical type
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, flint-core, m4rst, m4rst-distributed, m4rste, mzs, pwvla, spar-core, sparla, sparb, lattice-enum
GIL attached / bounded

Executable usage: validation/unit/linalg/test_vector_facade.py:51

linalg.LinearOperator.ring

Return the ring recorded by this LinearOperator.

(self) -> R

noether::linalg::LinearOperator · Python projection

Python projection convenience over this Rust mathematical type
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, flint-core, m4rst, m4rst-distributed, m4rste, mzs, pwvla, spar-core, sparla, sparb, lattice-enum
GIL attached / bounded

Executable usage: examples/11_qadic_witt_vectors.py:3 · examples/13_chinese_remainder_theorem.py:10 · examples/13_chinese_remainder_theorem.py:12 · examples/13_chinese_remainder_theorem.py:9 · examples/14_weighted_polynomials.py:10 · examples/14_weighted_polynomials.py:11