1######################### BEGIN COPYRIGHT MESSAGE ######################### 2# GBNP - computing Gröbner bases of noncommutative polynomials 3# Copyright 2001-2010 by Arjeh M. Cohen, Dié A.H. Gijsbers, Jan Willem 4# Knopper, Chris Krook. Address: Discrete Algebra and Geometry (DAM) group 5# at the Department of Mathematics and Computer Science of Eindhoven 6# University of Technology. 7# 8# For acknowledgements see the manual. The manual can be found in several 9# formats in the doc subdirectory of the GBNP distribution. The 10# acknowledgements formatted as text can be found in the file chap0.txt. 11# 12# GBNP is free software; you can redistribute it and/or modify it under 13# the terms of the Lesser GNU General Public License as published by the 14# Free Software Foundation (FSF); either version 2.1 of the License, or 15# (at your option) any later version. For details, see the file 'LGPL' in 16# the doc subdirectory of the GBNP distribution or see the FSF's own site: 17# http://www.gnu.org/licenses/lgpl.html 18########################## END COPYRIGHT MESSAGE ########################## 19 20# $Id: options.gi 12772 2010-01-15 13:10:24Z jwk $ 21 22# this file enables options 23# WARNING the option records are not copied (not with set and not with get) 24 25### GBNP.GetOptions:=function() 26### GBNP.GetOption:=function(name) 27### GBNP.SetOptions:=function(options) 28### GBNP.SetOption:=function(name,value) 29### GBNP.ClearOptions:=function(arg) 30### GBNP.ClearOption:=function(name) 31### GBNP.ConfigPrint:=function(arg) 32### GBNP.CalculatePG:=function(L) 33 34GBNP.OptionsRec:=rec(pg:=0); 35 36####################### 37### GBNP.GetOptions ### 38####################### 39### 40### Get all options 41### 42### Arguments: none 43### 44### #GBNP.GetOptions uses:# 45### #GBNP.GetOptions is used in: GBNP.AllObs GBNP.CreateOccurTreePTSLR GBNP.GP2NPM GBNP.NondivMonsPTSenum GBNP.PrintTraceTerm GBNP.ReduceCancellation GBNP.ReduceCancellationTrace GBNP.ReducePol2 GBNP.SGrobnerLoops GBNP.TransLetter PrintNP SGrobnerModule# 46### 47 48GBNP.GetOptions:=function() 49 return GBNP.OptionsRec; 50end; 51 52###################### 53### GBNP.GetOption ### 54###################### 55### 56### Get one option (slow, faster is GBNP.GetOptions().name) 57### 58### Arguments: 59### - name the name of the option asked for (string) 60### 61### #GBNP.GetOption uses:# 62### #GBNP.GetOption is used in:# 63### 64 65GBNP.GetOption:=function(name) 66 if IsBound(GBNP.OptionsRec.(name)) then 67 return GBNP.OptionsRec.(name); 68 fi; 69 return fail; 70end; 71 72####################### 73### GBNP.SetOptions ### 74####################### 75### 76### Function to set all options 77### 78### Arguments: 79### - options the new set of options 80### 81### #GBNP.SetOptions uses:# 82### #GBNP.SetOptions is used in:# 83### 84 85GBNP.SetOptions:=function(options) 86 GBNP.OptionsRec:=options; 87end; 88 89###################### 90### GBNP.SetOption ### 91###################### 92### 93### Function to set one option (slow, faster is GBNP.GetOptions().name:=value) 94### 95### Arguments: 96### - name the name of the option to change (string) 97### - value the new value 98### 99### #GBNP.SetOption uses:# 100### #GBNP.SetOption is used in: GBNP.ConfigPrint GBNP.GP2NPM GBNP.SGrobnerLoops SGrobnerModule# 101### 102 103GBNP.SetOption:=function(name,value) 104 GBNP.OptionsRec.(name):=value; 105end; 106 107######################### 108### GBNP.ClearOptions ### 109######################### 110### 111### function to clear all options 112### 113### Arguments: none 114### 115### #GBNP.ClearOptions uses:# 116### #GBNP.ClearOptions is used in:# 117### 118 119GBNP.ClearOptions:=function(arg) 120 GBNP.OptionsRec:=rec(pg:=0); 121end; 122 123######################## 124### GBNP.ClearOption ### 125######################## 126### 127### function to clear one option 128### 129### Arguments: 130### - name name of option to clear (string) 131### 132### #GBNP.ClearOption uses:# 133### #GBNP.ClearOption is used in:# 134### 135 136GBNP.ClearOption:=function(name) 137 Unbind(GBNP.OptionsRec.(name)); 138end; 139 140######################## 141### GBNP.ConfigPrint ### 142######################## 143### XXX integer -> discarded 144### <#GAPDoc Label="GBNP.ConfigPrint"> 145### <ManSection Label="GBNP.ConfigPrint"> 146### <Func Name="GBNP.ConfigPrint" Comm="Set GBNP print options" Arg="arg" /> 147### <Description> 148### By default the generators of the algebra are printed as <C>a</C>, ..., 149### <C>l</C> and everything after the twelfth generator as <C>x</C>. 150### By calling <C>ConfigPrint</C> it is possible to 151### alter this printing convention. 152### The argument(s) will be an algebra or arguments used for naming algebras in 153### GAP upon creation. More specifically, we have the following choices. 154### <List> 155### <Mark><Emph>no arguments</Emph></Mark><Item>When the function is invoked 156### without arguments the printing is reset to the default (see above).</Item> 157### <Mark>algebra</Mark><Item>When the function is invoked with an algebra as 158### argument, generators will be printed as they would be in the 159### algebra.</Item> 160### <Mark>algebra,integer</Mark><Item>When the function is invoked with an 161### algebra and an integer <A>n</A> as arguments, generators will be printed as 162### they would be in the algebra and seperated over the <A>n</A> dimensions.</Item> 163### <Mark>leftmodule</Mark><Item>When the function is invoked with an 164### leftmodule <M>A^n</M> of an associative algebra as argument, generators 165### will be printed as they would be in the algebra, seperated over the 166### <A>n</A> dimensions.</Item> 167### <Mark>string</Mark><Item>When the function is invoked with a string as its 168### argument, it is assumed that there is only 1 generator and that this should 169### be named as indicated by the string.</Item> 170### <Mark>integer</Mark><Item>When the function is invoked with an integer 171### as its argument, the <A>n</A>-th generator will be printed as 172### <C>x.<n></C>.</Item> 173### <Mark>integer, string</Mark><Item>When the function is invoked with a 174### non-negative integer and a string as its arguments, 175### generators will be printed as 176### <C><s>.<n></C>, where <C><s></C> is the string given as 177### argument and <C><n></C> the number of the generator. There is no 178### checking whether the number given as argument is really the dimension. So 179### it is possible that higher numbers return in the output. This way of input 180### is useful however, because it is a distinction 181### from the one-dimensional case 182### and compatible with the way a free algebra is created.</Item> 183### <Mark>string, string, ..., string</Mark><Item>When the function is invoked 184### with a sequence of strings, then 185### generators will be printed with the corresponding 186### string or <C>x</C> if the sequence is not long enough.</Item> 187### </List> 188### <P/> 189### <#Include Label="example-ConfigPrint"> 190### </Description> 191### </ManSection> 192### <#/GAPDoc> 193### 194### #GBNP.ConfigPrint uses: GBNP.SetOption# 195### #GBNP.ConfigPrint is used in:# 196### 197 198GBNP.ConfigPrint:=function(arg) 199local larg, # length of arg 200 names, # names of the generators 201 ln, # length of names 202 A; 203 204 larg:=Length(arg); 205 if larg=0 then 206 # no arguments, use default 207 GBNP.ClearOption("PrintLetterFunction"); 208 GBNP.ClearOption("PrintModuleDimension"); 209 return; 210 elif larg=1 then 211 if IsAlgebra(arg[1]) and IsAssociative(arg[1]) then 212 names:=ShallowCopy(ElementsFamily( 213 FamilyObj(arg[1]))!.names); 214 # is this the right function - jwk 215 elif IsString(arg[1]) then 216 GBNP.SetOption("PrintLetterFunction",x->arg[1]); 217 return ; 218 elif IsInt(arg[1]) then 219 GBNP.SetOption("PrintLetterFunction", 220 x->Concatenation("x.",String(x))); 221 return ; 222 elif IsLeftModule(arg[1]) then 223 A:=LeftActingDomain(arg[1]); 224 225 # should be a module of an associative algebra 226 if not (IsAlgebra(A) and IsAssociative(A)) then 227 return fail; 228 fi; 229 230 names:=ShallowCopy(ElementsFamily( 231 FamilyObj(A))!.names); 232 233 GBNP.SetOption("PrintModuleDimension",DimensionOfVectors(arg[1])); 234 fi; 235 elif larg=2 then 236 if IsInt(arg[1]) then # dimension doesn't really matter 237 GBNP.SetOption("PrintLetterFunction", 238 x->Concatenation(arg[2],".",String(x))); 239 return ; 240 elif IsAlgebra(arg[1]) and IsAssociative(arg[1]) and 241 IsInt(arg[2]) then 242 names:=ShallowCopy(ElementsFamily( 243 FamilyObj(arg[1]))!.names); 244 245 GBNP.SetOption("PrintModuleDimension",arg[2]); 246 247 else # should be all strings 248 names:=ShallowCopy(arg); 249 fi; 250 else 251 names:=ShallowCopy(arg); 252 fi; 253 254 ln:=Length(names); 255 GBNP.SetOption("PrintLetterFunction",function(x) 256 if x<=ln then 257 return names[x]; 258 else 259 return "x"; 260 fi; 261 end); 262end; 263 264######################## 265### GBNP.CalculatePG ### 266######################## 267### 268### checks for the number of prefix generators (that is the number of the 269### lowest generator, multiplied with -1 to make it positive) 270### 271### NOTE: this procedure assumes that L does contain 0 ( [[],[]] ) 272### 273### Arguments: 274### - L list of polynomials 275### 276### #GBNP.CalculatePG uses:# 277### #GBNP.CalculatePG is used in: GBNP.IsGrobnerBasisTest Grobner IsGrobnerPair MakeGrobnerPair SGrobner SGrobnerModule# 278### 279 280GBNP.CalculatePG:=function(L) 281local F; 282 F:=Filtered(L, x->IsBound(x[1][1][1]) and x[1][1][1]<0); 283 if Length(F)=0 then 284 return 0; 285 else 286 return -Minimum(List(F,x->x[1][1][1])); 287 fi; 288end; 289 290########################### 291### GBNP.CalculatePGlts ### 292########################### 293### 294### checks for the number of prefix generators (that is the number of the 295### lowest generator, multiplied with -1 to make it positive) 296### 297### Arguments: 298### - L list of leading terms 299### 300### #GBNP.CalculatePG uses:# 301### #GBNP.CalculatePG is used in: GBNP.IsGrobnerBasisTest Grobner IsGrobnerPair MakeGrobnerPair SGrobner SGrobnerModule# 302### 303 304GBNP.CalculatePGlts:=function(L) 305local F; 306 F:=Filtered(L, x->IsBound(x[1]) and x[1]<0); 307 if Length(F)=0 then 308 return 0; 309 else 310 return -Minimum(List(F,x->x[1])); 311 fi; 312end; 313 314GBNP.cleancount:=0; 315