Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Gauss] Error when computing the transpose of a small sparse matrix over GF(2) #604

Open
jdobben opened this issue Apr 12, 2024 · 3 comments

Comments

@jdobben
Copy link

jdobben commented Apr 12, 2024

There appears to be a bug in the gauss package when computing the transpose of a small sparse matrix over GF(2). The issue occurs in recent distributions of GAP, such as GAP 4.12.2 (2022-12-18) / Gauss 2022.11-01 and GAP 4.13.0 (2024-03-15) / Gauss 2023.02-04. The issue can be reproduced by running the following code in GAP:

LoadPackage("gauss");
sm := SparseMatrix(2, 5, [[1,3],[2,4]], [[1,1],[1,1]], GF(2));
TransposedSparseMat(sm);

I'm getting the following output:

 ┌───────┐   GAP 4.13.0 of 2024-03-15
 │  GAP  │   https://www.gap-system.org
 └───────┘   Architecture: x86_64-pc-linux-gnu-default64-kv9
 Configuration:  gmp 6.2.1, GASMAN, readline
 Loading the library and packages ...
 Packages:   AClib 1.3.2, Alnuth 3.2.1, AtlasRep 2.1.8, AutPGrp 1.11, 
             Browse 1.8.21, CaratInterface 2.3.6, CRISP 1.4.6, Cryst 4.1.27, 
             CrystCat 1.1.10, CTblLib 1.3.9, FactInt 1.6.3, FGA 1.5.0, 
             Forms 1.2.9, GAPDoc 1.6.7, genss 1.6.8, IO 4.8.2, IRREDSOL 1.4.4, 
             LAGUNA 3.9.6, orb 4.9.0, Polenta 1.3.10, Polycyclic 2.16, 
             PrimGrp 3.4.4, RadiRoot 2.9, recog 1.4.2, ResClasses 4.7.3, 
             SmallGrp 1.5.3, Sophus 1.27, SpinSym 1.5.2, StandardFF 1.0, 
             TomLib 1.2.11, TransGrp 3.6.5, utils 0.85
 Try '??help' for help. See also '?copyright', '?cite' and '?authors'
gap> LoadPackage("gauss");
─────────────────────────────────────────────────────────────────────────────
Loading Gauss 2023.02-04 (Extended Gauss functionality for GAP)
by Simon Görtzen (https://www.linkedin.com/in/simongoertzen/).
maintained by:
   Mohamed Barakat (https://mohamed-barakat.github.io) and
   Sebastian Gutsche (https://sebasguts.github.io).
Homepage: https://homalg-project.github.io/pkg/Gauss
Report issues at https://github.com/homalg-project/homalg_project/issues
─────────────────────────────────────────────────────────────────────────────
true
gap> sm := SparseMatrix(2, 5, [[1,3],[2,4]], [[1,1],[1,1]], GF(2));
<a 2 x 5 sparse matrix over GF(2)>
gap> TransposedSparseMat(sm);
Error, Record Element: '<rec>.entries' must have an assigned value in
  Add( T!.entries[M!.indices[i][j]], M!.entries[i][j] 
 ); at $(GAPPATH)/pkg/gauss/gap/SparseMatrix.gi:506 called from 
<function "TransposedSparseMat method">( <arguments> )
 called from read-eval loop at *stdin*:3
type 'quit;' to quit to outer loop
brk> 

Am I doing something wrong, or is there a bug here?

@jdobben jdobben changed the title Error when computing the transpose of a small sparse matrix over GF(2) [Gauss] Error when computing the transpose of a small sparse matrix over GF(2) Apr 12, 2024
@mohamed-barakat
Copy link
Member

GF(2) matrices are in so far special, as they do not have the component entries, since all nontrival entries are simply 1. So please use:

gap> LoadPackage("gauss", false);;
gap> sm := SparseMatrix(2, 5, [[1,3],[2,4]]);
gap> TransposedSparseMat(sm);

@jdobben
Copy link
Author

jdobben commented Apr 14, 2024

Thank you for your quick response! That works and seems to circumvent this problem.

However, it still seems to me that the third constructor SparseMatrix( nrows, ncols, indices, entries[, R] ) is broken for GF(2). As far as I can tell, the documentation doesn't specify that this constructor assumes R <> GF(2), so this appears to be an oversight in either the code or the documentation.

BTW, I see now that there is another problem with my input, because the entries I gave are actually integers instead of elements of GF(2) (the problem I ran into in issue #606). The input in my original post should have been:

sm := SparseMatrix(2, 5, [[1,3],[2,4]], [[1,1],[1,1]] * One(GF(2)));

This still gives the same error message as before. It would be helpful if the constructor would either convert this to a valid input or immediately throw an error message, instead of quietly accepting the input and giving cryptic error messages later on.

@mohamed-barakat
Copy link
Member

You are right, the 4 (or 5) argument version of SparseMatrix is not intended for use with GF(2). We can state this explicitly in the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants