Hacker News new | ask | show | jobs
by compumike 2852 days ago
I like how you moved to Complex16Array for reduced memory overhead and improving CPU cache performance. I'd probably take a close look at your get method's "return new Complex16(...)" call and see if those object instantiations are consuming a lot of CPU time and memory churn on their own.

We use quite a bit of complex numbers in Javascript under the hood within CircuitLab for doing frequency-domain circuit analysis of electronic circuits like filters and amplifiers. In that mode, a circuit simulator is essentially solving a system of complex-valued equations using a sparse matrix solver that accepts complex numbers, so the complex arithmetic routines are some of the potential performance hot spots. You'd want to unroll a lot of the intermediate manipulation without creating a lot of new objects in the middle! I've written a short complex numbers tutorial here: https://www.circuitlab.com/textbook/complex-numbers/

1 comments

Yes, I decided to add the instantiations for readability. It would be more efficient in a production setting to do the operations directly on the raw data.

Thank you for the link!