From afc698ad2c1b0ee28bfc3672c0175d9b544e6c88 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 1 Jan 2018 23:43:17 +0100 Subject: [PATCH] Fix inefficiency when dealing with certain algebra modules The issue was originally reported by Rudolf Tange on the GAP support mailing list. The fix is virtually identical to a fix for a similar issue, see 7aec45fa176be87c32afd53f3cbf88f7ee5c890f --- lib/algrep.gd | 5 +++++ lib/algrep.gi | 18 ++++++++++++++++-- tst/testinstall/algrep.tst | 16 ++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/lib/algrep.gd b/lib/algrep.gd index 9faea8e5597..8cab5ff4177 100644 --- a/lib/algrep.gd +++ b/lib/algrep.gd @@ -790,6 +790,11 @@ DeclareCategory( "IsMonomialElement", IsVector ); DeclareCategoryCollections( "IsMonomialElement" ); DeclareCategoryFamily( "IsMonomialElement" ); +# +DeclareHandlingByNiceBasis( "IsMonomialElementVectorSpace", + "for free left modules of monomial elements"); + + ############################################################################# ## #O ConvertToNormalFormMonomialElement( ) diff --git a/lib/algrep.gi b/lib/algrep.gi index e480abe00b5..5fd6b7cc091 100644 --- a/lib/algrep.gi +++ b/lib/algrep.gi @@ -3180,8 +3180,9 @@ end ); ############################################################################# ## ## Prevent nice basis handling to kick in for vector spaces over sparse -## elements, as that ends up trying to enumerate the vector space, which -## is not a good idea for non-trivial examples. +## elements (including monomial elements), as that ends up trying to +## enumerate the vector space, which is not a good idea for non-trivial +## examples. ## InstallHandlingByNiceBasis( "IsSparseVectorSpace", rec( detect:= function( R, gens, V, zero ) @@ -3196,6 +3197,19 @@ InstallHandlingByNiceBasis( "IsSparseVectorSpace", rec( UglyVector := function( C, vec ) end, ) ); +InstallHandlingByNiceBasis( "IsMonomialElementVectorSpace", rec( + detect:= function( R, gens, V, zero ) + if IsMonomialElementCollection(V) then + return fail; + else + return false; + fi; + end, + NiceFreeLeftModuleInfo := function( C ) end, + NiceVector := function( C, c ) end, + UglyVector := function( C, vec ) end, +) ); + ############################################################################# ## diff --git a/tst/testinstall/algrep.tst b/tst/testinstall/algrep.tst index f8a971a73c7..444a047cd7b 100644 --- a/tst/testinstall/algrep.tst +++ b/tst/testinstall/algrep.tst @@ -30,5 +30,21 @@ true gap> ForAll([1..10], i -> Random(A) in A); true +# +# creating subalgebra +# +gap> L:=FullMatrixLieAlgebra(GF(3), 2);; Dimension(L);; +gap> V:=AdjointModule(L); +> +gap> S:=SymmetricPowerOfAlgebraModule(V, 4); +<35-dimensional left-module over > +gap> bas:=Basis(S){[ 1, 2, 4, 5, 6, 9, 13, 14, 15, 16, 19, 25, 32, 33, 34, 35 ]};; +gap> S1:=SubAlgebraModule(S,bas); +> +gap> Dimension(S1); +16 +gap> S1:=SubAlgebraModule(S,bas,"basis"); +<16-dimensional left-module over > + # gap> STOP_TEST( "algrep.tst", 1);