checking if a dividend / divisor pair entering a division is the same as last time division was activated
The reason for that is to enable existing code to work without changes... in my experience code like this is quite common:
d:= (x div y);
m:= (x mod y);
And I wanted that code run as fast as possible and not have to be rewritten by the user. The overhead will be small.
I ran some tests comparing your code to mine. Add, subtract & multiply all take approximately the same time (my code is about 25% slower but I'm happy with that).
I did some tests of dynamic arrays vs new/free of pointer to array. It looks to me like dynamic arrays are faster, and they get more faster as the size of the array increases (if that makes sense). The main reason for this is that new of pointer to array requires the memory to be initialised, whereas a dynamic array has its memory zero'd automagically. (There might be a trick to fix this that I'm not aware of). So I don't think my dynamic arrays are a problem.
As you point out, my division routine is my biggest bottleneck. Can you explain in a nutshell why your division runs so much quicker, please?
I looked at your code, and the only thing I could see is a reference to doing each calculation loop on 2 or 3 limbs/words instead just one (as I am doing). Is that the essence of what you are doing?
I am considering attempting to steal your code and translate it line-by-line to work with my data structures. But am a bit uneasy about this because of the difficulties I had translating the standard Knuth algorithm from C. Also, would you object if I did this?
Thanks.