Weird behaviour of Matrix_cyclo_dense

42 views
Skip to first unread message

Александр Каренин (alexKar)

unread,
Sep 28, 2022, 1:44:51 AM9/28/22
to sage-devel
Hi all,

Having trouble with the matrix multiplication which I first explained in https://ask.sagemath.org/question/64194/determinants-over-cyclotomic-fields-are-broken/
If I define two matrices (L and U) over CyclotomicField and then multiply then like L*U and via the definition then the results are sometimes different. An example is:

K.<z> = CyclotomicField(16)
OK = K.ring_of_integers()
L = [[-575*z^7 - 439*z^6 - 237*z^5 + 237*z^3 + 439*z^2 + 575*z + 623, 0],
[0,     -114*z^7 - 88*z^6 - 48*z^5 + 48*z^3 + 88*z^2 + 114*z + 123]]
U = [[-1926*z^7 - 1474*z^6 - 798*z^5 + 798*z^3 + 1474*z^2 + 1926*z + 2085, 0],
[0,   -1014*z^7 - 777*z^6 - 421*z^5 + 421*z^3 + 777*z^2 + 1014*z + 1097]]
L, U = matrix(K,L), matrix(K,U)
LU = matrix( [ [L[i].inner_product(U.transpose()[j]) for j in range(2)] for i in range(2)] )
assert LU == L*U

Where the last assertion must clearly sucseed but it doesn't.

Note: if I define L, U = matrix(K,L), matrix(K,U) then the matrices are no longer Matrix_cyclo_dense but Matrix_generic_dense and the last assertion sucseeds!

Checked that one on Ubuntu 22.04.01 and MacOS on sage 9.4, 9.5 and 9.6. Is this the known issue? Am doing it wrong?

Kind regards,
Alexander

Dima Pasechnik

unread,
Sep 28, 2022, 8:42:28 AM9/28/22
to sage-...@googlegroups.com
Thanks for the report!

On Wed, Sep 28, 2022 at 6:49 AM Александр Каренин (alexKar)
<tremel...@gmail.com> wrote:
> Having trouble with the matrix multiplication which I first explained in https://ask.sagemath.org/question/64194/determinants-over-cyclotomic-fields-are-broken/
> If I define two matrices (L and U) over CyclotomicField and then multiply then like L*U and via the definition then the results are sometimes different. An example is:
>
> K.<z> = CyclotomicField(16)
> OK = K.ring_of_integers()
> L = [[-575*z^7 - 439*z^6 - 237*z^5 + 237*z^3 + 439*z^2 + 575*z + 623, 0],
> [0, -114*z^7 - 88*z^6 - 48*z^5 + 48*z^3 + 88*z^2 + 114*z + 123]]
> U = [[-1926*z^7 - 1474*z^6 - 798*z^5 + 798*z^3 + 1474*z^2 + 1926*z + 2085, 0],
> [0, -1014*z^7 - 777*z^6 - 421*z^5 + 421*z^3 + 777*z^2 + 1014*z + 1097]]
> L, U = matrix(K,L), matrix(K,U)
> LU = matrix( [ [L[i].inner_product(U.transpose()[j]) for j in range(2)] for i in range(2)] )
> assert LU == L*U
>
> Where the last assertion must clearly sucseed but it doesn't.
>
> Note: if I define L, U = matrix(K,L), matrix(K,U) then the matrices are no longer Matrix_cyclo_dense but Matrix_generic_dense and the last assertion sucseeds!

I gather you mean
L, U = matrix(OK,L), matrix(OK,U)
after checking your
https://ask.sagemath.org/question/64194/determinants-over-cyclotomic-fields-are-broken
>
> Checked that one on Ubuntu 22.04.01 and MacOS on sage 9.4, 9.5 and 9.6. Is this the known issue? Am doing it wrong?

It's a bug, see https://trac.sagemath.org/ticket/34597

Dima
>
> Kind regards,
> Alexander
>
> --
> You received this message because you are subscribed to the Google Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/44f0ff3c-71db-4555-a494-80b2ae222c22n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages