-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doing multiplication into the result directly. #17
Comments
Hey @aameen951 - sorry for the slow response. Thank you for the tip, and no worries about not leaving a PR - a tip like this with code and all, is valuable to me :) However, "straight from the hip" I am not completely sure what it would translate to, in my library - I would have to take some time to understand each step in your example code, and translate it. Unfortunately, it is a task that will have to wait a bit - but maybe in my summer's vacation :) Anyways - thanks for the contribution Ameen. I will leave this issue open and mark it as TODO/help wanted, in case anyone can easily grasp your idea, and make a PR, before I get to it. |
Hi @kokke, Your library is very useful and clear, I add one ⭐ . However, I use calculations which require millions of calls to the bignum_* functions Do you have any ideas like the one proposed by @aameen951 to optimize the "big" loops in your library ? Here are my stats for one execution of my program :
Greetings, JL. |
Hi @JL2014 and thanks for your kind words :) This library is using very simplistic algorithms and not much optimization at all. Multiplication and division is usually quite slow, so that's where I would start looking. For better performance, you could consider using GMP https://gmplib.org/ -- very clear code as well, but also very optimized and fast.
A simple optimization would be to add a "counter"/bitmap of which words have bits set, so you can skip them. E.g. when adding 1 +1, only the least-significant-word is needed. I think several guys have proposed PRs and optimizations in issues over the time, I just haven't had time/energy to incorporate them or even review much of it. |
Sorry for not submitting a pull request, I'm working on a bignum library and I saw your implementation of multiplication so I just want to point out that you can simplify it by doing the multiply and the add in one loop into the result bn as follow:
The text was updated successfully, but these errors were encountered: