In numpy I have an array like
[0 + 0.5j, 0.25 + 1.2352444e-24j, 0.25+ 0j, 2.46519033e-32 + 0j]
what is the fastest and easiest way to set the super low value to zero to get
[0 + 0.5j, 0.25 + 0j, 0.25+ 0j, 0 + 0j]
efficiency is not the paramount.
Hmmm. I’m not super-happy with it, but this seems to work:
and you can choose your tolerance as your problem requires. I usually use an order of magnitude or so higher than
but it’s problem-dependent.