freealg 0.7.17__py3-none-any.whl → 0.7.18__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. freealg/__init__.py +8 -6
  2. freealg/__version__.py +1 -1
  3. freealg/_algebraic_form/_branch_points.py +18 -18
  4. freealg/_algebraic_form/_continuation_algebraic.py +13 -13
  5. freealg/_algebraic_form/_cusp.py +15 -15
  6. freealg/_algebraic_form/_cusp_wrap.py +6 -6
  7. freealg/_algebraic_form/_decompress.py +16 -16
  8. freealg/_algebraic_form/_decompress4.py +31 -31
  9. freealg/_algebraic_form/_decompress5.py +23 -23
  10. freealg/_algebraic_form/_decompress6.py +13 -13
  11. freealg/_algebraic_form/_decompress7.py +15 -15
  12. freealg/_algebraic_form/_decompress8.py +17 -17
  13. freealg/_algebraic_form/_decompress9.py +18 -18
  14. freealg/_algebraic_form/_decompress_new.py +17 -17
  15. freealg/_algebraic_form/_decompress_new_2.py +57 -57
  16. freealg/_algebraic_form/_decompress_util.py +10 -10
  17. freealg/_algebraic_form/_decompressible.py +292 -0
  18. freealg/_algebraic_form/_edge.py +10 -10
  19. freealg/_algebraic_form/_homotopy4.py +9 -9
  20. freealg/_algebraic_form/_homotopy5.py +9 -9
  21. freealg/_algebraic_form/_support.py +19 -19
  22. freealg/_algebraic_form/algebraic_form.py +262 -468
  23. freealg/_base_form.py +401 -0
  24. freealg/_free_form/__init__.py +1 -4
  25. freealg/_free_form/_density_util.py +1 -1
  26. freealg/_free_form/_plot_util.py +3 -511
  27. freealg/_free_form/free_form.py +8 -367
  28. freealg/_util.py +59 -11
  29. freealg/distributions/__init__.py +2 -1
  30. freealg/distributions/_base_distribution.py +163 -0
  31. freealg/distributions/_chiral_block.py +137 -11
  32. freealg/distributions/_compound_poisson.py +141 -47
  33. freealg/distributions/_deformed_marchenko_pastur.py +138 -33
  34. freealg/distributions/_deformed_wigner.py +98 -9
  35. freealg/distributions/_fuss_catalan.py +269 -0
  36. freealg/distributions/_kesten_mckay.py +4 -130
  37. freealg/distributions/_marchenko_pastur.py +8 -196
  38. freealg/distributions/_meixner.py +4 -130
  39. freealg/distributions/_wachter.py +4 -130
  40. freealg/distributions/_wigner.py +10 -127
  41. freealg/visualization/__init__.py +2 -2
  42. freealg/visualization/{_rgb_hsv.py → _domain_coloring.py} +37 -29
  43. freealg/visualization/_plot_util.py +513 -0
  44. {freealg-0.7.17.dist-info → freealg-0.7.18.dist-info}/METADATA +1 -1
  45. freealg-0.7.18.dist-info/RECORD +74 -0
  46. freealg-0.7.17.dist-info/RECORD +0 -69
  47. /freealg/{_free_form/_sample.py → _sample.py} +0 -0
  48. /freealg/{_free_form/_support.py → _support.py} +0 -0
  49. {freealg-0.7.17.dist-info → freealg-0.7.18.dist-info}/WHEEL +0 -0
  50. {freealg-0.7.17.dist-info → freealg-0.7.18.dist-info}/licenses/AUTHORS.txt +0 -0
  51. {freealg-0.7.17.dist-info → freealg-0.7.18.dist-info}/licenses/LICENSE.txt +0 -0
  52. {freealg-0.7.17.dist-info → freealg-0.7.18.dist-info}/top_level.txt +0 -0
@@ -22,14 +22,14 @@ __all__ = ['decompress_newton']
22
22
  # eval P partials
23
23
  # ===============
24
24
 
25
- def eval_P_partials(z, m, a_coeffs):
25
+ def eval_P_partials(z, m, coeffs):
26
26
  """
27
27
  Evaluate P(z,m) and its partial derivatives dP/dz and dP/dm.
28
28
 
29
- This assumes P is represented by `a_coeffs` in the monomial basis
29
+ This assumes P is represented by `coeffs` in the monomial basis
30
30
 
31
31
  P(z, m) = sum_{j=0..s} a_j(z) * m^j,
32
- a_j(z) = sum_{i=0..deg_z} a_coeffs[i, j] * z^i.
32
+ a_j(z) = sum_{i=0..deg_z} coeffs[i, j] * z^i.
33
33
 
34
34
  The function returns P, dP/dz, dP/dm with broadcasting over z and m.
35
35
 
@@ -39,7 +39,7 @@ def eval_P_partials(z, m, a_coeffs):
39
39
  First argument to P.
40
40
  m : complex or array_like of complex
41
41
  Second argument to P. Must be broadcast-compatible with `z`.
42
- a_coeffs : ndarray, shape (deg_z+1, s+1)
42
+ coeffs : ndarray, shape (deg_z+1, s+1)
43
43
  Coefficient matrix for P in the monomial basis.
44
44
 
45
45
  Returns
@@ -61,14 +61,14 @@ def eval_P_partials(z, m, a_coeffs):
61
61
  --------
62
62
  .. code-block:: python
63
63
 
64
- P, Pz, Pm = eval_P_partials(1.0 + 1j, 0.2 + 0.3j, a_coeffs)
64
+ P, Pz, Pm = eval_P_partials(1.0 + 1j, 0.2 + 0.3j, coeffs)
65
65
  """
66
66
 
67
67
  z = numpy.asarray(z, dtype=complex)
68
68
  m = numpy.asarray(m, dtype=complex)
69
69
 
70
- deg_z = int(a_coeffs.shape[0] - 1)
71
- s = int(a_coeffs.shape[1] - 1)
70
+ deg_z = int(coeffs.shape[0] - 1)
71
+ s = int(coeffs.shape[1] - 1)
72
72
 
73
73
  if (z.ndim == 0) and (m.ndim == 0):
74
74
  zz = complex(z)
@@ -78,7 +78,7 @@ def eval_P_partials(z, m, a_coeffs):
78
78
  ap = numpy.empty(s + 1, dtype=complex)
79
79
 
80
80
  for j in range(s + 1):
81
- c = a_coeffs[:, j]
81
+ c = coeffs[:, j]
82
82
 
83
83
  val = 0.0 + 0.0j
84
84
  for i in range(deg_z, -1, -1):
@@ -118,10 +118,10 @@ def eval_P_partials(z, m, a_coeffs):
118
118
  Pm = numpy.zeros(zz.size, dtype=complex)
119
119
 
120
120
  for j in range(s + 1):
121
- aj = zp @ a_coeffs[:, j]
121
+ aj = zp @ coeffs[:, j]
122
122
  P += aj * mp[:, j]
123
123
 
124
- ajp = dzp @ a_coeffs[:, j]
124
+ ajp = dzp @ coeffs[:, j]
125
125
  Pz += ajp * mp[:, j]
126
126
 
127
127
  if j >= 1:
@@ -134,7 +134,7 @@ def eval_P_partials(z, m, a_coeffs):
134
134
  # fd solve w
135
135
  # ==========
136
136
 
137
- # def fd_solve_w(z, t, a_coeffs, w_init, max_iter=50, tol=1e-12,
137
+ # def fd_solve_w(z, t, coeffs, w_init, max_iter=50, tol=1e-12,
138
138
  # armijo=1e-4, min_lam=1e-6, w_min=1e-14):
139
139
  # """
140
140
  # Solve for w = m(t,z) from the implicit FD equation using damped Newton.
@@ -155,7 +155,7 @@ def eval_P_partials(z, m, a_coeffs):
155
155
  # Query point in the complex plane.
156
156
  # t : float
157
157
  # Time parameter (tau = exp(t)).
158
- # a_coeffs : ndarray
158
+ # coeffs : ndarray
159
159
  # Coefficients defining P(zeta,y) in the monomial basis.
160
160
  # w_init : complex
161
161
  # Initial guess for w.
@@ -189,7 +189,7 @@ def eval_P_partials(z, m, a_coeffs):
189
189
  # .. code-block:: python
190
190
  #
191
191
  # w, ok = fd_solve_w(
192
- # z=0.5 + 1e-6j, t=2.0, a_coeffs=a_coeffs, w_init=m1_fn(0.5 + 1e-6j),
192
+ # z=0.5 + 1e-6j, t=2.0, coeffs=coeffs, w_init=m1_fn(0.5 + 1e-6j),
193
193
  # max_iter=50, tol=1e-12
194
194
  # )
195
195
  # """
@@ -213,7 +213,7 @@ def eval_P_partials(z, m, a_coeffs):
213
213
  # zeta = z + alpha / w
214
214
  # y = tau * w
215
215
  #
216
- # F, Pz, Py = eval_P_partials(zeta, y, a_coeffs)
216
+ # F, Pz, Py = eval_P_partials(zeta, y, coeffs)
217
217
  # F = complex(F)
218
218
  # Pz = complex(Pz)
219
219
  # Py = complex(Py)
@@ -243,7 +243,7 @@ def eval_P_partials(z, m, a_coeffs):
243
243
  # zeta_new = z + alpha / w_new
244
244
  # y_new = tau * w_new
245
245
  #
246
- # F_new = eval_P_partials(zeta_new, y_new, a_coeffs)[0]
246
+ # F_new = eval_P_partials(zeta_new, y_new, coeffs)[0]
247
247
  # F_new = complex(F_new)
248
248
  #
249
249
  # if abs(F_new) <= (1.0 - armijo * lam) * F_abs:
@@ -256,10 +256,10 @@ def eval_P_partials(z, m, a_coeffs):
256
256
  # if not ok:
257
257
  # return w, False
258
258
  #
259
- # F_end = eval_P_partials(z + alpha / w, tau * w, a_coeffs)[0]
259
+ # F_end = eval_P_partials(z + alpha / w, tau * w, coeffs)[0]
260
260
  # return w, (abs(F_end) <= 10.0 * tol)
261
261
 
262
- def fd_solve_w(z, t, a_coeffs, w_init, max_iter=50, tol=1e-12,
262
+ def fd_solve_w(z, t, coeffs, w_init, max_iter=50, tol=1e-12,
263
263
  armijo=1e-4, min_lam=1e-6, w_min=1e-14):
264
264
  """
265
265
  Solve for w = m(t,z) from the implicit FD equation using damped Newton.
@@ -280,7 +280,7 @@ def fd_solve_w(z, t, a_coeffs, w_init, max_iter=50, tol=1e-12,
280
280
  Query point in the complex plane.
281
281
  t : float
282
282
  Time parameter (tau = exp(t)).
283
- a_coeffs : ndarray
283
+ coeffs : ndarray
284
284
  Coefficients defining P(zeta,y) in the monomial basis.
285
285
  w_init : complex
286
286
  Initial guess for w.
@@ -314,7 +314,7 @@ def fd_solve_w(z, t, a_coeffs, w_init, max_iter=50, tol=1e-12,
314
314
  .. code-block:: python
315
315
 
316
316
  w, ok = fd_solve_w(
317
- z=0.5 + 1e-6j, t=2.0, a_coeffs=a_coeffs, w_init=m1_fn(0.5 + 1e-6j),
317
+ z=0.5 + 1e-6j, t=2.0, coeffs=coeffs, w_init=m1_fn(0.5 + 1e-6j),
318
318
  max_iter=50, tol=1e-12
319
319
  )
320
320
  """
@@ -341,7 +341,7 @@ def fd_solve_w(z, t, a_coeffs, w_init, max_iter=50, tol=1e-12,
341
341
  # zeta = z + alpha / w
342
342
  # y = tau * w
343
343
  #
344
- # F, Pz, Py = eval_P_partials(zeta, y, a_coeffs)
344
+ # F, Pz, Py = eval_P_partials(zeta, y, coeffs)
345
345
  # F = complex(F)
346
346
  # Pz = complex(Pz)
347
347
  # Py = complex(Py)
@@ -371,7 +371,7 @@ def fd_solve_w(z, t, a_coeffs, w_init, max_iter=50, tol=1e-12,
371
371
  # zeta_new = z + alpha / w_new
372
372
  # y_new = tau * w_new
373
373
  #
374
- # F_new = eval_P_partials(zeta_new, y_new, a_coeffs)[0]
374
+ # F_new = eval_P_partials(zeta_new, y_new, coeffs)[0]
375
375
  # F_new = complex(F_new)
376
376
  #
377
377
  # if abs(F_new) <= (1.0 - armijo * lam) * F_abs:
@@ -397,7 +397,7 @@ def fd_solve_w(z, t, a_coeffs, w_init, max_iter=50, tol=1e-12,
397
397
  # P(z + beta/y, y) = 0, beta = tau - 1.
398
398
  # Multiply by y^deg_z to clear denominators and get a polynomial in y.
399
399
 
400
- a = numpy.asarray(a_coeffs, dtype=numpy.complex128)
400
+ a = numpy.asarray(coeffs, dtype=numpy.complex128)
401
401
  deg_z = a.shape[0] - 1
402
402
  deg_m = a.shape[1] - 1
403
403
 
@@ -460,13 +460,13 @@ def fd_solve_w(z, t, a_coeffs, w_init, max_iter=50, tol=1e-12,
460
460
  w = complex(best)
461
461
 
462
462
  # final residual check
463
- F_end = eval_P_partials(z + alpha / w, tau * w, a_coeffs)[0]
463
+ F_end = eval_P_partials(z + alpha / w, tau * w, coeffs)[0]
464
464
  return w, (abs(F_end) <= 1e3 * tol)
465
465
 
466
466
  # -------------------
467
467
 
468
468
 
469
- F_end = eval_P_partials(z + alpha / w, tau * w, a_coeffs)[0]
469
+ F_end = eval_P_partials(z + alpha / w, tau * w, coeffs)[0]
470
470
  return w, (abs(F_end) <= 10.0 * tol)
471
471
 
472
472
 
@@ -474,7 +474,7 @@ def fd_solve_w(z, t, a_coeffs, w_init, max_iter=50, tol=1e-12,
474
474
  # NEW FUNCTION
475
475
  # ============
476
476
 
477
- def fd_candidates_w(z, t, a_coeffs, w_min=1e-14):
477
+ def fd_candidates_w(z, t, coeffs, w_min=1e-14):
478
478
  """
479
479
  Return candidate roots w solving P(z + alpha/w, tau*w)=0 with Im(w)>0 (if Im(z)>0).
480
480
  """
@@ -483,7 +483,7 @@ def fd_candidates_w(z, t, a_coeffs, w_min=1e-14):
483
483
  alpha = 1.0 - 1.0 / tau
484
484
  want_pos_imag = (z.imag > 0.0)
485
485
 
486
- a = numpy.asarray(a_coeffs, dtype=numpy.complex128)
486
+ a = numpy.asarray(coeffs, dtype=numpy.complex128)
487
487
  deg_z = a.shape[0] - 1
488
488
  deg_m = a.shape[1] - 1
489
489
 
@@ -521,7 +521,7 @@ def fd_candidates_w(z, t, a_coeffs, w_min=1e-14):
521
521
  # residual filter (optional but helps)
522
522
  # -------------
523
523
  # TEST
524
- # F = eval_P_partials(z + alpha / w, tau * w, a_coeffs)[0]
524
+ # F = eval_P_partials(z + alpha / w, tau * w, coeffs)[0]
525
525
  # if abs(F) < 1e-6:
526
526
  # cands.append(complex(w))
527
527
  # ---------------
@@ -536,7 +536,7 @@ def fd_candidates_w(z, t, a_coeffs, w_min=1e-14):
536
536
  # decompress newton
537
537
  # =================
538
538
 
539
- def decompress_newton(z_list, t_grid, a_coeffs, w0_list=None,
539
+ def decompress_newton(z_list, t_grid, coeffs, w0_list=None,
540
540
  dt_max=0.1, sweep=True, time_rel_tol=5.0,
541
541
  active_imag_eps=None, sweep_pad=20,
542
542
  max_iter=50, tol=1e-12, armijo=1e-4,
@@ -556,7 +556,7 @@ def decompress_newton(z_list, t_grid, a_coeffs, w0_list=None,
556
556
  Query points z (typically x + 1j*eta with eta > 0), ordered along x.
557
557
  t_grid : array_like of float
558
558
  Strictly increasing time grid.
559
- a_coeffs : ndarray
559
+ coeffs : ndarray
560
560
  Coefficients defining P(z,m) in the monomial basis.
561
561
  w0_list : array_like of complex
562
562
  Initial values w(t0,z) at t_grid[0].
@@ -616,7 +616,7 @@ def decompress_newton(z_list, t_grid, a_coeffs, w0_list=None,
616
616
  # -----------------
617
617
 
618
618
  def _candidates(iz, t):
619
- cands = fd_candidates_w(z_list[iz], t, a_coeffs, w_min=w_min)
619
+ cands = fd_candidates_w(z_list[iz], t, coeffs, w_min=w_min)
620
620
  if len(cands) == 0:
621
621
  # fallback: carry previous value as a candidate
622
622
  return [complex(w_prev[iz])]
@@ -724,7 +724,7 @@ def decompress_newton(z_list, t_grid, a_coeffs, w0_list=None,
724
724
  if refine_newton:
725
725
  for iz in range(nz):
726
726
  w_sol, success = fd_solve_w(
727
- z_list[iz], t, a_coeffs, w_row[iz],
727
+ z_list[iz], t, coeffs, w_row[iz],
728
728
  max_iter=max_iter, tol=tol, armijo=armijo,
729
729
  min_lam=min_lam, w_min=w_min)
730
730
  w_row[iz] = w_sol
@@ -6,7 +6,7 @@
6
6
  #
7
7
  # Public API (used by AlgebraicForm.decompress):
8
8
  # build_time_grid(size, n0, min_n_times=0) -> (t_all, idx_req)
9
- # decompress_newton(z_list, t_grid, a_coeffs, w0_list=None, **opts) -> (W, ok)
9
+ # decompress_newton(z_list, t_grid, coeffs, w0_list=None, **opts) -> (W, ok)
10
10
  #
11
11
  # Core equation (FD):
12
12
  # tau = exp(t) - 1
@@ -102,13 +102,13 @@ def build_time_grid(size, n0, min_n_times=0):
102
102
  # Polynomial utilities
103
103
  # ===================
104
104
 
105
- def _poly_coef_in_w(z, a_coeffs):
105
+ def _poly_coef_in_w(z, coeffs):
106
106
  """
107
107
  For fixed z, return coefficients c[j] so that P(z,w)=sum_j c[j] w^j.
108
- a_coeffs[i,j] corresponds to z^i w^j.
108
+ coeffs[i,j] corresponds to z^i w^j.
109
109
  """
110
110
  z = complex(z)
111
- a = np.asarray(a_coeffs, dtype=np.complex128)
111
+ a = np.asarray(coeffs, dtype=np.complex128)
112
112
  deg_z = int(a.shape[0] - 1)
113
113
  # Horner in z for each j
114
114
  zp = 1.0 + 0.0j
@@ -119,8 +119,8 @@ def _poly_coef_in_w(z, a_coeffs):
119
119
  return c # shape (s+1,)
120
120
 
121
121
 
122
- def _eval_P(z, w, a_coeffs):
123
- c = _poly_coef_in_w(z, a_coeffs)
122
+ def _eval_P(z, w, coeffs):
123
+ c = _poly_coef_in_w(z, coeffs)
124
124
  # Horner in w
125
125
  ww = complex(w)
126
126
  out = 0.0 + 0.0j
@@ -129,11 +129,11 @@ def _eval_P(z, w, a_coeffs):
129
129
  return out
130
130
 
131
131
 
132
- def _eval_dP_dw(z, w, a_coeffs):
132
+ def _eval_dP_dw(z, w, coeffs):
133
133
  """
134
134
  d/dw P(z,w)
135
135
  """
136
- c = _poly_coef_in_w(z, a_coeffs) # c[j] w^j
136
+ c = _poly_coef_in_w(z, coeffs) # c[j] w^j
137
137
  ww = complex(w)
138
138
  # derivative coefficients: j*c[j]
139
139
  out = 0.0 + 0.0j
@@ -142,13 +142,13 @@ def _eval_dP_dw(z, w, a_coeffs):
142
142
  return out
143
143
 
144
144
 
145
- def _eval_dP_dz(z, w, a_coeffs):
145
+ def _eval_dP_dz(z, w, coeffs):
146
146
  """
147
147
  d/dz P(z,w)
148
148
  """
149
149
  z = complex(z)
150
150
  w = complex(w)
151
- a = np.asarray(a_coeffs, dtype=np.complex128)
151
+ a = np.asarray(coeffs, dtype=np.complex128)
152
152
  deg_z = int(a.shape[0] - 1)
153
153
  # compute b[j] = sum_{i>=1} i*a[i,j]*z^{i-1}
154
154
  if deg_z <= 0:
@@ -165,15 +165,15 @@ def _eval_dP_dz(z, w, a_coeffs):
165
165
  return out
166
166
 
167
167
 
168
- def _fd_F_and_dF(w, z, tau, a_coeffs):
168
+ def _fd_F_and_dF(w, z, tau, coeffs):
169
169
  """
170
170
  F(w) = P(z - tau*w, w).
171
171
  dF/dw = dP/dz * (-tau) + dP/dw evaluated at (zeta, w).
172
172
  """
173
173
  zeta = z - tau * w
174
- F = _eval_P(zeta, w, a_coeffs)
175
- dPdw = _eval_dP_dw(zeta, w, a_coeffs)
176
- dPdz = _eval_dP_dz(zeta, w, a_coeffs)
174
+ F = _eval_P(zeta, w, coeffs)
175
+ dPdw = _eval_dP_dw(zeta, w, coeffs)
176
+ dPdz = _eval_dP_dz(zeta, w, coeffs)
177
177
  dF = dPdw - tau * dPdz
178
178
  return F, dF
179
179
 
@@ -185,7 +185,7 @@ def _fd_F_and_dF(w, z, tau, a_coeffs):
185
185
  def _newton_fd_scalar(
186
186
  z,
187
187
  t,
188
- a_coeffs,
188
+ coeffs,
189
189
  w_init,
190
190
  *,
191
191
  max_iter=60,
@@ -212,7 +212,7 @@ def _newton_fd_scalar(
212
212
  w = complex(w.real, w_min)
213
213
 
214
214
  # initial
215
- F, dF = _fd_F_and_dF(w, z, tau, a_coeffs)
215
+ F, dF = _fd_F_and_dF(w, z, tau, coeffs)
216
216
  res0 = abs(F)
217
217
  if not np.isfinite(res0):
218
218
  return complex(np.nan, np.nan), False, 0, np.inf
@@ -239,7 +239,7 @@ def _newton_fd_scalar(
239
239
  w_new = w + lam * step
240
240
  if w_min > 0.0 and w_new.imag < w_min:
241
241
  w_new = complex(w_new.real, w_min)
242
- F_new, dF_new = _fd_F_and_dF(w_new, z, tau, a_coeffs)
242
+ F_new, dF_new = _fd_F_and_dF(w_new, z, tau, coeffs)
243
243
  f1 = abs(F_new)
244
244
  if np.isfinite(f1) and (f1 <= (1.0 - 1e-4 * lam) * f0):
245
245
  w, F, dF = w_new, F_new, dF_new
@@ -252,10 +252,10 @@ def _newton_fd_scalar(
252
252
  w = w + step
253
253
  if w_min > 0.0 and w.imag < w_min:
254
254
  w = complex(w.real, w_min)
255
- F, dF = _fd_F_and_dF(w, z, tau, a_coeffs)
255
+ F, dF = _fd_F_and_dF(w, z, tau, coeffs)
256
256
 
257
257
  # final
258
- F, _ = _fd_F_and_dF(w, z, tau, a_coeffs)
258
+ F, _ = _fd_F_and_dF(w, z, tau, coeffs)
259
259
  ok = np.isfinite(F.real) and np.isfinite(F.imag) and (abs(F) <= 1e3 * tol * (1.0 + res0))
260
260
  return w, bool(ok), max_iter, abs(F)
261
261
 
@@ -294,7 +294,7 @@ def _dedup_cands(cands, tol=1e-10):
294
294
  def _fd_candidates(
295
295
  z,
296
296
  t,
297
- a_coeffs,
297
+ coeffs,
298
298
  seeds,
299
299
  *,
300
300
  max_iter=60,
@@ -313,7 +313,7 @@ def _fd_candidates(
313
313
  ress = []
314
314
  for s in seeds:
315
315
  w, ok, _, res = _newton_fd_scalar(
316
- z, t, a_coeffs, s,
316
+ z, t, coeffs, s,
317
317
  max_iter=max_iter, tol=tol,
318
318
  armijo=armijo, min_lam=min_lam, w_min=w_min
319
319
  )
@@ -525,7 +525,7 @@ def _renormalize_density(z_list, w_path, target_mass=1.0):
525
525
  def decompress_newton(
526
526
  z_list: np.ndarray,
527
527
  t_grid: np.ndarray,
528
- a_coeffs: np.ndarray,
528
+ coeffs: np.ndarray,
529
529
  w0_list: np.ndarray | None = None,
530
530
  *,
531
531
  dt_max: float = 0.05,
@@ -633,7 +633,7 @@ def decompress_newton(
633
633
  seeds.append(complex(-1.0 / (z_list[iz] - tau * w_prev[iz] + 1e-30)))
634
634
 
635
635
  cands, oks, ress = _fd_candidates(
636
- z_list[iz], float(t_sub), a_coeffs, seeds,
636
+ z_list[iz], float(t_sub), coeffs, seeds,
637
637
  max_iter=max_iter, tol=tol,
638
638
  armijo=armijo, min_lam=min_lam, w_min=w_min,
639
639
  keep_best=keep_best,
@@ -6,7 +6,7 @@ FD decompression with correct characteristic map + robust root selection.
6
6
 
7
7
  Keeps public API:
8
8
  - build_time_grid(size, n0, min_n_times=..., include_t0=True) -> (t_all, idx_req)
9
- - decompress_newton(z_list, t_grid, a_coeffs, w0_list=None, **newton_opt) -> (W, ok)
9
+ - decompress_newton(z_list, t_grid, coeffs, w0_list=None, **newton_opt) -> (W, ok)
10
10
 
11
11
  IMPORTANT: This implements the characteristic transform consistent with:
12
12
  τ(t)=e^t, α(t)=1-τ^{-1},
@@ -83,13 +83,13 @@ def build_time_grid(size, n0, min_n_times=0, include_t0=True):
83
83
  # Polynomial curve utilities
84
84
  # ===========================
85
85
 
86
- def _poly_w_coeffs(z: complex, t: float, a_coeffs: np.ndarray) -> np.ndarray:
86
+ def _poly_w_coeffs(z: complex, t: float, coeffs: np.ndarray) -> np.ndarray:
87
87
  """
88
88
  Build Q(w) coeffs (descending) for:
89
89
  Q(w) = w^{deg_z} * P(z + α/w, τ w)
90
90
  where τ=e^t, α=1-1/τ.
91
91
  """
92
- a = np.asarray(a_coeffs, dtype=np.complex128)
92
+ a = np.asarray(coeffs, dtype=np.complex128)
93
93
  deg_z = a.shape[0] - 1
94
94
  deg_m = a.shape[1] - 1
95
95
 
@@ -169,8 +169,8 @@ def _newton_poly_root(coeff_desc: np.ndarray, w0: complex, max_iter: int, tol: f
169
169
  return w, bool(np.isfinite(f) and abs(f) <= float(tol) * (1.0 + abs(w)))
170
170
 
171
171
 
172
- def _roots_of_Q(z: complex, t: float, a_coeffs: np.ndarray):
173
- coeff_desc = _poly_w_coeffs(z, t, a_coeffs)
172
+ def _roots_of_Q(z: complex, t: float, coeffs: np.ndarray):
173
+ coeff_desc = _poly_w_coeffs(z, t, coeffs)
174
174
  if coeff_desc.size <= 1:
175
175
  return coeff_desc, np.empty((0,), np.complex128)
176
176
  r = np.roots(coeff_desc)
@@ -178,7 +178,7 @@ def _roots_of_Q(z: complex, t: float, a_coeffs: np.ndarray):
178
178
  return coeff_desc, r.astype(np.complex128, copy=False)
179
179
 
180
180
 
181
- def _physical_anchor_for_x(x: float, t: float, a_coeffs: np.ndarray,
181
+ def _physical_anchor_for_x(x: float, t: float, coeffs: np.ndarray,
182
182
  eta_hi: float, eta_lo: float, n_eta: int,
183
183
  herglotz_tol: float,
184
184
  max_iter: int, tol: float,
@@ -186,7 +186,7 @@ def _physical_anchor_for_x(x: float, t: float, a_coeffs: np.ndarray,
186
186
  etas = np.linspace(float(eta_hi), float(eta_lo), int(n_eta))
187
187
  z0 = complex(x, etas[0])
188
188
 
189
- coeff0, roots0 = _roots_of_Q(z0, t, a_coeffs)
189
+ coeff0, roots0 = _roots_of_Q(z0, t, coeffs)
190
190
  if roots0.size == 0:
191
191
  return -1.0 / z0, False
192
192
 
@@ -203,10 +203,10 @@ def _physical_anchor_for_x(x: float, t: float, a_coeffs: np.ndarray,
203
203
 
204
204
  for eta in etas[1:]:
205
205
  z = complex(x, eta)
206
- coeff, _ = _roots_of_Q(z, t, a_coeffs)
206
+ coeff, _ = _roots_of_Q(z, t, coeffs)
207
207
  w, ok2 = _newton_poly_root(coeff, w, max_iter=max_iter, tol=tol, armijo=armijo, min_lam=min_lam)
208
208
  if not ok2:
209
- _coeff, roots = _roots_of_Q(z, t, a_coeffs)
209
+ _coeff, roots = _roots_of_Q(z, t, coeffs)
210
210
  if roots.size == 0:
211
211
  return w, False
212
212
  roots = np.asarray(roots, dtype=np.complex128)
@@ -328,7 +328,7 @@ def _viterbi_path(cand_list, z_list, w_prev,
328
328
  def decompress_newton(
329
329
  z_list,
330
330
  t_grid,
331
- a_coeffs,
331
+ coeffs,
332
332
  w0_list=None,
333
333
  *,
334
334
  dt_max=0.05,
@@ -375,7 +375,7 @@ def decompress_newton(
375
375
  from ._edge import evolve_edges, merge_edges
376
376
  if edge_support is None:
377
377
  raise ValueError("edge_support must be provided when edge_use=True")
378
- complex_edges = evolve_edges(t_grid, a_coeffs, support=edge_support)
378
+ complex_edges = evolve_edges(t_grid, coeffs, support=edge_support)
379
379
  # merge_edges in your package expects edges array (nt, 2k) and returns (real_merged_edges, active_k)
380
380
  real_edges, _active_k = merge_edges(complex_edges, t_grid)
381
381
  except Exception:
@@ -414,7 +414,7 @@ def decompress_newton(
414
414
  anchor_ok = np.ones((nz,), dtype=bool)
415
415
  for iz in range(nz):
416
416
  w_a, ok_a = _physical_anchor_for_x(
417
- float(x[iz]), float(t_sub), a_coeffs,
417
+ float(x[iz]), float(t_sub), coeffs,
418
418
  eta_hi=float(eta_hi), eta_lo=float(eta_lo),
419
419
  n_eta=int(n_eta),
420
420
  herglotz_tol=float(herglotz_tol),
@@ -427,7 +427,7 @@ def decompress_newton(
427
427
  cand_list = []
428
428
  for iz in range(nz):
429
429
  z = z_list[iz]
430
- coeff, roots = _roots_of_Q(z, float(t_sub), a_coeffs)
430
+ coeff, roots = _roots_of_Q(z, float(t_sub), coeffs)
431
431
 
432
432
  anc = anchors[iz]
433
433
  im_floor = None
@@ -32,21 +32,21 @@ __all__ = ['decompress_newton']
32
32
  # scalar poly evaluation
33
33
  # =====================
34
34
 
35
- def _eval_a_and_da(z: complex, a_coeffs: numpy.ndarray) -> tuple[numpy.ndarray, numpy.ndarray]:
35
+ def _eval_a_and_da(z: complex, coeffs: numpy.ndarray) -> tuple[numpy.ndarray, numpy.ndarray]:
36
36
  """Evaluate a_j(z) and a'_j(z) for j=0..s where P(z,y)=sum_j a_j(z) y^j.
37
37
 
38
- a_coeffs has shape (deg_z+1, s+1) storing coefficients in z ascending:
39
- a_coeffs[i,j] = coeff of z^i in a_j(z).
38
+ coeffs has shape (deg_z+1, s+1) storing coefficients in z ascending:
39
+ coeffs[i,j] = coeff of z^i in a_j(z).
40
40
  """
41
- deg_z = a_coeffs.shape[0] - 1
42
- s = a_coeffs.shape[1] - 1
41
+ deg_z = coeffs.shape[0] - 1
42
+ s = coeffs.shape[1] - 1
43
43
 
44
44
  a = numpy.empty(s + 1, dtype=numpy.complex128)
45
45
  da = numpy.empty(s + 1, dtype=numpy.complex128)
46
46
 
47
47
  # Horner for each column j
48
48
  for j in range(s + 1):
49
- col = a_coeffs[:, j]
49
+ col = coeffs[:, j]
50
50
  # a_j(z)
51
51
  v = complex(col[deg_z])
52
52
  for i in range(deg_z - 1, -1, -1):
@@ -65,10 +65,10 @@ def _eval_a_and_da(z: complex, a_coeffs: numpy.ndarray) -> tuple[numpy.ndarray,
65
65
  return a, da
66
66
 
67
67
 
68
- def _eval_P_Pz_Py(z: complex, y: complex, a_coeffs: numpy.ndarray) -> tuple[complex, complex, complex]:
68
+ def _eval_P_Pz_Py(z: complex, y: complex, coeffs: numpy.ndarray) -> tuple[complex, complex, complex]:
69
69
  """Return P(z,y), Pz(z,y)=\partial_z P, Py(z,y)=\partial_y P (scalars)."""
70
- a, da = _eval_a_and_da(z, a_coeffs)
71
- s = a_coeffs.shape[1] - 1
70
+ a, da = _eval_a_and_da(z, coeffs)
71
+ s = coeffs.shape[1] - 1
72
72
 
73
73
  # Build powers of y incrementally (cheap; s is small)
74
74
  ypow = 1.0 + 0.0j
@@ -100,7 +100,7 @@ def _newton_2x2(
100
100
  tau: float,
101
101
  zeta0: complex,
102
102
  y0: complex,
103
- a_coeffs: numpy.ndarray,
103
+ coeffs: numpy.ndarray,
104
104
  *,
105
105
  max_iter: int,
106
106
  tol: float,
@@ -120,7 +120,7 @@ def _newton_2x2(
120
120
  y = (w_min + 0.0j)
121
121
 
122
122
  for it in range(max_iter):
123
- P, Pz, Py = _eval_P_Pz_Py(zeta, y, a_coeffs)
123
+ P, Pz, Py = _eval_P_Pz_Py(zeta, y, coeffs)
124
124
  F1 = P
125
125
  F2 = z - zeta + tau_m1 / y
126
126
 
@@ -198,7 +198,7 @@ def _newton_2x2(
198
198
  def decompress_newton(
199
199
  z_query,
200
200
  t_all,
201
- a_coeffs,
201
+ coeffs,
202
202
  *,
203
203
  w0_list=None,
204
204
  max_iter: int = 40,
@@ -298,7 +298,7 @@ def decompress_newton(
298
298
  zeta0 = zeta_seed[j]
299
299
 
300
300
  zeta, y, okj, nit = _newton_2x2(
301
- z, tau, zeta0, y0, a_coeffs,
301
+ z, tau, zeta0, y0, coeffs,
302
302
  max_iter=max_iter, tol=tol,
303
303
  damping=damping, step_clip=step_clip,
304
304
  w_min=w_min, require_imw_pos=require_imw_pos,
@@ -311,7 +311,7 @@ def decompress_newton(
311
311
  for k in range(1, int(max_split) + 1):
312
312
  tau_mid = tau_prev + (tau - tau_prev) * (k / float(max_split))
313
313
  zeta_mid, y_mid, ok_mid, _ = _newton_2x2(
314
- z, tau_mid, zeta0, y0, a_coeffs,
314
+ z, tau_mid, zeta0, y0, coeffs,
315
315
  max_iter=max_iter, tol=tol,
316
316
  damping=damping, step_clip=step_clip,
317
317
  w_min=w_min, require_imw_pos=require_imw_pos,
@@ -322,7 +322,7 @@ def decompress_newton(
322
322
  zeta0b = zeta_mid
323
323
  y0b = y_mid
324
324
  zeta, y, okj, nit = _newton_2x2(
325
- z, tau, zeta0b, y0b, a_coeffs,
325
+ z, tau, zeta0b, y0b, coeffs,
326
326
  max_iter=max_iter, tol=tol,
327
327
  damping=damping, step_clip=step_clip,
328
328
  w_min=w_min, require_imw_pos=require_imw_pos,