freealg 0.1.5__py3-none-any.whl → 0.1.6__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.
- freealg/__version__.py +1 -1
- freealg/_decompress.py +45 -1
- freealg/_plot_util.py +37 -1
- freealg/freeform.py +9 -2
- {freealg-0.1.5.dist-info → freealg-0.1.6.dist-info}/METADATA +1 -1
- {freealg-0.1.5.dist-info → freealg-0.1.6.dist-info}/RECORD +9 -9
- {freealg-0.1.5.dist-info → freealg-0.1.6.dist-info}/WHEEL +0 -0
- {freealg-0.1.5.dist-info → freealg-0.1.6.dist-info}/licenses/LICENSE.txt +0 -0
- {freealg-0.1.5.dist-info → freealg-0.1.6.dist-info}/top_level.txt +0 -0
freealg/__version__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.1.
|
|
1
|
+
__version__ = "0.1.6"
|
freealg/_decompress.py
CHANGED
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
# =======
|
|
12
12
|
|
|
13
13
|
import numpy
|
|
14
|
+
# from scipy.integrate import solve_ivp
|
|
14
15
|
|
|
15
|
-
__all__ = ['decompress']
|
|
16
|
+
__all__ = ['decompress', 'reverse_characteristics']
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
# ==========
|
|
@@ -134,3 +135,46 @@ def decompress(matrix, size, x=None, delta=1e-4, iterations=500, step_size=0.1,
|
|
|
134
135
|
rho = rho.reshape(*x.shape)
|
|
135
136
|
|
|
136
137
|
return rho, x, (lb, ub)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
# =======================
|
|
141
|
+
# reverse characteristics
|
|
142
|
+
# =======================
|
|
143
|
+
|
|
144
|
+
def reverse_characteristics(matrix, z_inits, T, iterations=500, step_size=0.1,
|
|
145
|
+
tolerance=1e-8):
|
|
146
|
+
"""
|
|
147
|
+
"""
|
|
148
|
+
|
|
149
|
+
t_span = (0, T)
|
|
150
|
+
t_eval = numpy.linspace(t_span[0], t_span[1], 50)
|
|
151
|
+
|
|
152
|
+
m = matrix._eval_stieltjes
|
|
153
|
+
|
|
154
|
+
def _char_z(z, t):
|
|
155
|
+
return z + (1 / m(z)[1]) * (1 - numpy.exp(t))
|
|
156
|
+
|
|
157
|
+
target_z, target_t = numpy.meshgrid(z_inits, t_eval)
|
|
158
|
+
|
|
159
|
+
z = numpy.full(target_z.shape, numpy.mean(matrix.support) - .1j,
|
|
160
|
+
dtype=numpy.complex128)
|
|
161
|
+
|
|
162
|
+
# Broken Newton steps can produce a lot of warnings. Removing them for now.
|
|
163
|
+
with numpy.errstate(all='ignore'):
|
|
164
|
+
for _ in range(iterations):
|
|
165
|
+
objective = _char_z(z, target_t) - target_z
|
|
166
|
+
mask = numpy.abs(objective) >= tolerance
|
|
167
|
+
if not numpy.any(mask):
|
|
168
|
+
break
|
|
169
|
+
z_m = z[mask]
|
|
170
|
+
t_m = target_t[mask]
|
|
171
|
+
|
|
172
|
+
# Perform finite difference approximation
|
|
173
|
+
dfdz = _char_z(z_m+tolerance, t_m) - _char_z(z_m-tolerance, t_m)
|
|
174
|
+
dfdz /= 2*tolerance
|
|
175
|
+
dfdz[dfdz == 0] = 1.0
|
|
176
|
+
|
|
177
|
+
# Perform Newton step
|
|
178
|
+
z[mask] = z_m - step_size * objective[mask] / dfdz
|
|
179
|
+
|
|
180
|
+
return z
|
freealg/_plot_util.py
CHANGED
|
@@ -18,6 +18,7 @@ import matplotlib
|
|
|
18
18
|
import colorsys
|
|
19
19
|
import matplotlib.ticker as ticker
|
|
20
20
|
import matplotlib.gridspec as gridspec
|
|
21
|
+
from ._decompress import reverse_characteristics
|
|
21
22
|
|
|
22
23
|
__all__ = ['plot_fit', 'plot_density', 'plot_hilbert', 'plot_stieltjes',
|
|
23
24
|
'plot_stieltjes_on_disk']
|
|
@@ -243,11 +244,42 @@ def _value_formatter(v, pos):
|
|
|
243
244
|
return f"{m_val:.1f}"
|
|
244
245
|
|
|
245
246
|
|
|
247
|
+
# ================
|
|
248
|
+
# plot char curves
|
|
249
|
+
# ================
|
|
250
|
+
def _plot_char_curves(ax, char_curves):
|
|
251
|
+
"""
|
|
252
|
+
"""
|
|
253
|
+
|
|
254
|
+
curves = reverse_characteristics(char_curves['matrix'],
|
|
255
|
+
char_curves['z'], 4)
|
|
256
|
+
lw = 2
|
|
257
|
+
for idx in range(curves.shape[1]):
|
|
258
|
+
|
|
259
|
+
creal, cimag = curves[:, idx].real, curves[:, idx].imag
|
|
260
|
+
|
|
261
|
+
ax.plot(creal, cimag, ':', color='white', linewidth=lw,
|
|
262
|
+
alpha=0.75)
|
|
263
|
+
|
|
264
|
+
ax.annotate(
|
|
265
|
+
'', # no text
|
|
266
|
+
xy=(creal[-1], cimag[-1]), # arrow tip at final point
|
|
267
|
+
xytext=(creal[-2], cimag[-2]), # tail at penultimate point
|
|
268
|
+
arrowprops=dict(
|
|
269
|
+
arrowstyle='-|>', # simple arrow head
|
|
270
|
+
mutation_scale=5, # size of the head
|
|
271
|
+
color='white',
|
|
272
|
+
lw=lw, alpha=0.75, # arrow shaft line width
|
|
273
|
+
)
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
|
|
246
277
|
# ==============
|
|
247
278
|
# plot stieltjes
|
|
248
279
|
# ==============
|
|
249
280
|
|
|
250
|
-
def plot_stieltjes(x, y, m1, m2, support, latex=False,
|
|
281
|
+
def plot_stieltjes(x, y, m1, m2, support, latex=False, char_curves=None,
|
|
282
|
+
save=False):
|
|
251
283
|
"""
|
|
252
284
|
"""
|
|
253
285
|
|
|
@@ -297,6 +329,10 @@ def plot_stieltjes(x, y, m1, m2, support, latex=False, save=False):
|
|
|
297
329
|
ax1.set_xlim([x_min, x_max])
|
|
298
330
|
ax1.set_ylim([y_min, y_max])
|
|
299
331
|
|
|
332
|
+
# Plot characteristic curves
|
|
333
|
+
if char_curves is not None:
|
|
334
|
+
_plot_char_curves(ax1, char_curves)
|
|
335
|
+
|
|
300
336
|
pos = ax1.get_position()
|
|
301
337
|
cbar_width = 0.013
|
|
302
338
|
pad = 0.013
|
freealg/freeform.py
CHANGED
|
@@ -631,7 +631,8 @@ class FreeForm(object):
|
|
|
631
631
|
# stieltjes
|
|
632
632
|
# =========
|
|
633
633
|
|
|
634
|
-
def stieltjes(self, x, y, plot=False, latex=False,
|
|
634
|
+
def stieltjes(self, x, y, plot=False, latex=False, char_curves=None,
|
|
635
|
+
save=False):
|
|
635
636
|
"""
|
|
636
637
|
Compute Stieltjes transform of the spectral density over a 2D Cartesian
|
|
637
638
|
grid on the complex plane.
|
|
@@ -655,6 +656,10 @@ class FreeForm(object):
|
|
|
655
656
|
If `True`, the plot is rendered using LaTeX. This option is
|
|
656
657
|
relevant only if ``plot=True``.
|
|
657
658
|
|
|
659
|
+
char_curves : numpy.array, default=None
|
|
660
|
+
If ``plot=True``, also plot characteristic curves starting from
|
|
661
|
+
these locations.
|
|
662
|
+
|
|
658
663
|
save : bool, default=False
|
|
659
664
|
If not `False`, the plot is saved. If a string is given, it is
|
|
660
665
|
assumed to the save filename (with the file extension). This option
|
|
@@ -742,7 +747,9 @@ class FreeForm(object):
|
|
|
742
747
|
m2[mask_m, :] = -m1[mask_m, :] + self._glue(z[mask_m, :])
|
|
743
748
|
|
|
744
749
|
if plot:
|
|
745
|
-
plot_stieltjes(x, y, m1, m2, self.support, latex=latex,
|
|
750
|
+
plot_stieltjes(x, y, m1, m2, self.support, latex=latex,
|
|
751
|
+
char_curves={'matrix': self, 'z': char_curves},
|
|
752
|
+
save=save)
|
|
746
753
|
|
|
747
754
|
return m1, m2
|
|
748
755
|
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
freealg/__init__.py,sha256=K92neXJZ9VE1U_j_pj28Qyq1MzlMXhOuYK2ZihgwCaU,463
|
|
2
|
-
freealg/__version__.py,sha256=
|
|
2
|
+
freealg/__version__.py,sha256=n3oM6B_EMz93NsTI18NNZd-jKFcUPzUkbIKj5VFK5ok,22
|
|
3
3
|
freealg/_chebyshev.py,sha256=X6u5pKjR1HPZ-KbCfr7zT6HRwB6pZMADvVS3sT5LTkA,5638
|
|
4
4
|
freealg/_damp.py,sha256=k2vtBtWOxQBf4qXaWu_En81lQBXbEO4QbxxWpvuVhdE,1802
|
|
5
|
-
freealg/_decompress.py,sha256=
|
|
5
|
+
freealg/_decompress.py,sha256=7U2lL8F5z76aFuZJBsPj70jEVRuzvJHnIh5FSw-aLME,4680
|
|
6
6
|
freealg/_jacobi.py,sha256=AT4ONSHGGDxVKE3MGMLyMR8uDFiO-e9u3x5udYfdJJk,5635
|
|
7
7
|
freealg/_pade.py,sha256=mP96wEPfIzHLZ6PDB5OyhmSA8N1uVPVUkmJa3ebXXiU,13623
|
|
8
|
-
freealg/_plot_util.py,sha256=
|
|
8
|
+
freealg/_plot_util.py,sha256=Ng9c_U9kxsRb16GsvVa2u4AiXUKw0oD4E3BB_e9d9h8,19575
|
|
9
9
|
freealg/_sample.py,sha256=K1ZxKoiuPbEKyh-swL5X7gz1kYcQno6Mof0o1xF38tg,2323
|
|
10
10
|
freealg/_util.py,sha256=alJ9s1U_sHL7dXq7hI10fa8CF_AZ6Xmy_QsoyDYPSDQ,3677
|
|
11
|
-
freealg/freeform.py,sha256=
|
|
11
|
+
freealg/freeform.py,sha256=pZM4IUVegXjKCi9484Gz4bPkYt0tRvslTrha_yKW7y4,29042
|
|
12
12
|
freealg/distributions/__init__.py,sha256=Hnk9bJi4Wy8I_1uuskRyrT2DUpPN1YmBY5uK7XI3U_o,644
|
|
13
13
|
freealg/distributions/kesten_mckay.py,sha256=Oq2FCX60seojy7LDn8nYPrbqinmXv4YC-93VxlmDQ6M,15913
|
|
14
14
|
freealg/distributions/marchenko_pastur.py,sha256=GwDTN-7au2h7H7PnZkQfs6bas8fNhgEnQ-hTWsBMZuE,16403
|
|
15
15
|
freealg/distributions/wachter.py,sha256=2eqbJY4S1MqLjgqO6qY06m3-_s-bKTuSiryS_ZH_xvI,16136
|
|
16
16
|
freealg/distributions/wigner.py,sha256=MSrB-HLMzOwnWDDzw5XPLsoL4LEIV35w5jWeL-qDn9Y,15448
|
|
17
|
-
freealg-0.1.
|
|
18
|
-
freealg-0.1.
|
|
19
|
-
freealg-0.1.
|
|
20
|
-
freealg-0.1.
|
|
21
|
-
freealg-0.1.
|
|
17
|
+
freealg-0.1.6.dist-info/licenses/LICENSE.txt,sha256=J-EEYEtxb3VVf_Bn1TYfWnpY5lMFIM15iLDDcnaDTPA,1443
|
|
18
|
+
freealg-0.1.6.dist-info/METADATA,sha256=eIE88q1eRccGUJdZmKYfjoP6p-XTP4y7tBkKrCb3jfU,2939
|
|
19
|
+
freealg-0.1.6.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
|
20
|
+
freealg-0.1.6.dist-info/top_level.txt,sha256=eR2wrgYwDdnnJ9Zf5PruPqe4kQav0GMvRsqct6y00Q8,8
|
|
21
|
+
freealg-0.1.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|