Skip to content

Commit 477c79f

Browse files
author
André Gaul
committed
NonnormalAuto: avoid duplicate points due to round-off errors
1 parent 8901d3a commit 477c79f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pseudopy/nonnormal.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,17 +303,21 @@ def sort(lambd):
303303
# construct points for evaluation of resolvent
304304
points = []
305305
arg = numpy.linspace(0, 2*numpy.pi, n_points, endpoint=False)
306-
307306
for midpoint, radius_max in zip(midpoints, radii):
308307
radius_log = numpy.logspace(numpy.log10(eps_min),
309308
numpy.log10(radius_max),
310309
n_circles
311310
)
311+
312312
#radius_lin = numpy.linspace(eps_min, radius_max, n_circles)
313313
for radius in radius_log:
314314
rand = 0.
315315
if randomize:
316316
rand = numpy.random.rand()
317-
points.append(midpoint + radius*numpy.exp(1j*(rand+arg)))
317+
318+
# check that radius is larger than round-off in order to
319+
# avoid duplicate points
320+
if numpy.abs(radius)/numpy.abs(midpoint) > 1e-15:
321+
points.append(midpoint + radius*numpy.exp(1j*(rand+arg)))
318322
points = numpy.concatenate(points)
319323
super(NonnormalAuto, self).__init__(A, points, **kwargs)

0 commit comments

Comments
 (0)