1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//! Solvers of F(z) = 0 in double-, quad- and octo-double precision, written over a [`Problem`]: a problem gives its
//! residual and its exact Jacobian in one of multidouble's precisions (`Precision`: [`Double`], [`Quad`], [`Octo`]),
//! and the solvers here need nothing else of it. The multiple-shooting layout of the crate multishoot is one such
//! problem.
//!
//! * [`newton`]: the Newton step and the damped Newton loop, and the chord and Shamanskii methods that reuse its
//! factors;
//! * [`gcr`]: a preconditioned Krylov solver (GMRES in its GCR form) on exact Jacobian-vector products, and the Newton
//! method whose steps it refines from an approximate factorization;
//! * [`lm`]: the Levenberg-Marquardt method, for starts where Newton's method stalls or its Jacobian is singular;
//! * [`anm`]: the asymptotic numerical method, the Taylor series of a solution branch in the problem's parameter;
//! * [`predict`]: predictors for continuation: Lagrange extrapolation, the cubic Hermite, and the exact tangent;
//! * [`singularity`]: the nearest singularities of a series from its coefficients: Pade poles that recur across the
//! approximants' orders, the root test's radius, the ratio method and a recurrence for a conjugate pair;
//! * [`subspace`]: the weakest singular directions of the Jacobian, Newton's method with them removed from its steps,
//! and the sensitivities of single unknowns to the residual;
//! * [`winding`]: the number and the places of the zeros of an analytic function inside a polygon, by the argument
//! principle, and Muller's method for one zero;
//! * [`prec`]: helpers for states held as part arrays in any of the precisions.
//!
//! A problem is its residual and its exact Jacobian. Here x^2 = 2 in double-double, solved by the damped Newton loop:
//!
//! ```
//! use multisolver::multidouble::linalg::ld_for;
//! use multisolver::newton::{newton, NewtonOpts};
//! use multisolver::{Double, Problem, DD};
//!
//! struct Sqrt2;
//!
//! impl Problem<Double> for Sqrt2 {
//! fn len(&self) -> usize {
//! 1
//! }
//! fn residual(&self, z: &[&[f64]], _par: bool) -> Result<Vec<DD>, String> {
//! let x = DD { hi: z[0][0], lo: z[1][0] };
//! Ok(vec![x * x - DD::from_f64(2.0)])
//! }
//! fn jacobian(&self, z: &[&[f64]], _par: bool) -> Result<(Vec<Vec<f64>>, usize), String> {
//! let ld = ld_for(1);
//! let d = DD { hi: z[0][0], lo: z[1][0] }.mul_f(2.0);
//! let (mut hi, mut lo) = (vec![0.0; ld], vec![0.0; ld]);
//! (hi[0], lo[0]) = (d.hi, d.lo);
//! Ok((vec![hi, lo], ld))
//! }
//! }
//!
//! let mut z = vec![vec![1.0], vec![0.0]];
//! let report = newton::<Double, _>(&Sqrt2, &mut z, &NewtonOpts::default()).unwrap();
//! let x = DD { hi: z[0][0], lo: z[1][0] };
//! assert!(report.converged && (x * x - DD::from_f64(2.0)).hi.abs() <= 1e-30);
//! ```
pub use multidouble;
pub use DD;
pub use ;
pub use Native;
pub use ;
/// A system F(z) = 0 of `len()` equations in as many unknowns, evaluated in the precision P. The state z is held as
/// P::PARTS part arrays of f64 (part q of unknown i at `z[q][i]`).
/// A problem whose Jacobian-vector product J v can be formed without the Jacobian, exact to the precision P
/// A problem whose equations depend on a parameter p, with the residual's Taylor series in it: the coefficients of
/// F(sum_k z_k h^k, p0 + h) in h, exact to the precision P