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 getting matrix entries after permutation in _palp_PM_max() #35997

Merged
merged 12 commits into from
Jul 30, 2023

Conversation

xuluze
Copy link
Contributor

@xuluze xuluze commented Jul 28, 2023

Modify the _palp_PM_max() to obtain the matrix entry after permutation without make copy of the matrix. @mkoeppe

before

sage: %timeit -n 10 -r 3 o = lattice_polytope.cross_polytope(3); o._palp_PM_max();
36.8 ms ± 5.19 ms per loop (mean ± std. dev. of 3 runs, 10 loops each)

after

sage: %timeit -n 10 -r 3 o = lattice_polytope.cross_polytope(3); o._palp_PM_max();
4.88 ms ± 2.23 ms per loop (mean ± std. dev. of 3 runs, 10 loops each)

📝 Checklist

  • The title is concise, informative, and self-explanatory.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation accordingly.

⌛ Dependencies

@mkoeppe
Copy link
Member

mkoeppe commented Jul 28, 2023

Also add some before/after timings (use %time or %timeit) in the PR description please

@mkoeppe
Copy link
Member

mkoeppe commented Jul 28, 2023

I tried it out but it does not pass tests for me:
./sage -t --long src/sage/geometry/lattice_polytope.py

@xuluze
Copy link
Contributor Author

xuluze commented Jul 28, 2023 via email

Copy link
Member

@mkoeppe mkoeppe left a comment

Choose a reason for hiding this comment

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

Works for me, great improvement, thanks!

@github-actions
Copy link

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

@vbraun vbraun merged commit 79dc351 into sagemath:develop Jul 30, 2023
7 of 9 checks passed
@mkoeppe mkoeppe added this to the sage-10.1 milestone Jul 30, 2023
vbraun pushed a commit to vbraun/sage that referenced this pull request Nov 27, 2023
…alp_native')`, change to default, add as a `Polyhedron` method

    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

<!-- Why is this change required? What problem does it solve? -->
The current default algorithm, using the external, unmaintained `palp`
package, is unreliable.

Here, as a follow-up on sagemath#35997, we make the reimplementation of the PALP
algorithm in Python (`palp_native`) suitable as the new default by
speeding it up.

We also fix a bug in introduced in sagemath#35997.

We also make it available as a method of `Polyhedron` (for base ring
`ZZ`).

@xuluze
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [ ] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#36031
Reported by: Matthias Köppe
Reviewer(s): Dima Pasechnik, Frédéric Chapoton, Matthias Köppe
vbraun pushed a commit to vbraun/sage that referenced this pull request Dec 4, 2023
…alp_native')`, change to default, add as a `Polyhedron` method

    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

<!-- Why is this change required? What problem does it solve? -->
The current default algorithm, using the external, unmaintained `palp`
package, is unreliable.

Here, as a follow-up on sagemath#35997, we make the reimplementation of the PALP
algorithm in Python (`palp_native`) suitable as the new default by
speeding it up.

We also fix a bug in introduced in sagemath#35997.

We also make it available as a method of `Polyhedron` (for base ring
`ZZ`).

@xuluze
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [ ] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#36031
Reported by: Matthias Köppe
Reviewer(s): Dima Pasechnik, Frédéric Chapoton, Matthias Köppe
vbraun pushed a commit to vbraun/sage that referenced this pull request Dec 5, 2023
…alp_native')`, change to default, add as a `Polyhedron` method

    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

<!-- Why is this change required? What problem does it solve? -->
The current default algorithm, using the external, unmaintained `palp`
package, is unreliable.

Here, as a follow-up on sagemath#35997, we make the reimplementation of the PALP
algorithm in Python (`palp_native`) suitable as the new default by
speeding it up.

We also fix a bug in introduced in sagemath#35997.

We also make it available as a method of `Polyhedron` (for base ring
`ZZ`).

@xuluze
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [ ] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#36031
Reported by: Matthias Köppe
Reviewer(s): Dima Pasechnik, Frédéric Chapoton, Matthias Köppe
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

3 participants