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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
//! Intrinsic S² (sphere) smooth specification types.
//!
//! These configuration types own the user-facing description of an intrinsic
//! sphere smooth (construction method, reproducing kernel, penalty order, and
//! realized-design identifiability policy). The sibling `sphere_kernels` and
//! `sphere_spectral` modules consume them to assemble the basis and penalty.
use Array2;
use ;
use CenterStrategy;
/// Which intrinsic S² smooth construction to use.
///
/// - `Wahba`: reproducing-kernel basis on a center set selected by
/// `center_strategy`. The kernel function itself is chosen via
/// `wahba_kernel` (Sobolev = true Σ [l(l+1)]^{-m} P_l kernel,
/// Pseudo = Wahba's 1981 closed-form pseudo-spline).
/// - `Harmonic`: real spherical-harmonic truncation up to `max_degree` with
/// the Laplace-Beltrami eigenvalue penalty `[l(l+1)]^m`. Basis
/// dimension is `max_degree * (max_degree + 2)`; centers are ignored.
/// Which reproducing kernel to use for `SphereMethod::Wahba`.
///
/// Both options yield positive-definite reproducing kernels on S² with
/// the same family of `penalty_order m ∈ {1, 2, 3, 4}`. They define
/// *different* RKHS, however:
///
/// - **Sobolev** (default, more correct): true Wahba/Sobolev kernel
/// `K_m(γ) = (1/4π) Σ_{l ≥ 1} (2l+1) · [l(l+1)]^{-m} · P_l(cos γ)`,
/// the reproducing kernel of `H^m(S²)` under the Laplace–Beltrami
/// inner product. Penalty quadratic form recovers
/// `‖f‖²_{H^m} = Σ_l [l(l+1)]^m · |f̂_l|²`.
/// For m=1, 2, 3 this is evaluated via the closed forms from
/// Beatson & zu Castell (2018) "Thinplate Splines on the Sphere"
/// (SIGMA 14 (2018), 083) using elementary functions plus the
/// di/trilogarithm. For m=4 we fall back to the spectral Legendre
/// series (96 terms ⇒ truncation error ≲ 1e-12).
///
/// - **Pseudo**: Wahba 1981's "pseudo-spline" kernel with Legendre
/// weights `2 / [(l+1)(l+2)···(l+m+1)]` (decaying as `l^{-(m+1)}`,
/// different from Sobolev's `l^{-2m}`). Faster to evaluate (one
/// elementary polynomial in `sin(γ/2)`, `log`), and matches mgcv's
/// `bs="sos"` exactly. At `m=4` the pseudo-spline produces
/// numerically tiny kernel values (`K(p,p) ≈ 3e-4`) and the basis
/// pipeline historically collapsed the smooth contribution to zero
/// — the cure is the REML scale-invariance fix in the solver, not
/// the kernel itself.
///
/// Default is **Sobolev** because it matches the canonical "Wahba
/// spline of order m on S²" interpretation. Use `Pseudo` for exact
/// mgcv compatibility.
/// Intrinsic S² (sphere) smooth configuration.
/// Realized-design identifiability policy for the Wahba spherical spline (#532).