-
Notifications
You must be signed in to change notification settings - Fork 176
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
Support randmatrix() for mp.iv and mp contexts #527
Conversation
There is a small problem: random.random() returns a random double, so this will not give full precision random numbers. |
Should be better now. I added tests, but am not sure how |
By the way, please let me know as soon as you consider it ready for merging so that I can provide a rebased version of this pull request as a single commit. |
@MaxGaukler could you please fix merge conflicts? |
d92aa5e
to
7f5cf5e
Compare
Now squashed and rebased. Happy to see that there is interest in my suggestion :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are also merge conflicts. Please fix them.
Except for comment in the ctx_fp.py and above remark - seems ok for me.
To make this work correctly, rand() now supports arbitrary precision: >>> x = mpmath.iv.rand() * mpmath.iv.convert(2**53) >>> x - int(x) mpi('0.0', '0.0') >>> mpmath.iv.prec=1234 >>> x = mpmath.iv.rand() * mpmath.iv.convert(2**53) >>> x - int(x) mpi('0.05786680052076454587 ...
Before,
mpmath.iv.randmatrix()
caused an error. Now it works correctly:import random
to the top level? AFAIK it should even be faster this way.