/usr/share/gap/lib/ctblmoli.gi is in gap-libs 4r6p5-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 | #############################################################################
##
#W ctblmoli.gi GAP library Thomas Breuer
##
##
#Y Copyright (C) 1997, Lehrstuhl D für Mathematik, RWTH Aachen, Germany
#Y (C) 1998 School Math and Comp. Sci., University of St Andrews, Scotland
#Y Copyright (C) 2002 The GAP Group
##
## This file contains methods for Molien series.
##
#############################################################################
##
#F StringOfUnivariateRationalPolynomialByCoefficients( <coeffs>, <nam> )
##
#T maybe we need more flexible ways to influence how an object is printed or
#T how its string looks like;
#T in this case, I want to influence how the indeterminate is printed.
##
BindGlobal( "StringOfUnivariateRationalPolynomialByCoefficients",
function( coeffs, nam )
local string, i;
string:= "";
for i in [ 1 .. Length( coeffs ) ] do
if coeffs[i] <> 0 then
if coeffs[i] > 0 then
if not IsEmpty( string ) then
Append( string, "+" );
fi;
if coeffs[i] <> 1 then
Append( string, String( coeffs[i] ) );
if i <> 1 then
Append( string, "*" );
fi;
elif i = 1 then
Append( string, "1" );
fi;
elif coeffs[i] < 0 then
if coeffs[i] <> -1 then
Append( string, String( coeffs[i] ) );
if i <> 1 then
Append( string, "*" );
fi;
elif i = 1 then
Append( string, "-1" );
else
Append( string, "-" );
fi;
fi;
if i <> 1 then
Append( string, nam );
fi;
if i > 2 then
Append( string, "^" );
Append( string, String( i-1 ) );
fi;
fi;
od;
if IsEmpty( string ) then
string:= "0";
fi;
ConvertToStringRep( string );
# Return the string.
return string;
end );
#############################################################################
##
#F CoefficientTaylorSeries( <numer>, <r>, <k>, <i> )
##
## We have
## $$
## \frac{1}{( 1 - x )^k} =
## \frac{1}{(k-1)!} \frac{d^{k-1}}{dx^{k-1}} \frac{1}{1-x}
## \mbox{\rm\ where\ }
## \frac{1}{1 - x} = \sum_{j=0}^{\infty} x^j .
## $$
## Thus we get
## $$
## \frac{c_i z^i}{( 1 - z^r )^k} =
## \sum_{j=0}^{\infty} c_i \frac{(j+k-1)!}{(k-1)! j!} z^{r j + i}.
## $$
##
## For $p(z) = \sum_{i=0}^m c_i z^i$ where $m = u r + n$ with $0\leq n \< r$
## we have
## $$
## \frac{p(z)}{( 1 - z^r )^k} =
## \frac{1}{(k-1)!}\sum_{i=0}^m\sum_{j=0}^{\infty}
## c_i \frac{(j+k-1)!}{(k-1)! j!} z^{r j + i} .
## $$
##
## The coefficient of $z^l$ with $l = g r + v$, $0\leq v \< r$ is
## $$
## \sum_{j=0}^{\min\{g,u\}} c_{j r + v}
## \prod_{\mu=1}^{k-1} \frac{g-j+\mu}{\mu} .
## $$
##
InstallGlobalFunction( CoefficientTaylorSeries, function( numer, r, k, l )
local i, m, u, v, g, coeff, lower, summand, mu;
m:= Length( numer ) - 1;
u:= Int( m / r );
v:= l mod r;
g:= Int( l / r );
coeff:= 0;
# lower bound for the summation
if g < u then
lower:= u-g;
else
lower:= 0;
fi;
for i in [ lower .. u ] do
if (u-i)*r + v <= m then
summand:= numer[ (u-i)*r + v + 1 ];
for mu in [ 1 .. k-1 ] do
summand:= summand * ( i - u + g + mu ) / mu;
od;
coeff:= coeff + summand;
fi;
od;
return coeff;
end );
#############################################################################
##
#F SummandMolienSeries( <tbl>, <psi>, <chi>, <i> )
##
InstallGlobalFunction( SummandMolienSeries, function( tbl, psi, chi, i )
local x, # indeterminate
numer, # numerator in summands corresp. to `i'-th class
a, # multiplicities of cycl. pol. in the denominator
ev, # eigenvalues of `psi' at class `i'
n, # element order of class `i'
e, # `E(n)'
div, # divisors of `n'
d, # loop over `div'
roots, # exponents of `d'-th prim. roots
r; # loop over `roots'
x:= Indeterminate( Cyclotomics );
if chi[i] = 0 then
numer := Zero(x);
a := [ 1, 1 ];
else
ev := EigenvaluesChar( tbl, psi, i );
n := Length( ev );
e := E(n);
# numerator of summands corresponding to `i'-th class
numer:= chi[i] * e ^ Sum( [ 1 .. n ], j -> j * ev[j] ) * One( x );
div:= ShallowCopy( DivisorsInt( n ) );
RemoveSet( div, 1 );
a:= List( [ 1 .. n ], x -> 0 );
a[1]:= ev[n];
for d in div do
# compute $a_d$, that is, the maximal multiplicity of `ev[k]'
# for all `k' with $\gcd(n,k) = n / d$.
roots:= ( n / d ) * PrimeResidues( d );
a[d]:= Maximum( ev{ roots } );
for r in roots do
if a[d] <> ev[r] then
numer:= numer * ( x - e ^ r ) ^ ( a[d] - ev[r] );
fi;
od;
od;
fi;
return rec( numer := numer,
a := a );
end );
#############################################################################
##
#F MolienSeries( <psi> )
#F MolienSeries( <psi>, <chi> )
#F MolienSeries( <tbl>, <psi> )
#F MolienSeries( <tbl>, <psi>, <chi> )
##
InstallGlobalFunction( MolienSeries, function( arg )
local tbl, # character table, first argument
psi, # character of `tbl', second argument
chi, # character of `tbl', optional third argument
numers, # list of numerators of sum of polynomial quotients
denoms, # list of denominators of sum of polynomial quotients
x, # indeterminate
tblclasses, # class lengths of `tbl'
orders, # representative orders of `tbl'
classes, # list of classes of `tbl' that are not yet used
sub, # classes that belong to one cyclic subgroup
i, # represenative of `sub'
n, # element order of class `i'
summand, #
numer, # numerator in summands corresp. to `i'-th class
div, # divisors of `n'
a, # multiplicities of cycl. pol. in the denominator
d, # loop over `div'
r, # loop over `roots'
f, # `CF( n )'
special, # parameters of special factor in the denominator
dd, # loop over divisors of `d'
p, #
q, #
j, #
F, #
pol, #
qr, #
num, #
pos, #
denpos, #
repr, #
series, # Molien series, result
denom, # smallest common denominator for the summands
denomstring, # string of `denom', in factored form
c, # coefficients & valuation
numerstring, # string of `numer'
denominfo, # list of pairs `[ r, k ]' in the denominator
rkpairs, # list of pairs of the form `[ r, k ]'
rr, # `r' value of the current summand
kk, # `k' value of the current summand
sumnumer, # numerator of the current summand
pair, # loop over `rkpairs'
min; # minimum of `kk' and `k' value of the current pair
# Check and get the arguments.
if Length( arg ) = 1 and IsClassFunction( arg[1] ) then
tbl:= UnderlyingCharacterTable( arg[1] );
psi:= ValuesOfClassFunction( arg[1] );
chi:= List( psi, x -> 1 );
elif Length( arg ) = 2 and IsClassFunction( arg[1] )
and IsClassFunction( arg[2] ) then
tbl:= UnderlyingCharacterTable( arg[1] );
psi:= ValuesOfClassFunction( arg[1] );
chi:= ValuesOfClassFunction( arg[2] );
elif Length( arg ) = 2 and IsOrdinaryTable( arg[1] )
and IsHomogeneousList( arg[2] ) then
tbl:= arg[1];
psi:= arg[2];
chi:= List( psi, x -> 1 );
elif Length( arg ) = 3 and IsOrdinaryTable( arg[1] )
and IsList( arg[2] )
and IsList( arg[3] ) then
tbl:= arg[1];
psi:= arg[2];
chi:= arg[3];
else
Error( "usage: MolienSeries( [<tbl>, ]<psi>[, <chi>] )" );
fi;
# Initialize lists of numerators and denominators
# of summands of the form $p_j(z) / (z^r-1)^k$.
# In `numers[ <j> ]' the coefficients list of $p_j(z)$ is stored,
# in `denoms[ <j> ]' the pair `[ r, k ]'.
# `pol' is an additive polynomial.
numers:= [];
denoms:= [];
x:= Indeterminate( Rationals );
pol:= Zero( x );
tblclasses:= SizesConjugacyClasses( tbl );
classes:= [ 1 .. Length( tblclasses ) ];
orders:= OrdersClassRepresentatives( tbl );
# Take the cyclic subgroups of `tbl'.
while not IsEmpty( classes ) do
# Compute the next cyclic subgroup,
# remove the classes of the cyclic subgroup,
# take a representative.
sub:= ClassOrbit( tbl, classes[1] );
SubtractSet( classes, sub );
i:= sub[1];
# Compute $v(g) = \frac{\chi(g) \det(D(g))}{\det(z I - D(g))}$
# for $g$ in class `i'.
# This is encoded as record with components `numer' and `a'
# where `a[r]' means the multiplicity of the `r'-th cyclotomic
# polynomial in the denominator.
summand:= SummandMolienSeries( tbl, psi, chi, i );
# Omit summands with zero numerator.
if not IsZero( summand.numer ) then
numer:= CoefficientsOfLaurentPolynomial( summand.numer );
a:= summand.a;
# Compute the sum over class representatives of the cyclic
# subgroup containing $g$, i.e., the relative trace of $v(g)$.
n:= orders[i];
f:= CF( n );
numer:= List( ShiftedCoeffs( numer[1], numer[2] ),
y -> Trace( f, y ) )
* ( Length( sub ) / Phi(n) );
numer:= UnivariatePolynomial( Rationals, numer, 1 );
# Try to reduce the number of factors in the denominator
# by forming one factor of the form $(z^r - 1)^k$.
# But we still want to guarantee that the factors are pairwise
# coprime, that is, the exponents of all involved cyclotomic
# polynomials must be equal.
special:= false;
if a[1] > 0 then
# There is such a ``special\'\' factor.
div:= DivisorsInt( n );
for d in Reversed( div ) do
if a[1] <> 0 and ForAll( DivisorsInt(d), y -> a[y] = a[1] ) then
# The special factor is $( z^d - 1 ) ^ a[d]$.
special:= [ d, a[d] ];
for dd in DivisorsInt( d ) do
a[dd]:= 0;
od;
fi;
od;
fi;
# Compute the product of the remaining factors in the denominator.
F:= One( x );
for j in [ 1 .. n ] do
if a[j] <> 0 then
F:= F * CyclotomicPolynomial( Rationals, j ) ^ a[j];
fi;
od;
if special <> false then
# Split the summand into two summands, with denominators
# the special factor `f' resp. the remaining factors `F'.
f:= ( x ^ special[1] - 1 ) ^ special[2];
repr:= GcdRepresentation( F, f );
# Reduce the numerators if possible.
num:= numer * repr[1];
if special[1] * special[2]
< DegreeOfLaurentPolynomial( num ) then
qr:= QuotientRemainder( num, f );
pol:= pol + tblclasses[i] * qr[1];
num:= qr[2];
fi;
# Store the summand.
denpos:= Position( denoms, special, 0 );
if denpos = fail then
Add( denoms, special );
Add( numers, tblclasses[i] * num );
else
numers[ denpos ]:= numers[ denpos ] + tblclasses[i] * num;
fi;
# The remaining term is `numer \* repr[2] / F'.
numer:= numer * repr[2];
fi;
# Split the quotient into a sum of quotients
# whose denominators are cyclotomic polynomials.
# We have $1 / \prod_{i=1}^k f_i = \sum_{i=1}^k p_i / f_i$
# if the $f_i$ are pairwise coprime,
# where the polynomials $p_i$ are computed by
# $r_i \prod_{j>i} f_j + q_i f_i = 1$ for $1 \leq i \leq k-1$,
# $r_k = 1$, and $p_i = r_i \prod_{j=1}^{i-1} q_j$.
# In the end we have a sum of quotients with denominator of the
# form $(z^r-1)^k$. We store the pair $[ r, k ]$ in the list
# `denoms', and $(-1)^k$ times the numerator in the list `numers'.
pos:= 1;
q:= 1;
while pos <= n do
if a[ pos ] <> 0 then
# $f_i$ is the next factor encoded in `a'.
f:= CyclotomicPolynomial( Rationals, pos ) ^ a[ pos ];
F:= F / f;
# $\prod_{j>i} f_j$ is stored in `F', and $f_i$ is in `f'.
# at first position $r_i$, at second position $q_i$
repr:= GcdRepresentation( F, f );
# The numerator $p_i$.
p:= q * repr[1];
q:= q * repr[2];
# We blow up the denominator $f_i$, and encode the summands.
dd:= ShallowCopy( DivisorsInt( pos ) );
RemoveSet( dd, pos );
for r in dd do
p:= p * CyclotomicPolynomial( Rationals, r ) ^ a[ pos ];
od;
# Reduce the numerators if possible.
num:= numer * p;
if DegreeOfLaurentPolynomial( num )
> pos * a[ pos ] then
qr:= QuotientRemainder( num, (x^pos - 1)^a[pos] );
pol:= pol + tblclasses[i] * qr[1];
num:= qr[2];
fi;
# Store the summand.
denpos:= Position( denoms, [ pos, a[ pos ] ], 0 );
if denpos = fail then
Add( denoms, [ pos, a[ pos ] ] );
Add( numers, tblclasses[i] * num );
else
numers[ denpos ]:= numers[ denpos ] + tblclasses[i] * num;
fi;
fi;
pos:= pos + 1;
od;
fi;
od;
# Now compute the Taylor series for each summand.
for i in [ 1 .. Length( numers ) ] do
num:= CoefficientsOfLaurentPolynomial( numers[i] );
num:= ShiftedCoeffs( num[1], num[2] );
if IsEmpty( num ) then
Unbind( numers[i] );
else
numers[i]:= rec( numer := num,
r := denoms[i][1],
k := denoms[i][2] );
# Replace denominators $(z^r - 1)^k$ by $(1 - z^r)^k$.
if numers[i].k mod 2 = 1 then
numers[i].numer:= AdditiveInverse( numers[i].numer );
fi;
fi;
od;
numers:= Compacted( numers );
# Sort the summands according to descending `r' component,
# and for the same `r', according to descending `k'.
Sort( numers, function( x, y )
return x.r > y.r or ( x.r = y.r and x.k > y.k );
end );
pol:= CoefficientsOfLaurentPolynomial( pol );
pol:= ShiftedCoeffs( pol[1], pol[2] );
# Compute the display string.
# First translate the sum of fractions into a single fraction.
numer:= Zero( x );
denom:= One( x );
denomstring:= "";
denominfo:= [];
rkpairs:= [];
for summand in numers do
rr:= summand.r;
kk:= summand.k;
sumnumer:= UnivariatePolynomial( Rationals, summand.numer )
* denom;
for pair in rkpairs do
if kk <> 0 and pair[1] mod rr = 0 then
min:= Minimum( kk, pair[2] );
sumnumer:= sumnumer / ( 1 - x^rr )^min;
kk:= kk - min;
fi;
od;
if kk <> 0 then
# Blow up the common denominator.
numer:= numer * ( 1 - x^rr )^kk;
denom:= denom * ( 1 - x^rr )^kk;
Add( rkpairs, [ rr, kk ] );
Append( denomstring, "(1-z" );
if 1 < rr then
Add( denomstring, '^' );
Append( denomstring, String(rr) );
fi;
Add( denomstring, ')' );
if 1 < kk then
Add( denomstring, '^' );
Append( denomstring, String(kk) );
fi;
Add( denomstring, '*' );
Append( denominfo, [ rr, kk ] );
fi;
numer:= numer + sumnumer;
od;
if not IsEmpty( pol ) then
numer:= numer + denom * UnivariatePolynomial( Rationals, pol );
fi;
numer:= numer / Size( tbl );
if psi[1] mod 2 = 1 then
numer:= - numer;
fi;
denomstring:= denomstring{ [ 1 .. Length(denomstring)-1] };
ConvertToStringRep( denomstring );
c:= CoefficientsOfLaurentPolynomial( numer );
numerstring:= StringOfUnivariateRationalPolynomialByCoefficients(
Concatenation( ListWithIdenticalEntries( c[2], 0 ), c[1] ), "z" );
# Compute the series.
series:= numer / denom;
#T avoid forming this quotient!
SetIsUnivariateRationalFunction( series, true );
# Set the info record.
SetMolienSeriesInfo( series,
rec( summands := numers,
size := Size( tbl ),
degree := psi[1],
numer := numer,
denom := denom,
denominfo := denominfo,
numerstring := numerstring,
denomstring := denomstring,
ratfun := series
) );
# Return the series.
return series;
end );
#############################################################################
##
#F MolienSeriesWithGivenDenominator( <molser>, <list> )
##
InstallGlobalFunction( MolienSeriesWithGivenDenominator,
function( molser, list )
local info,
denominfo,
x,
one,
denom,
pair,
numer,
c,
numerstring,
denomstring,
rr, kk,
coeffs,
series;
if not HasMolienSeriesInfo( molser ) then
Error( "MolienSeriesInfo must be known for <molser>" );
fi;
info:= MolienSeriesInfo( molser );
# Compute the numerator that belongs to the desired denominator.
list:= Collected( list );
x:= Indeterminate( Rationals );
one:= One( x );
denom:= one;
for pair in list do
denom:= denom * ( one - x^pair[1] )^pair[2];
od;
numer:= denom * info.numer / info.denom;
if not IsUnivariatePolynomial( numer ) then
return fail;
fi;
# Create the strings for numerator and denominator.
c:= CoefficientsOfLaurentPolynomial( numer );
numerstring:= StringOfUnivariateRationalPolynomialByCoefficients(
Concatenation( ListWithIdenticalEntries( c[2], 0 ), c[1] ), "z" );
denomstring:= "";
for pair in Reversed( list ) do
rr:= pair[1];
kk:= pair[2];
Append( denomstring, "(1-z" );
if 1 < rr then
Add( denomstring, '^' );
Append( denomstring, String(rr) );
fi;
Add( denomstring, ')' );
if 1 < kk then
Add( denomstring, '^' );
Append( denomstring, String(kk) );
fi;
Add( denomstring, '*' );
od;
denomstring:= denomstring{ [ 1 .. Length(denomstring)-1] };
ConvertToStringRep( denomstring );
# Create the Molien series object (create the rat. function
# from the given one, without division).
coeffs:= CoefficientsOfUnivariateRationalFunction( info.ratfun );
series:= UnivariateRationalFunctionByExtRepNC( FamilyObj( info.ratfun ),
coeffs[1], coeffs[2], coeffs[3],
IndeterminateNumberOfUnivariateRationalFunction( info.ratfun ) );
SetIsUnivariateRationalFunction( series, true );
#T why is this not automatically maintained?
SetMolienSeriesInfo( series,
rec(
# We need not adjust these components
summands:= info.summands,
size:= info.size,
degree:= info.degree,
# These components are new.
ratfun:= series,
numer:= numer,
denom:= denom,
denominfo := Immutable( list ),
numerstring := numerstring,
denomstring := denomstring ) );
# Return the new series.
return series;
end );
#############################################################################
##
#M ViewObj( <molser> ) . . . . . . . . . . . . . . . . . for a Molien series
#M PrintObj( <molser> ) . . . . . . . . . . . . . . . . for a Molien series
##
ViewMolienSeries := function( molser )
molser:= MolienSeriesInfo( molser );
Print( "( ", molser.numerstring, " ) / ( ", molser.denomstring, " )" );
end;
InstallMethod( ViewObj,
"for a Molien series",
[ IsRationalFunction and IsUnivariateRationalFunction
and HasMolienSeriesInfo ],
ViewMolienSeries );
InstallMethod( PrintObj,
"for a Molien series",
[ IsRationalFunction and IsUnivariateRationalFunction
and HasMolienSeriesInfo ],
ViewMolienSeries );
#############################################################################
##
#F ValueMolienSeries( series, i )
##
InstallGlobalFunction( ValueMolienSeries, function( series, i )
local value;
series:= MolienSeriesInfo( series );
value:= Sum( series.summands,
s -> CoefficientTaylorSeries( s.numer, s.r, s.k, i ), 0 );
# There is a factor $\frac{(-1)^{\psi(1)}}{\|G\|}$.
if series.degree mod 2 = 1 then
value:= AdditiveInverse( value );
fi;
return value / series.size;
end );
#############################################################################
##
#E
|