Karatsuba algorithm

Started by
11 comments, last by iMalc 9 years, 11 months ago

Yeah I really should change mine to just use a vector internally. I had been trying to be clever and save space.

Modulo wrap around is very easy for fixed-sized values. It just means you only keep the n lowest bits of the result.

But certainly for a variable-sized bigint, unsigned doesn't really make sense.

Your code seems to be very high level and well commented. Mine is more designed for high performance and less need to understand how it works hence less commenting.

In fact your code reminds me of this: http://ericlippert.com/2013/09/16/math-from-scratch-part-one/

"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms
Advertisement

Mine is more designed for high performance and less need to understand how it works hence less commenting.

I think for the most part, mine should still have good performance. At this point, I put a lot of trust in the compiler to optimize things, like the intermediate variables, lambdas, and the algorithm based loops. They do make debugging a little easier. Plus there have been several iterations of this code, I figure the more I document it, they more likely I'll remember what the heck I was thinking at the time, and be less inclined to start over :).

"I can't believe I'm defending logic to a turing machine." - Kent Woolworth [Other Space]

I hope that optimism pays off for ya.

"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms

This topic is closed to new replies.

Advertisement