From e10aef5dd15532b987fc902ddeffc5163ba5adc3 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 2 Oct 2018 13:39:03 +0200 Subject: [PATCH] Fix + and * of DirectProductElement and non-list collection These are problematic as follows: Suppose you want to know what kind of object A*B is: * If A and B are "scalars", it is their product. * If A is a "scalar" and B=[x,y] is a list or a direct product element (dpe), it is the list [A*x,A*y]. * If A=[x,y] is a list and B is a "scalar", it is the list [x*B, y*B] * If both are lists, it is their scalar product But now what if A is a RightCoset in a group G, and B a group element? Then we might expect this to be the new right coset A*B, at least if B is in G. But if B is a list or dpe [x,y], it could also mean the dpe [A*x, A*y]. This ambiguity is the source of problems once the method ranks fluctuate. This commit works around this issue by modifying some methods which currently try to disambiguate the above situation by checking the arguments against the filter `IsList`, to instead check `IsListOrCollection`. --- lib/tuples.gd | 3 ++- lib/tuples.gi | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/tuples.gd b/lib/tuples.gd index 487bb6b64d..4ed3790bb5 100644 --- a/lib/tuples.gd +++ b/lib/tuples.gd @@ -46,7 +46,8 @@ DeclareInfoClass( "InfoDirectProductElements" ); ## The sum and the product of a direct product element and a list in ## is the list of sums and products, ## respectively. -## The sum and the product of a direct product element and a non-list +## The sum and the product of a direct product element and an object +## that is neither a list nor a collection ## is the direct product element of componentwise sums and products, ## respectively. ## diff --git a/lib/tuples.gi b/lib/tuples.gi index cdb8a7e55a..8dcf4ade04 100644 --- a/lib/tuples.gi +++ b/lib/tuples.gi @@ -470,7 +470,7 @@ InstallOtherMethod( \+, "for a direct product element, and a non-list", [ IsDirectProductElement, IsObject ], function( dpelm, nonlist ) - if IsList( nonlist ) then + if IsListOrCollection( nonlist ) then TryNextMethod(); fi; return DirectProductElement( List( dpelm, entry -> entry + nonlist ) ); @@ -480,7 +480,7 @@ InstallOtherMethod( \+, "for a non-list, and a direct product element", [ IsObject, IsDirectProductElement ], function( nonlist, dpelm ) - if IsList( nonlist ) then + if IsListOrCollection( nonlist ) then TryNextMethod(); fi; return DirectProductElement( List( dpelm, entry -> nonlist + entry ) ); @@ -490,7 +490,7 @@ InstallOtherMethod( \*, "for a direct product element, and a non-list", [ IsDirectProductElement, IsObject ], function( dpelm, nonlist ) - if IsList( nonlist ) then + if IsListOrCollection( nonlist ) then TryNextMethod(); fi; return DirectProductElement( List( dpelm, entry -> entry * nonlist ) ); @@ -500,7 +500,7 @@ InstallOtherMethod( \*, "for a non-list, and a direct product element", [ IsObject, IsDirectProductElement ], function( nonlist, dpelm ) - if IsList( nonlist ) then + if IsListOrCollection( nonlist ) then TryNextMethod(); fi; return DirectProductElement( List( dpelm, entry -> nonlist * entry ) );