Code sprint for the win

The only part that was remaining for the is_strong_lucas_pseudoprime function was either a massive block of indecpheriable code composed of unprounceable variables and seemingly random function calls and for loops in the reference code (a fun little C program that has everything and the kitchen sink) or a sentence in the reference PDF.  Ugh.

Turns out translating the code from C isn’t so bad when the binding module (Math::GMPz) just prefixes every C function with the capital letter ‘R’.  Most of my time was spent making sure I have my variables correctly (a lot of $V, $V_m, $V_2m, and so on) and making sure I understand the code.  So, 80+ lines of code and inline comments later, we have a function that at least doesn’t cause the perl compiler to barf.  The next step is obviously to write some test code to make sure this is all legit, but that’ll wait till tomorrow.

Oh, and there were a few typos in the psuedocode, so those are fixed in later commits.

So todays rant / realization is that trying to implement an algorithim without understanding the nuts and bolts is a really stupid way to go about living.  Spend the extra time knowing what every line of code does, be able to compile and run it in your head (at least conceptually) because if you don’t that is a guaranteed way to create bugs.  And when you go bug hunting, you’ll be so unfamiliar with the terrain that it’ll take you ten times as long just to debug it.

Posted in Google Summer of Code | Comments Off on Code sprint for the win

Comments are closed.