pysolver_view.roots.solvers.linear_model module#

Dense trust-region subproblems with reusable QR and lazy SVD factors.

The ordinary full-rank Gauss–Newton path uses column-pivoted QR. Hybrid Broyden updates retain that permutation and update the factors in quadratic work; a triangular condition estimate guards this no-longer-pivoted update. An SVD supplies minimum-norm solutions for ill-conditioned models and solves the damped LM subproblem. No normal-equation matrix is formed.

class pysolver_view.roots.solvers.linear_model.LinearModel(a, f, stats=None, refresh_interval=25, *, compute_gradient=True)[source]#

Bases: object

Factor and update the linear residual model f + a @ step.

The matrix a is the Jacobian in fixed scaled coordinates, f is the residual at the accepted base, and g = a.T @ f is the model gradient. The attributes q and r are QR factors of a[:, perm]. The cached damping value _mu is normalized by the largest singular value squared.

a has at least as many rows as columns. stats is a shared mutable counter dictionary; costs accumulate across model instances. A failed update returns False and the caller must discard this model and obtain a freshly evaluated Jacobian. Refreshing QR every refresh_interval successful updates limits accumulated factorization drift; it does not evaluate a Jacobian or discard the Broyden approximation.

property gauss_newton#

Return the cached unconstrained least-squares step for the current model.

Use a guarded triangular QR solve when possible; otherwise use an SVD minimum-norm solution with a numerical-rank cutoff. The returned cached array is internal state; step() supplies a copy when returning it to the driver.

levenberg_marquardt_step(radius)[source]#

Return the unconstrained step if feasible, otherwise solve LM damping.

property newton_raphson#

Return a strict square full-rank Newton direction without rank truncation.

A numerically singular model raises LinAlgError rather than silently replacing Newton with a pseudoinverse least-squares direction.

property numerical_rank#

Return full rank for guarded QR, otherwise the SVD numerical rank.

powell_hybrid_step(radius)[source]#

Return the unconstrained step if feasible, otherwise follow the dogleg.

step(method, radius)[source]#

Select a named subproblem step for experiments using the model directly.

Solver entry points bind the explicit step functions once before iteration. Short method aliases remain supported by this compatibility interface.

update(correction, direction, f_new)[source]#

Apply a += outer(correction, direction) and anchor at f_new.

A finite rejected trial can still improve the Jacobian approximation; its caller supplies the unchanged accepted residual in that case. Nonfinite input, gradient overflow, or a poorly conditioned updated QR requests an exact-Jacobian refresh by returning False.