So I have a data set of coefficients which are calculated from a Laplace expansion into spherical harmonics. The resulting coefficients can be either real or complex. When I'm working though the data, there are times all (or a lot) the imaginary components have values << eps i.e the numerical accuracy (so in one dataset of 100,000 or so coefficents, the max imaginary component is 2e-17 compared to a max coefficient of 120).
For the purposes of my work, the presence of the imaginary numbers is bad for both clarity and computational time.
For a variable A;
I can use the code
to zero the effectively zero real components however the logical '<' ignores imaginary numbers. I did a lot of searching and can't seem to find a method to do the same with the imaginary component.
I believe it maybe possible to break up the matrix using real and imag, set the zeros and then reassign the initial matrix with the new imaginary components, howver I'm unsure of a consise way to do this and I would imagine the 4 lines of code I can write would become cumbersome when I'm working with lots of data and loops etc
Any ideas or suggestions would be much appreicated