Skip to content
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

improve random sampling of quotient-ring elements #37367

Conversation

yyyyx4
Copy link
Member

@yyyyx4 yyyyx4 commented Feb 16, 2024

Currently, random sampling in generic quotient rings is restricted to a very small (and special) subset of the elements:

sage: R.<x,y> = QQ[]
sage: S = R.quotient([x^3, y^2])
sage: {S.random_element() for _ in range(999)}
{-2, -1, 0, 1, 2}

In this patch we add an implementation of .random_element() which simply calls the .random_element() method of the cover ring and maps the result to the quotient. This is still far from perfect for many kinds of quotient rings, but it's definitely an improvement compared to the current behavior.

Copy link

Documentation preview for this PR (built with commit 5c1309c; changes) is ready! 🎉

Copy link
Contributor

@GiacomoPope GiacomoPope left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, and even if there's a smarter method this could be done in the future. I think this is good to go.

vbraun pushed a commit to vbraun/sage that referenced this pull request Feb 18, 2024
    
Currently, random sampling in generic quotient rings is restricted to a
very small (and special) subset of the elements:
```sage
sage: R.<x,y> = QQ[]
sage: S = R.quotient([x^3, y^2])
sage: {S.random_element() for _ in range(999)}
{-2, -1, 0, 1, 2}
```

In this patch we add an implementation of `.random_element()` which
simply calls the `.random_element()` method of the cover ring and maps
the result to the quotient. This is still far from perfect for many
kinds of quotient rings, but it's definitely an improvement compared to
the current behavior.
    
URL: sagemath#37367
Reported by: Lorenz Panny
Reviewer(s): Giacomo Pope
vbraun pushed a commit to vbraun/sage that referenced this pull request Feb 19, 2024
    
Currently, random sampling in generic quotient rings is restricted to a
very small (and special) subset of the elements:
```sage
sage: R.<x,y> = QQ[]
sage: S = R.quotient([x^3, y^2])
sage: {S.random_element() for _ in range(999)}
{-2, -1, 0, 1, 2}
```

In this patch we add an implementation of `.random_element()` which
simply calls the `.random_element()` method of the cover ring and maps
the result to the quotient. This is still far from perfect for many
kinds of quotient rings, but it's definitely an improvement compared to
the current behavior.
    
URL: sagemath#37367
Reported by: Lorenz Panny
Reviewer(s): Giacomo Pope
@tscrim
Copy link
Collaborator

tscrim commented Feb 20, 2024

It would be good to also pass options along.

@yyyyx4
Copy link
Member Author

yyyyx4 commented Feb 20, 2024

Good point, but it looks like @vbraun is already merging this — is it okay to still change the branch now?

@tscrim
Copy link
Collaborator

tscrim commented Feb 20, 2024

Hmmm….possibly no. Let’s just make another PR, and cc me for the review.

@vbraun vbraun merged commit 193e49d into sagemath:develop Feb 25, 2024
18 of 24 checks passed
@yyyyx4 yyyyx4 deleted the public/improve_random_sampling_in_generic_quotient_rings branch February 25, 2024 12:03
@mkoeppe mkoeppe added this to the sage-10.3 milestone Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants