Thanks @oscar!  I didn't think I would get a reply from the blog's owner :-)

Re setting of the environment variable SYMPY_GROUND_TYPES=flint:   (1) 
Would that be in conflict with other parts of sympy/numpy/scipy?  (2) After 
it is set to flint, is there a way to turn it back to the default?  I can 
see scenarios where I need to bench mark various options, and it would be 
really nice to be able to change the flag as I go along in my jupyter 
notebook, as oppsed to restarting the program from scratch.

Taboo question:  When might Sympy 1.13 be coming out?  I am know that such 
questions are taboo, but my project has various stages/steps, and depending 
on the availability of 1.1.3 I might want to work on the LLL-parts first 
while waiting for 1.1.3 to become available.

MANY THANKS for your help and advice.

On Sunday, November 5, 2023 at 10:23:54 AM UTC-5 Oscar wrote:

> On Sun, 5 Nov 2023 at 15:04, T-Rex <[email protected]> wrote:
> >
> > According to https://oscarbenjamin.github.io/blog/czi/post2.html sympy 
> now has LLL, but when I consulted the sympy documentation I could not find 
> actual commands that produces an LLL-reduced basis.
>
> SymPy has a new matrix type called DomainMatrix for which the
> LLL-algorithm is implemented. Ideally the LLL-algorithm would be
> exposed through the ordinary Matrix type but it is not. The
> DomainMatrix.lll method is documented here:
>
> https://docs.sympy.org/latest/modules/polys/domainmatrix.html#sympy.polys.matrices.domainmatrix.DomainMatrix.lll
>
> Starting with an ordinary Matrix M the command to get an LLL-reduced
> basis in SymPy 1.12 is:
>
> In [1]: from sympy.polys.matrices import DomainMatrix
>
> In [2]: M = randMatrix(5) # make a random 5x5 Matrix
>
> In [3]: M
> Out[3]:
> ⎡74 3 71 3 27⎤
> ⎢ ⎥
> ⎢86 74 14 89 26⎥
> ⎢ ⎥
> ⎢58 2 14 54 17⎥
> ⎢ ⎥
> ⎢35 53 17 58 31⎥
> ⎢ ⎥
> ⎣72 83 33 61 85⎦
>
> In [4]: dM = DomainMatrix.from_Matrix(M) # Convert to DomainMatrix
>
> In [5]: dM.lll().to_Matrix() # Compute LLL-basis and convert back to Matrix
> Out[5]:
> ⎡ 7 -19 17 23 22⎤
> ⎢ ⎥
> ⎢51 21 -3 31 -5⎥
> ⎢ ⎥
> ⎢-23 51 3 4 14⎥
> ⎢ ⎥
> ⎢53 -2 -4 -24 18⎥
> ⎢ ⎥
> ⎣-14 -24 -58 -4 13⎦
>
> In SymPy 1.13 there will be a to_DM() method to make this a bit easier
> so it is just:
>
> M.to_DM().lll().to_Matrix()
>
> Ideally we should add an .lll() method directly to Matrix to do this
> without users needing to perform the conversion explicitly.
>
> Also SymPy 1.13 will be able to use python-flint for this. If you have
> python-flint installed (pip install python-flint) and then set the
> environment variable SYMPY_GROUND_TYPES=flint then the
> DomainMatrix.lll method will automatically use Flint which is a lot
> faster for this operation.
>
> --
> Oscar
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/54713a7c-886f-46dd-965e-0e288e61d901n%40googlegroups.com.

Reply via email to