Compressed sparse row format Created 2026-10-20 Updated 2026-11-05
Compressed sparse row format stores a sparse matrix using arrays of nonzero values, their column indices, and an array of row offsets. For zero-based row , its entries occupy positions from through .
For , one representation is , , . Equal adjacent offsets encode an empty row. This permits matrix-vector product in time without storing zeros. Whether columns are sorted or duplicates are permitted is an implementation convention.
Conjugate gradient method Created 2026-09-24 Updated 2026-11-05
The conjugate gradient method solves for a real symmetric positive-definite matrix by minimizing over expanding affine Krylov subspaces. Its successive nonzero search directions are A-conjugate directions, so a new line minimization preserves the optimality already obtained along earlier directions.
Start with and stop if it is zero; otherwise put . The recurrence is
Stop when the new residual is zero, before attempting another division. Each step uses a matrix-vector product, a few inner products and vector updates; a sparse or implicit linear operator can therefore be used without forming its inverse.[ref]
For , and , the first step has , and . The next conjugate direction is and its step size is , giving the exact solution . Finite termination of the conjugate gradient method is an exact-arithmetic statement; floating-point loss of orthogonality changes the practical stopping analysis.
Linear solver Created 2026-10-25 Updated 2026-11-05
A linear solver is an algorithm that computes a solution or controlled approximation to a linear system . For an invertible matrix, the mathematical solution is unique. A direct linear solver usually computes a matrix factorization, such as Pivoted LU decomposition, followed by triangular solves. An iterative method instead updates an approximate vector, often using matrix-vector products and a matrix preconditioner.
A stopping rule should reflect the required accuracy. The linear-system residual can be scaled as
when the denominator is positive, using compatible vector norms and an induced matrix norm. This compares equation error with the input scale; a condition number is still needed to interpret it as a forward error guarantee. In a differential equation computation, the linear solver tolerance must be small enough relative to the intended discretization accuracy. A stable time step alone does not control errors left by an inaccurate inner solve.
Matrix-vector product Created 2026-10-25 Updated 2026-11-05
For an -by- matrix and an -component column vector , their matrix-vector product is the column vector with entries
Equivalently, it is the linear combination of the columns of with coefficients . This formula uses no complex conjugation, so over the complex numbers it should not be confused with an inner product of a row and . A dense evaluation costs arithmetic operations in Big O notation.
Since , the QR factorization gives
First compute by a matrix-vector product, costing scalar multiplications and additions for dense . Then solve the upper triangular matrix system by back substitution:
Every denominator is nonzero because is invertible. The back substitution costs multiplications and subtractions together, plus divisions, for arithmetic operations. Including , the total is arithmetic operations under this scalar counting convention, hence , with denoting Big O notation. The already supplied QR factorization is reused; no matrix inverse needs to be computed.
For , and are square orthogonal matrices. Multiply the linear system successively by , and to obtain
With the singular value decomposition already supplied, compute , divide by , then form . The two dense matrix-vector products each cost arithmetic operations in Big O notation, and the diagonal scaling costs . Thus
If the singular value decomposition first has to be computed, its usual dense cost is ; that is a separate setup cost and can be reused for further right-hand sides.