Re: fmpz_lll returns U=0

11 views
Skip to first unread message

John Cremona

unread,
May 22, 2026, 5:37:33 PM (3 days ago) May 22
to FLINT dev
Attached is a small example. I compiled with

gcc flint_ex.c -lflint -o flint_ex

and running produces

A (before) =
[[-1 1 -2 0 -2 3]
[1 -2 2 2 -2 0]
]
A (after) =
[[1 -2 2 2 -2 0]
[-1 1 -2 0 -2 3]
]
U =
[[0 0]
[0 0]
]

John

PS There does not appear to be a clear function for fmpz_lll_t -- I
don't know if that matters.

On Fri, 22 May 2026 at 15:35, John Cremona <john.c...@gmail.com> wrote:
>
> I am using the function fmpz_lll but it appears to return the zero
> matrix for that expected transform U. I am probably doing something
> stupid but I cannot easily track down what is happening as the code is
> complicated.
>
> Here is an extract from my code, not including the initialization of A
> which is done in a subsidiary function called flint_mat_from_mat
> (which has caused no problems before -- it does the fmpz_mat_init()
> call):
>
> fmpz_mat_t A;
> flint_mat_from_mat(A, M);
> flint_printf("fmpz_mat A = \n");
> fmpz_mat_print_pretty(A); cout << endl;
> auto nr = fmpz_mat_nrows(A);
> fmpz_mat_t UU;
> fmpz_mat_init(UU, nr, nr);
> flint_printf("After fmpz_mat_init, UU = \n");
> fmpz_mat_print_pretty(UU); cout << endl;
> fmpz_lll_t fl;
> fmpz_lll_context_init_default(fl);
>
> and the output is
>
> fmpz_mat A =
> [[-1 1 -2 0 -2 3 4 -2 -3 -3 2 3 0 1 -6 0 6 -6 9 13 2 -12 -4 8]
> [1 -2 2 2 -2 0 -2 0 0 6 -2 -4 0 -2 4 4 -8 2 2 -4 -8 2 -4 6]
> ]
> After fmpz_mat_init, UU =
> [[0 0]
> [0 0]
> ]
> fmpz_lll sets A =
> [[1 -2 2 2 -2 0 -2 0 0 6 -2 -4 0 -2 4 4 -8 2 2 -4 -8 2 -4 6]
> [-1 1 -2 0 -2 3 4 -2 -3 -3 2 3 0 1 -6 0 6 -6 9 13 2 -12 -4 8]
> ]
> fmpz_lll sets UU =
> [[0 0]
> [0 0]
> ]
>
> I know that I should send a complete program but it is hot here in
> England (27C) so I amy not manage that before the weekend.
>
> John
flint_ex.c

John Cremona

unread,
May 22, 2026, 5:37:33 PM (3 days ago) May 22
to FLINT dev
Perhaps U needs to be initialized to the identity matrix? This is not documented! Similarly for HNF and SNF.  I noticed that the test code does this.

John

John Cremona

unread,
May 22, 2026, 5:37:34 PM (3 days ago) May 22
to FLINT dev
Reply all
Reply to author
Forward
0 new messages