GalSim-developers / GalSim

The modular galaxy image simulation toolkit. Documentation:
http://galsim-developers.github.io/GalSim/
Other
227 stars 107 forks source link

Use single-precision for Silicon internal storage #1140

Closed rmjarvis closed 2 years ago

rmjarvis commented 2 years ago

This PR changes the internal storage of the pixel boundaries from double to single precision. I made sure everything still uses double precision for all calculations, so there isn't too much loss of precision in the various places.

This is most important when the sides may add 1 to their positions depending on which side of the square they are on. If these are done in single precision, there is more loss of precision. Probably still acceptable, TBH, but it seems prudent to do as much as possible in double precision nonetheless.

Anyway, only one test ended up needing to be relaxed in its precision, and I dug into it and convinced myself that it is unavoidable. Basically, it's when we first apply the tree rings to all the boundaries, then go back and calculate areas. This necessarily passes through float storage, so it only ends up accurate at rtol=2e-8. That seems completely fine to me.

jamesp-epcc commented 2 years ago

This looks good to me. Ensuring that all the intermediate calculations are still done in double is a definite improvement on my version.

rmjarvis commented 2 years ago

Thanks James!