What's the point of GF(2, impl='ntl')?

58 views
Skip to first unread message

John H Palmieri

unread,
Sep 26, 2023, 1:00:45 AM9/26/23
to sage-devel
Setup:

sage: F = GF(2, impl='ntl')
sage: m_ntl = identity_matrix(1, F)
sage: v_ntl = vector(F, (1,))

Now consider

sage: m_ntl * v_ntl
sage: v_ntl * m_ntl

I'm trying to multiply a 1x1 matrix by a 1-dimensional vector, in one order or the other. Here's what happens: the first line fails with a SignalError, and the second actually crashes Sage. If we are defining a field that can't do linear algebra, shouldn't there be big warnings posted somewhere? If we are defining a field like this, are there any expectations that it should work broadly with Sage types and constructions? I just discovered that cup products in mod 2 cohomology don't work when "mod 2" means coefficients in GF(2, impl='ntl'), and I don't know if I should bother trying to fix this.

For what it's worth, I get the same with `GF(2, impl='givaro')`. Also for what it's worth, explicitly converting `v_ntl` to a matrix allows the matrix multiplication to work.

I see this on two different OS X machines, one Intel and one Apple Silicon.

--
John

Message has been deleted

Vincent Delecroix

unread,
Sep 29, 2023, 3:32:14 AM9/29/23
to sage-...@googlegroups.com
What is your sage version? How did you install it? Did you open an
issue on github?

Best
Vincent
> --
> 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/faeffb72-3b16-4f37-90c4-f969e4d5c017n%40googlegroups.com.

Dima Pasechnik

unread,
Sep 29, 2023, 8:54:45 AM9/29/23
to sage-...@googlegroups.com
On Fri, Sep 29, 2023 at 8:32 AM Vincent Delecroix
<20100.d...@gmail.com> wrote:
>
> What is your sage version? How did you install it? Did you open an
> issue on github?

I can confirm this happens on Linux, with a recent Sage beta, too.

This is now https://github.com/sagemath/sage/issues/36361
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/CAGEwAAm37d_yY%2B7AYbUV2dtVwXBGwE412yLGjcPi1wSCO%2BjfvA%40mail.gmail.com.

John H Palmieri

unread,
Sep 29, 2023, 11:53:16 AM9/29/23
to sage-devel
First, an error in the original message: it should have been "identity_matrix(F, 1)". That doesn't make any difference in the behavior. A little exploration suggests that the problem goes away if you make the identity matrix sparse: the problem may be with multiplying a dense matrix with a vector. I'm not sure about this, though.

This is with the most recent beta, built from scratch on several different OS X machines. It also happens on Sagecell. I have not yet opened an issue, because there are deeper existential questions: if linear algebra over this field is broken, and if there are no doctests to detect that it's broken, how viable is this implementation? How long has it been broken? Why has no one noticed? What is it used for? Should we keep it?

I think that if someone wanted to add a new implementation of a field to Sage today, we would insist on doctests verifying that it worked as a drop-in replacement for the existing implementations everywhere in Sage where fields get used. GF(2, impl='ntl') does not meet this standard. Someone can presumably fix this one bug, but is someone willing to add all of the doctests that should really be added?

Vincent Delecroix

unread,
Sep 29, 2023, 11:57:40 AM9/29/23
to sage-...@googlegroups.com
I definitely agree about tests! There should be a generic "test suite"
that should systematically be run with these all different
implementations. It is a bit ridiculous that your example was not
caught.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/378f06a5-2008-42fb-8642-32019a3a4976n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages