I'm trying to optimize this code - Code Link. Any tips on how to do so would be really appreciated.
Hi, I'm trying to reduce the time taken to execute the codeWhat are you trying to achieve by "optimizing" the code?
The examples given appear to be quite concise. They are all compiled and will generate very similar machine code. The speed at which they run will be mostly affected by the type and clock speed of the processor they are compiled to.Hi, I'm trying to reduce the time taken to execute the code
Thanks..so how would the code look like in that case?I think, for this particular type of problem, a lot of it comes down to how well the compiler can leverage things like the SIMD instructions of the processor. I don't know how well modern C compilers are at doing that. My understanding is that Python and Java both have modules/libraries available that are pretty good at it. A language like MATLAB is specifically designed to leverage these capabilities and the matrix nature of the notation is designed to make doing so much easier.
In addition, this is a problem that would lend itself extremely well to parallelization on different cores (or using a high-end graphics card), so once again it comes down to whether the compiler is able to effectively decompose the problem along those lines and how the code should be written to enable the compiler to do so.
That's going to depend on the language and, possibly most importantly, the specific compiler you are using. If you really want to squeeze performance out of your code, you have to get extremely familiar with the intimate details of your tools and learn what they can do and how you need to write your code to enable them to do it.Thanks..so how would the code look like in that case?
by Jake Hertz
by Jake Hertz
by Jake Hertz