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
//! Least squares optimization and curve fitting.
//!
//! This module provides methods for solving nonlinear least squares problems:
//! minimize ||f(x)||^2 = sum(f_i(x)^2)
//!
//! where f: R^n -> R^m is a vector-valued function (residuals).
//!
//! # Runtime-Generic Architecture
//!
//! All operations are implemented generically over numr's `Runtime` trait.
//! The same code works on CPU, CUDA, and WebGPU backends with **zero duplication**.
//!
//! ```text
//! least_squares/
//! ├── mod.rs # Exports only
//! ├── traits/
//! │ ├── mod.rs # Exports only
//! │ └── least_squares.rs # Trait definition + types
//! ├── impl_generic/
//! │ ├── mod.rs # Exports only
//! │ ├── leastsq.rs # Unbounded LM algorithm
//! │ └── bounded.rs # Bounded LM algorithm
//! ├── cpu/
//! │ ├── mod.rs # Exports only
//! │ └── least_squares.rs # CPU impl
//! ├── cuda/
//! │ ├── mod.rs # Exports only
//! │ └── least_squares.rs # CUDA impl
//! └── wgpu/
//! ├── mod.rs # Exports only
//! └── least_squares.rs # WebGPU impl
//! ```
pub use ;