Skip to content

Conversation

user202729
Copy link
Contributor

@user202729 user202729 commented Jun 20, 2025

Supports calling external flatter executable for LLL algorithm. (If the user wants to use this it is necessary to install from source from https://github.com/keeganryan/flatter)

📝 Checklist

  • The title is concise and informative.
  • 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 and checked the documentation preview.

⌛ Dependencies

Copy link

github-actions bot commented Jun 20, 2025

Documentation preview for this PR (built with commit dc5a22f; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@@ -3097,6 +3101,16 @@ cdef class Matrix_integer_dense(Matrix_dense):
[0 0 0]
[0 0 0]

When ``algorithm='flatter'``, some matrices are not supported depends
Copy link
Member

Choose a reason for hiding this comment

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

the sentence is broken. When is a Germanism, too. You want something like

The ``algorithm='flatter'`` might not support matrices supported by other algorithms.

@@ -3024,6 +3024,10 @@ cdef class Matrix_integer_dense(Matrix_dense):

- ``'pari'`` -- pari's qflll

- ``'flatter'`` -- external executable ``flatter``, requires manual install (see caveats below).
Note that sufficiently new version of ``pari`` also supports FLATTER algorithm, see
Copy link
Member

Choose a reason for hiding this comment

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

please provide Pari version info where this appeared. Also, do you know if this already is available from cypari2 ?

Copy link
Contributor Author

@user202729 user202729 Jun 26, 2025

Choose a reason for hiding this comment

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

  • New recursive implementation of the qflll and qflllgram functions
    using the FLATTER reduction algorithm of N. Heninger and K. Ryan.

from https://pari.math.u-bordeaux.fr/archives/pari-announce-24/msg00003.html

so, 2.17.0.

supposedly it's available

sage: pari.version()
(2, 17, 1)

but pari is still slower than flatter on my machine. Demo where LLL is used to compute (integral) kernel of a matrix:

m = random_matrix(ZZ, 25, 50, x=1, y=10^100)
assert m.rank() == 25

%time m.change_ring(QQ).right_kernel_matrix()  # 2.5s
%time m.right_kernel_matrix()  # 8s

%time m1 = (m.T*2^1200).augment(matrix.identity(50)).LLL(algorithm="pari")  # 5s
assert m1[:25,:25]==0

%time m1 = (m.T*2^1200).augment(matrix.identity(50)).LLL(algorithm="flatter")  # 3s (CPU time is small because time is spent in subprocess)
assert m1[:25,:25]==0

more:

%time m.right_kernel_matrix(algorithm='flint')  # 6s
%time m.right_kernel_matrix(algorithm='pari')   # unreasonably long
%time m.right_kernel_matrix(algorithm='padic')  # 8.5s

%time m.change_ring(QQ).right_kernel_matrix(algorithm='flint')  # 2.2s
%time m.change_ring(QQ).right_kernel_matrix(algorithm='padic')  # 2.2s

if fp is not None or early_red or use_givens or transformation or eta is not None or use_siegel:
raise TypeError("flatter does not support fp, early_red, use_givens, transformation, eta or use_siegel")
if kwds:
raise TypeError("flatter does not support additional keywords")
Copy link
Member

Choose a reason for hiding this comment

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

would it be more consistent to just ignore kwds here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's better practice to complain to the user about invalid data than to silently ignore them.

vbraun pushed a commit to vbraun/sage that referenced this pull request Jun 27, 2025
sagemathgh-40274: Add flatter support
    
Supports calling external `flatter` executable for `LLL` algorithm. (If
the user wants to use this it is necessary to install from source from
https://github.com/keeganryan/flatter)

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

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

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40274
Reported by: user202729
Reviewer(s): Dima Pasechnik, user202729
@vbraun vbraun merged commit 7b22571 into sagemath:develop Jul 6, 2025
31 checks passed
@user202729 user202729 mentioned this pull request Aug 25, 2025
5 tasks
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.

3 participants