Support randmatrix() for mp.iv and mp contexts#527
Merged
skirpichev merged 1 commit intompmath:masterfrom Jun 26, 2023
Merged
Conversation
Collaborator
|
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 |
Contributor
Author
|
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. |
Collaborator
|
@MaxGaukler could you please fix merge conflicts? |
d92aa5e to
7f5cf5e
Compare
Contributor
Author
|
Now squashed and rebased. Happy to see that there is interest in my suggestion :-) |
skirpichev
reviewed
Jun 3, 2023
skirpichev
requested changes
Jun 3, 2023
Collaborator
skirpichev
left a comment
There was a problem hiding this comment.
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 ...
skirpichev
approved these changes
Jun 11, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before,
mpmath.iv.randmatrix()caused an error. Now it works correctly:import randomto the top level? AFAIK it should even be faster this way.