Statistical Methods

Validate a Matrix-Free Operator's Contract

Define the task

A matrix-free operator supplies matrix-vector products without storing every matrix entry. This can reduce storage in iterative algorithms, but it shifts validation responsibility to the supplied function. Declare input and output dimensions, data type and whether an adjoint operation is provided. A function that accepts a vector is not necessarily linear. Parameters and hidden state must remain consistent throughout a solve; silently changing them changes the problem.

Carry out the check

Test additivity A(u+v)=Au+Av and scaling A(cu)=cAu on several synthetic inputs with scale-aware tolerances. Compare with an explicitly constructed small matrix where possible. If supplying an adjoint, check the inner-product relation against independent vectors and use conjugation correctly for complex values. Verify shape handling, including a column-vector input where required by the library contract. These tests detect implementation mistakes but do not prove correctness for every possible input or establish positive definiteness.

Worked hypothetical example

For hypothetical A(x1,x2)=(2x1+x2,3x2), u=(1,0) and v=(0,1), outputs are Au=(2,0), Av=(1,3), and A(u+v)=(3,3), matching their sum. Its transpose maps (a,b) to (2a,a+3b). In contrast, adding a fixed one to every output breaks linearity because A(0) is then nonzero. Save these reference calculations and rerun operator tests when indexing, scaling or boundary logic changes.

Method checked 21 November 2026 against Primary method documentation: LinearOperator.

Related reading

Reading path: Analyze data. Guide 192 of 192. Choose any guide to suit your project.

Statistical Methods

Reconstruct a covariance matrix from its Cholesky factor

Check triangular-factor orientation before reconstructing a covariance matrix.

Statistical Methods

Identify which matrix norm a numerical report uses

Compare absolute row sums, column sums and Frobenius magnitude. Includes a worked matrix example and reproducibility checks.

Browse this reading pathTools for this stageGuides and downloads for this stage