Open lukebhan opened 4 years ago
This is much more of a rust-specific question, but let's say I have Bignums a, b, and c, and I want to perform some additions like x = a + b, y = b + c, and z = a + c.
How can I make this actually work? Should I call copy even though it's not yet implemented for bignum, call clone, inline new objects?
use clone for now. We need to implement copy for bignum in the future, but you have to make sure to deep copy the vectors in rust. It probably will make us slower.
I think we need to implement versions of things like add or sub that can just borrow the Bignums right @luke-bhan? So that when x = a + b is called it doesn't require a or b to be moved, just their values to be borrowed.
I wish.. but I found this a long time ago https://stackoverflow.com/questions/40301864/overloading-the-add-operator-without-copying-the-operands
Does this not work?
brilliant. YES
So I got around multiplying by two (because I can't multiply Bignums in the definition of Bignum multiplication) by adding twice. Any way to make this work for dividing by two? Maybe it's time to convert to binary so I can bit shift lol
you should be able to multiply and subtract as you please with bignums. Take a look at the modulo function, I am multiplying an subtracting there.
what do you by multiplying bignums in the defintion. If its an operator overload you can, if its the new function I don't think you can.
I'm just working on the alternate implementation of multiplication and so obviously multiplying within that definition is going to lead to some serious looping issues.
Also for now, I think I'm just going to implement a divide by two method and see if this works as a PoC
Ok hard coded in division by two, now need to think about how to solve multiplication of smaller Bignums within my multiplication of Bignums method :)
We should dynamically call a multiplication based on the number of digits in Bignum, for testing purposes we can also call each of them on their own whenever, but I need to use standard carry-based multiplication as a subroutine or else infinite loops galore @luke-bhan
thats certainly fine.Obviously the fft division is super buggy. Feel free to just make that a function in the file for now and then you can use just a standard multiplication algo in its place.
200*.5 won't return 100. it gets flipped to 0.1