![]() } Now the code is doing three multiplies per iteration, which is the minimum. It squares z.r and z.i twice each, and it multiplies by two. The code does six multiplications and at high-precisions those are very expensive. That’s correct but it’s not very efficient. With that in mind a more detailed version would be: I’m not going to review complex math, but I will point out that abs(complex) is equal to the square root of (real * real + imaginary * imaginary) and if you square both sides you can avoid the square root. Since z and c are complex numbers we have to store each one as two components and expand out operations like multiplication to multiple operations on those components. Practical considerations necessitate adding a limit to how many times the loop runs before giving up the search, but I’m going to ignore that for the sake of elegance and simplicity. ![]() If the loop never exits then the point is in the Mandelbrot set. The Mandelbrot set is calculated by setting the complex number ‘c’ to the location of the point you want to calculate and then executing the following loop: This article discusses a simple algebraic improvement that gives up to a 33% speedup, and a follow-up article discusses a thread-scheduling improvement. I’ve been working on Fractal eXtreme on-and-off for years, and an important (and fun) part of working on it is optimizing the calculation of the Mandelbrot set, especially the high-precision math routines that allow deep-zooming.Īfter working on this over the course of a decade I assumed that all the easiest optimizations were done, but recently I found a couple of trivial optimizations that I had missed.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |