/usr/share/gap/lib/grpmat.gi is in gap-libs 4r7p9-1.
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 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 | #############################################################################
##
#W grpmat.gi GAP Library Frank Celler
##
##
#Y Copyright (C) 1996, 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 the methods for matrix groups.
##
#############################################################################
##
#M KnowsHowToDecompose( <mat-grp> )
##
InstallMethod( KnowsHowToDecompose, "matrix groups",
[ IsMatrixGroup, IsList ], ReturnFalse );
#############################################################################
##
#M DefaultFieldOfMatrixGroup( <mat-grp> )
##
InstallMethod(DefaultFieldOfMatrixGroup,"for a matrix group",[IsMatrixGroup],
function( grp )
local gens,R;
gens:= GeneratorsOfGroup( grp );
if IsEmpty( gens ) then
return Field( One( grp )[1][1] );
else
R:=DefaultScalarDomainOfMatrixList(gens);
if not IsField(R) then
R:=FieldOfMatrixList(gens);
fi;
fi;
return R;
end );
InstallMethod( DefaultFieldOfMatrixGroup,
"for matrix group over the cyclotomics",
[ IsCyclotomicMatrixGroup ],
grp -> Cyclotomics );
InstallMethod( DefaultFieldOfMatrixGroup,
"for a matrix group over an s.c. algebra",
[ IsMatrixGroup and IsSCAlgebraObjCollCollColl ],
grp -> ElementsFamily( ElementsFamily( ElementsFamily(
FamilyObj( grp ) ) ) )!.fullSCAlgebra );
# InstallOtherMethod( DefaultFieldOfMatrixGroup,
# "from source of nice monomorphism",
# [ IsMatrixGroup and HasNiceMonomorphism ],
# grp -> DefaultFieldOfMatrixGroup( Source( NiceMonomorphism( grp ) ) ) );
#T this was illegal,
#T since it assumes that the source is a different object than the
#T original group; if this fails then we run into an infinite recursion!
#############################################################################
##
#M FieldOfMatrixGroup( <mat-grp> )
##
InstallMethod( FieldOfMatrixGroup,
"for a matrix group",
[ IsMatrixGroup ],
function( grp )
local gens;
gens:= GeneratorsOfGroup( grp );
if IsEmpty( gens ) then
return Field( One( grp )[1][1] );
else
return FieldOfMatrixList(gens);
fi;
end );
#############################################################################
##
#M DimensionOfMatrixGroup( <mat-grp> )
##
InstallMethod( DimensionOfMatrixGroup, "from generators",
[ IsMatrixGroup and HasGeneratorsOfGroup ],
function( grp )
if not IsEmpty( GeneratorsOfGroup( grp ) ) then
return Length( GeneratorsOfGroup( grp )[ 1 ] );
else
TryNextMethod();
fi;
end );
InstallMethod( DimensionOfMatrixGroup, "from one",
[ IsMatrixGroup and HasOne ], 1,
grp -> Length( One( grp ) ) );
# InstallOtherMethod( DimensionOfMatrixGroup,
# "from source of nice monomorphism",
# [ IsMatrixGroup and HasNiceMonomorphism ],
# grp -> DimensionOfMatrixGroup( Source( NiceMonomorphism( grp ) ) ) );
#T this was illegal,
#T since it assumes that the source is a different object than the
#T original group; if this fails then we run into an infinite recursion!
#T why not delegate to `Representative' instead of installing
#T different methods?
#############################################################################
##
#M One( <mat-grp> )
##
InstallOtherMethod( One,
"for matrix group, call `IdentityMat'",
[ IsMatrixGroup ],
grp -> ImmutableMatrix(DefaultFieldOfMatrixGroup(grp),
IdentityMat( DimensionOfMatrixGroup( grp ),
DefaultFieldOfMatrixGroup( grp ) ) ));
#############################################################################
##
#M TransposedMatrixGroup( <G> ) . . . . . . . . .transpose of a matrix group
##
InstallMethod( TransposedMatrixGroup,
[ IsMatrixGroup ],
function( G )
local T;
T := GroupByGenerators( List( GeneratorsOfGroup( G ), TransposedMat ),
One( G ) );
#T avoid calling `One'!
UseIsomorphismRelation( G, T );
SetTransposedMatrixGroup( T, G );
return T;
end );
#############################################################################
##
#F NaturalActedSpace( [<G>,]<acts>,<veclist> )
##
InstallGlobalFunction(NaturalActedSpace,function(arg)
local f,i,j,veclist,acts;
veclist:=arg[Length(arg)];
acts:=arg[Length(arg)-1];
if Length(arg)=3 and IsGroup(arg[1]) and acts=GeneratorsOfGroup(arg[1]) then
f:=DefaultFieldOfMatrixGroup(arg[1]);
else
f:=FieldOfMatrixList(acts);
fi;
for i in veclist do
for j in i do
if not j in f then
f:=ClosureField(f,j);
fi;
od;
od;
return f^Length(veclist[1]);
end);
InstallGlobalFunction(BasisVectorsForMatrixAction,function(G)
local F, gens, evals, espaces, is, ise, gen, i, j,module,list,ind,vecs,mins;
F := DefaultFieldOfMatrixGroup(G);
# `Cyclotomics', the default field for rational matrix groups causes
# problems with a subsequent factorization
if IsIdenticalObj(F,Cyclotomics) then
# cyclotomics really is too large here
F:=FieldOfMatrixGroup(G);
fi;
list:=[];
if false and ValueOption("nosubmodules")=fail and IsFinite(F) then
module:=GModuleByMats(GeneratorsOfGroup(G),F);
if not MTX.IsIrreducible(module) then
mins:=Filtered(MTX.BasesCompositionSeries(module),x->Length(x)>0);
if Length(mins)<=5 then
mins:=MTX.BasesMinimalSubmodules(module);
else
if Length(mins)>7 then
mins:=mins{Set(List([1..7],x->Random([1..Length(mins)])))};
fi;
fi;
# now get potential basis vectors from submodules
for i in mins do
ind:=MTX.InducedActionSubmodule(module,i);
vecs:=BasisVectorsForMatrixAction(Group(ind.generators):nosubmodules);
Append(list,vecs*i);
od;
fi;
fi;
# use Murray/OBrien method
gens := ShallowCopy( GeneratorsOfGroup( G ) ); # Need copy for mutability
while Length( gens ) < 10 do
Add( gens, PseudoRandom( G ) );
od;
evals := []; espaces := [];
for gen in gens do
evals := Concatenation( evals, GeneralisedEigenvalues(F,gen) );
espaces := Concatenation( espaces, GeneralisedEigenspaces(F,gen) );
od;
is:=[];
# the `AddSet' wil automatically put small spaces first
for i in [1..Length(espaces)] do
for j in [i+1..Length(espaces)] do
ise:=Intersection(espaces[i],espaces[j]);
if Dimension(ise)>0 and not ise in is then
Add(is,ise);
fi;
od;
od;
Append(list,Concatenation(List(is,i->BasisVectors(Basis(i)))));
return list;
end);
#############################################################################
##
#F DoSparseLinearActionOnFaithfulSubset( <G>,<act>,<sort> )
##
## computes a linear action of the matrix group <G> on the span of the
## standard basis. The action <act> must be `OnRight', or
## `OnLines'. The calculation of further orbits stops, once a basis for the
## underlying space has been reached, often giving a smaller degree
## permutation representation.
## The boolean <sort> indicates, whether the domain will be sorted.
BindGlobal("DoSparseLinearActionOnFaithfulSubset",
function(G,act,sort)
local field, dict, acts, start, j, zerov, zero, dim, base, partbas, heads,
orb, delay, permimg, maxlim, starti, ll, ltwa, img, v, en, p, kill,
i, lo, imgs, xset, hom, R;
field:=DefaultFieldOfMatrixGroup(G);
#dict := NewDictionary( One(G)[1], true , field ^ Length( One( G ) ) );
acts:=GeneratorsOfGroup(G);
if Length(acts)=0 then
start:=One(G);
elif act=OnRight then
start:=Concatenation(BasisVectorsForMatrixAction(G),One(G));
elif act=OnLines then
j:=One(G);
start:=Concatenation(List(BasisVectorsForMatrixAction(G),
x->OnLines(x,j)),j);
else
Error("illegal action");
fi;
zerov:=Zero(start[1]);
zero:=zerov[1];
dim:=Length(zerov);
base:=[]; # elements of start which are a base in the permgrp sense
partbas:=[]; # la basis of space spanned so far
heads:=[];
orb:=[];
delay:=[]; # Vectors we delay later, because they are potentially very
# expensive.
permimg:=List(acts,i->[]);
maxlim:=200000;
starti:=1;
while Length(partbas)<dim or
(act=OnLines and not OnLines(Sum(base),One(G)) in orb) do
Info(InfoGroup,2,"dim=",Length(partbas)," ",
"|orb|=",Length(orb));
if Length(partbas)=dim and act=OnLines then
Info(InfoGroup,2,"add sum for projective action");
img:=OnLines(Sum(base),One(G));
else
if starti>Length(start) then
Sort(delay);
for i in delay do
Add(start,i[2]);
od;
maxlim:=maxlim*100;
Info(InfoGroup,2,
"original pool exhausted, use delayed. maxlim=",maxlim);
delay:=[];
fi;
ll:=Length(orb);
ltwa:=Maximum(maxlim,(ll+1)*20);
img:=start[starti];
v:=ShallowCopy(img);
for j in [ 1 .. Length( heads ) ] do
en:=v[heads[j]];
if en <> zero then
AddRowVector( v, partbas[j], - en );
fi;
od;
fi;
if not IsZero(v) then
dict := NewDictionary( v, true , field ^ Length( One( G ) ) );
# force `img' over field
if (Size(field)=2 and not IsGF2VectorRep(img)) or
(Size(field)>2 and Size(field)<=256 and not (Is8BitVectorRep(img)
and Q_VEC8BIT(img)=Size(field))) then
img:=ShallowCopy(img);
ConvertToVectorRep(img,Size(field));
fi;
Add(orb,img);
p:=Length(orb);
AddDictionary(dict,img,Length(orb));
kill:=false;
# orbit algorithm with image keeper
while p<=Length(orb) do
i:=1;
while i<=Length(acts) do
img := act(orb[p],acts[i]);
v:=LookupDictionary(dict,img);
if v=fail then
if Length(orb)>ltwa then
Info(InfoGroup,2,"Very long orbit, delay");
Add(delay,[Length(orb)-ll,orb[ll+1]]);
kill:=true;
for p in [ll+1..Length(orb)] do
Unbind(orb[p]);
for i in [1..Length(acts)] do
Unbind(permimg[i][p]);
od;
od;
i:=Length(acts)+1;
p:=Length(orb)+1;
else
Add(orb,img);
AddDictionary(dict,img,Length(orb));
permimg[i][p]:=Length(orb);
fi;
else
permimg[i][p]:=v;
fi;
i:=i+1;
od;
p:=p+1;
od;
fi;
starti:=starti+1;
if not kill then
# break criterion: do we actually *want* more points?
i:=ll+1;
lo:=Length(orb);
while i<=lo do
v:=ShallowCopy(orb[i]);
for j in [ 1 .. Length( heads ) ] do
en:=v[heads[j]];
if en <> zero then
AddRowVector( v, partbas[j], - en );
fi;
od;
if v<>zerov then
Add(base,orb[i]);
Add(partbas,ShallowCopy(orb[i]));
TriangulizeMat(partbas);
heads:=List(partbas,PositionNonZero);
if Length(partbas)>=dim then
# full dimension reached
i:=lo;
fi;
fi;
i:=i+1;
od;
fi;
od;
# Das Dictionary hat seine Schuldigkeit getan
Unbind(dict);
Info(InfoGroup,1,"found degree=",Length(orb));
# any asymptotic argument is pointless here: In practice sorting is much
# quicker than image computation.
if sort then
imgs:=Sortex(orb); # permutation we must apply to the points to be sorted.
# was: permimg:=List(permimg,i->OnTuples(Permuted(i,imgs),imgs));
# run in loop to save memory
for i in [1..Length(permimg)] do
permimg[i]:=Permuted(permimg[i],imgs);
permimg[i]:=OnTuples(permimg[i],imgs);
od;
fi;
#check routine
# Print("check!\n");
# for p in [1..Length(orb)] do
# for i in [1..Length(acts)] do
# img:=act(orb[p],acts[i]);
# v:=LookupDictionary(dict,img);
# if v<>permimg[i][p] then
# Error("wrong!");
# fi;
# od;
# od;
# Error("hier");
for i in [1..Length(permimg)] do
permimg[i]:=PermList(permimg[i]);
od;
if fail in permimg then
Error("not permutations");
fi;
xset:=ExternalSet( G, orb, acts, acts, act);
# when acting projectively the sum of the base vectors must be part of the
# base -- that will guarantee that we can distinguish diagonal from scalar
# matrices.
if act=OnLines then
if Length(base)<=dim then
Add(base,OnLines(Sum(base),One(G)));
fi;
fi;
# We know that the points corresponding to `start' give a base of the
# vector space. We can use
# this to get images quickly, using a stabilizer chain in the permutation
# group
SetBaseOfGroup( xset, base );
xset!.basePermImage:=List(base,b->PositionCanonical(orb,b));
hom := ActionHomomorphism( xset,"surjective" );
if act <> OnLines then
SetIsInjective(hom, true); # we know by construction that it is injective.
fi;
R:=Group(permimg,()); # `permimg' arose from `PermList'
SetBaseOfGroup(R,xset!.basePermImage);
if HasSize(G) and act=OnRight then
SetSize(R,Size(G)); # faithful action
fi;
SetRange(hom,R);
SetImagesSource(hom,R);
SetMappingGeneratorsImages(hom,[acts,permimg]);
# p:=RUN_IN_GGMBI; # no niceomorphism translation here
# RUN_IN_GGMBI:=true;
# SetAsGroupGeneralMappingByImages ( hom, GroupHomomorphismByImagesNC
# ( G, R, acts, permimg ) );
#
# SetFilterObj( hom, IsActionHomomorphismByBase );
# RUN_IN_GGMBI:=p;
base:=ImmutableMatrix(field,base);
SetLinearActionBasis(hom,base);
return hom;
end);
#############################################################################
##
#M IsomorphismPermGroup( <mat-grp> )
##
BindGlobal( "NicomorphismOfGeneralMatrixGroup", function( grp,canon,sort )
local nice,img,module,b;
b:=SeedFaithfulAction(grp);
if canon=false and b<>fail then
Info(InfoGroup,1,"using predefined action seed");
# the user (or code) gave a seed for a faithful action
nice:=MultiActionsHomomorphism(grp,b.points,b.ops);
# don't be too clever if it is a matrix over a non-field domain
elif not IsField(DefaultFieldOfMatrixGroup(grp)) then
Info(InfoGroup,1,"over nonfield");
#nice:=ActionHomomorphism( grp,AsSSortedList(grp),OnRight,"surjective");
if canon then
nice:=SortedSparseActionHomomorphism( grp, One( grp ) );
SetIsCanonicalNiceMonomorphism(nice,true);
else
nice:=SparseActionHomomorphism( grp, One( grp ) );
nice:=nice*SmallerDegreePermutationRepresentation(Image(nice));
fi;
elif IsFinite(grp) and ( (HasIsNaturalGL(grp) and IsNaturalGL(grp)) or
(HasIsNaturalSL(grp) and IsNaturalSL(grp)) ) then
# for full GL/SL we get never better than the full vector space as domain
Info(InfoGroup,1,"is GL/SL");
return NicomorphismFFMatGroupOnFullSpace(grp);
elif canon then
Info(InfoGroup,1,"canonical niceo");
nice:=SortedSparseActionHomomorphism( grp, One( grp ) );
SetIsCanonicalNiceMonomorphism(nice,true);
else
Info(InfoGroup,1,"act to find base");
nice:=DoSparseLinearActionOnFaithfulSubset( grp, OnRight, sort);
SetIsSurjective( nice, true );
img:=Image(nice);
if not IsFinite(DefaultFieldOfMatrixGroup(grp)) or
Length(GeneratorsOfGroup(grp))=0 then
module:=fail;
else
module:=GModuleByMats(GeneratorsOfGroup(grp),DefaultFieldOfMatrixGroup(grp));
fi;
#improve,
# try hard, unless absirr and orbit lengths at least 1/q^2 of domain --
#then we expect improvements to be of little help
if module<>fail and not (NrMovedPoints(img)>=
Size(DefaultFieldOfMatrixGroup(grp))^(Length(One(grp))-2)
and MTX.IsAbsolutelyIrreducible(module)) then
nice:=nice*SmallerDegreePermutationRepresentation(img);
else
nice:=nice*SmallerDegreePermutationRepresentation(img:cheap:=true);
fi;
fi;
SetIsInjective( nice, true );
return nice;
end );
InstallMethod( IsomorphismPermGroup,"matrix group", true,
[ IsMatrixGroup ], 10,
function(G)
local map;
if HasNiceMonomorphism(G) and IsPermGroup(Range(NiceMonomorphism(G))) then
map:=NiceMonomorphism(G);
if IsIdenticalObj(Source(map),G) then
return map;
fi;
return GeneralRestrictedMapping(map,G,Image(map,G));
else
if not HasIsFinite(G) then
Info(InfoWarning,1,
"IsomorphismPermGroup: The group is not known to be finite");
fi;
map:=NicomorphismOfGeneralMatrixGroup(G,false,false);
SetNiceMonomorphism(G,map);
return map;
fi;
end);
#############################################################################
##
#M NiceMonomorphism( <mat-grp> )
##
InstallMethod( NiceMonomorphism,"use NicomorphismOfGeneralMatrixGroup",
[ IsMatrixGroup and IsFinite ],
G->NicomorphismOfGeneralMatrixGroup(G,false,false));
#############################################################################
##
#M CanonicalNiceMonomorphism( <mat-grp> )
##
InstallMethod( CanonicalNiceMonomorphism, [ IsMatrixGroup and IsFinite ],
G->NicomorphismOfGeneralMatrixGroup(G,true,true));
#############################################################################
##
#F ProjectiveActionHomomorphismMatrixGroup(<G>)
##
InstallGlobalFunction(ProjectiveActionHomomorphismMatrixGroup,
G->DoSparseLinearActionOnFaithfulSubset(G,OnLines,true));
#############################################################################
##
#M GeneratorsSmallest(<finite matrix group>)
##
## This algorithm takes <bas>:=the points corresponding to the standard basis
## and then computes a minimal generating system for the permutation group
## wrt. this base <bas>. As lexicographical comparison of matrices is
## compatible with comparison of base images wrt. the standard base this
## also is the smallest (irredundant) generating set of the matrix group!
InstallMethod(GeneratorsSmallest,"matrix group via niceo",
[IsMatrixGroup and IsFinite],
function(G)
local gens,s,dom,mon,no;
mon:=CanonicalNiceMonomorphism(G);
no:=Image(mon,G);
dom:=UnderlyingExternalSet(mon);
s:=StabChainOp(no,rec(base:=List(BaseOfGroup(dom),
i->Position(HomeEnumerator(dom),i))));
# call the recursive function to do the work
gens:= SCMinSmaGens( no, s, [], One( no ), true ).gens;
SetMinimalStabChain(G,s);
return List(gens,i->PreImagesRepresentative(mon,i));
end);
#############################################################################
##
#M MinimalStabChain(<finite matrix group>)
##
## used for cosets where we probably won't need the smallest generators
InstallOtherMethod(MinimalStabChain,"matrix group via niceo",
[IsMatrixGroup and IsFinite],
function(G)
local s,dom,mon,no;
mon:=CanonicalNiceMonomorphism(G);
no:=Image(mon,G);
dom:=UnderlyingExternalSet(mon);
s:=StabChainOp(no,rec(base:=List(BaseOfGroup(dom),
i->Position(HomeEnumerator(dom),i))));
# call the recursive function to do the work
SCMinSmaGens( no, s, [], One( no ), false );
return s;
end);
#############################################################################
##
#M LargestElementGroup(<finite matrix group>)
##
InstallOtherMethod(LargestElementGroup,"matrix group via niceo",
[IsMatrixGroup and IsFinite],
function(G)
local s,dom,mon, img;
mon:=CanonicalNiceMonomorphism(G);
dom:=UnderlyingExternalSet(mon);
img:= Image( mon, G );
s:=StabChainOp( img, rec(base:=List(BaseOfGroup(dom),
i->Position(HomeEnumerator(dom),i))));
# call the recursive function to do the work
s:= LargestElementStabChain( s, One( img ) );
return PreImagesRepresentative(mon,s);
end);
#############################################################################
##
#M CanonicalRightCosetElement(<finite matrix group>,<rep>)
##
InstallMethod(CanonicalRightCosetElement,"finite matric group",IsCollsElms,
[IsMatrixGroup and IsFinite,IsMatrix],
function(U,e)
local mon,dom,S,o,oimgs,p,i,g;
mon:=CanonicalNiceMonomorphism(U);
dom:=UnderlyingExternalSet(mon);
S:=StabChainOp(Image(mon,U),rec(base:=List(BaseOfGroup(dom),
i->Position(HomeEnumerator(dom),i))));
dom:=HomeEnumerator(dom);
while not IsEmpty(S.generators) do
o:=dom{S.orbit}; # the relevant vectors
oimgs:=List(o,i->i*e); #their images
# find the smallest image
p:=1;
for i in [2..Length(oimgs)] do
if oimgs[i]<oimgs[p] then
p:=i;
fi;
od;
# the point corresponding to the preimage
p:=S.orbit[p];
# now find an element that maps S.orbit[1] to p;
g:=S.identity;
while S.orbit[1]^g<>p do
g:=LeftQuotient(S.transversal[p/g],g);
od;
# change by corresponding matrix element
e:=PreImagesRepresentative(mon,g)*e;
S:=S.stabilizer;
od;
return e;
end);
#############################################################################
##
#M ViewObj( <matgrp> )
##
InstallMethod( ViewObj,
"for a matrix group with stored generators",
[ IsMatrixGroup and HasGeneratorsOfGroup ],
function(G)
local gens;
gens:=GeneratorsOfGroup(G);
if Length(gens)>0 and Length(gens)*
Length(gens[1])^2 / GAPInfo.ViewLength > 8 then
Print("<matrix group");
if HasSize(G) then
Print(" of size ",Size(G));
fi;
Print(" with ",Length(GeneratorsOfGroup(G)),
" generators>");
else
Print("Group(");
ViewObj(GeneratorsOfGroup(G));
Print(")");
fi;
end);
#############################################################################
##
#M ViewObj( <matgrp> )
##
InstallMethod( ViewObj,"for a matrix group",
[ IsMatrixGroup ],
function(G)
local d;
d:=DimensionOfMatrixGroup(G);
Print("<group of ",d,"x",d," matrices");
if HasSize(G) then
Print(" of size ",Size(G));
fi;
if HasFieldOfMatrixGroup(G) then
Print(" over ",FieldOfMatrixGroup(G),">");
elif HasDefaultFieldOfMatrixGroup(G) then
Print(" over ",DefaultFieldOfMatrixGroup(G),">");
else
Print(" in characteristic ",Characteristic(One(G)),">");
fi;
end);
#############################################################################
##
#M PrintObj( <matgrp> )
##
InstallMethod( PrintObj,"for a matrix group",
[ IsMatrixGroup ],
function(G)
local l;
l:=GeneratorsOfGroup(G);
if Length(l)=0 then
Print("Group([],",One(G),")");
else
Print("Group(",l,")");
fi;
end);
#############################################################################
##
#M IsGeneralLinearGroup(<G>)
##
InstallMethod(IsGeneralLinearGroup,"try natural",[IsMatrixGroup],
function(G)
if HasIsNaturalGL(G) and IsNaturalGL(G) then
return true;
else
TryNextMethod();
fi;
end);
#############################################################################
##
#M IsSubgroupSL
##
InstallMethod(IsSubgroupSL,"determinant test for generators",
[IsMatrixGroup and HasGeneratorsOfGroup],
G -> ForAll(GeneratorsOfGroup(G),i->IsOne(DeterminantMat(i))) );
#############################################################################
##
#M <mat> in <G> . . . . . . . . . . . . . . . . . . . . is form invariant?
##
InstallMethod( \in, "respecting bilinear form", IsElmsColls,
[ IsMatrix, IsFullSubgroupGLorSLRespectingBilinearForm ],
NICE_FLAGS, # this method is better than the one using a nice monom.
function( mat, G )
local inv;
if not IsSubset( FieldOfMatrixGroup( G ), FieldOfMatrixList( [ mat ] ) )
or ( IsSubgroupSL( G ) and not IsOne( DeterminantMat( mat ) ) ) then
return false;
fi;
inv:= InvariantBilinearForm(G).matrix;
return mat * inv * TransposedMat( mat ) = inv;
end );
InstallMethod( \in, "respecting sesquilinear form", IsElmsColls,
[ IsMatrix, IsFullSubgroupGLorSLRespectingSesquilinearForm ],
NICE_FLAGS, # this method is better than the one using a nice monom.
function( mat, G )
local pow, inv;
if not IsSubset( FieldOfMatrixGroup( G ), FieldOfMatrixList( [ mat ] ) )
or ( IsSubgroupSL( G ) and not IsOne( DeterminantMat( mat ) ) ) then
return false;
fi;
pow:= RootInt( Size( FieldOfMatrixGroup( G ) ) );
inv:= InvariantSesquilinearForm(G).matrix;
return mat * inv * List( TransposedMat( mat ),
row -> List( row, x -> x^pow ) )
= inv;
end );
#############################################################################
##
#M IsGeneratorsOfMagmaWithInverses( <matlist> )
##
## Check that all entries are matrices of the same dimension, and that they
## are all invertible.
##
InstallMethod( IsGeneratorsOfMagmaWithInverses,
"for a list of matrices",
[ IsRingElementCollCollColl ],
function( matlist )
local dims;
if ForAll( matlist, IsMatrix ) then
dims:= DimensionsMat( matlist[1] );
return dims[1] = dims[2] and
ForAll( matlist, mat -> DimensionsMat( mat ) = dims ) and
ForAll( matlist, mat -> Inverse( mat ) <> fail );
fi;
return false;
end );
#############################################################################
##
#M GroupWithGenerators( <mats> )
#M GroupWithGenerators( <mats>, <id> )
##
InstallMethod( GroupWithGenerators,
"list of matrices",
[ IsFFECollCollColl ],
#T ???
function( gens )
local G,fam,typ,f;
fam:=FamilyObj(gens);
if IsFinite(gens) then
if not IsBound(fam!.defaultFinitelyGeneratedGroupType) then
fam!.defaultFinitelyGeneratedGroupType:=
NewType(fam,IsGroup and IsAttributeStoringRep
and HasGeneratorsOfMagmaWithInverses
and IsFinitelyGeneratedGroup);
fi;
typ:=fam!.defaultFinitelyGeneratedGroupType;
else
TryNextMethod();
fi;
f:=DefaultScalarDomainOfMatrixList(gens);
gens:=List(Immutable(gens),i->ImmutableMatrix(f,i));
G:=rec();
ObjectifyWithAttributes(G,typ,GeneratorsOfMagmaWithInverses,AsList(gens));
if IsField(f) then SetDefaultFieldOfMatrixGroup(G,f);fi;
return G;
end );
InstallMethod( GroupWithGenerators,
"list of matrices with identity", IsCollsElms,
[ IsFFECollCollColl,IsMultiplicativeElementWithInverse and IsFFECollColl],
function( gens, id )
local G,fam,typ,f;
fam:=FamilyObj(gens);
if IsFinite(gens) then
if not IsBound(fam!.defaultFinitelyGeneratedGroupWithOneType) then
fam!.defaultFinitelyGeneratedGroupWithOneType:=
NewType(fam,IsGroup and IsAttributeStoringRep
and HasGeneratorsOfMagmaWithInverses
and IsFinitelyGeneratedGroup and HasOne);
fi;
typ:=fam!.defaultFinitelyGeneratedGroupWithOneType;
else
TryNextMethod();
fi;
f:=DefaultScalarDomainOfMatrixList(gens);
gens:=List(Immutable(gens),i->ImmutableMatrix(f,i));
id:=ImmutableMatrix(f,id);
G:=rec();
ObjectifyWithAttributes(G,typ,GeneratorsOfMagmaWithInverses,AsList(gens),
One,id);
if IsField(f) then SetDefaultFieldOfMatrixGroup(G,f);fi;
return G;
end );
#############################################################################
##
#M IsConjugatorIsomorphism( <hom> )
##
InstallMethod( IsConjugatorIsomorphism,
"for a matrix group general mapping",
[ IsGroupGeneralMapping ], 1,
# There is no filter to test whether source and range of a homomorphism
# are matrix groups.
# So we have to test explicitly and make this method
# higher ranking than the default one in `ghom.gi'.
function( hom )
local s, r, dim, Fs, Fr, F, genss, rep;
s:= Source( hom );
if not IsMatrixGroup( s ) then
TryNextMethod();
elif not ( IsGroupHomomorphism( hom ) and IsBijective( hom ) ) then
return false;
elif IsEndoGeneralMapping( hom ) and IsInnerAutomorphism( hom ) then
return true;
fi;
r:= Range( hom );
# Check whether dimensions and fields of matrix entries are compatible.
dim:= DimensionOfMatrixGroup( s );
if dim <> DimensionOfMatrixGroup( r ) then
return false;
fi;
Fs:= DefaultFieldOfMatrixGroup( s );
Fr:= DefaultFieldOfMatrixGroup( r );
if FamilyObj( Fs ) <> FamilyObj( Fr ) then
return false;
fi;
if not ( IsField( Fs ) and IsField( Fr ) ) then
TryNextMethod();
fi;
F:= ClosureField( Fs, Fr );
if not IsFinite( F ) then
TryNextMethod();
fi;
# Compute a conjugator in the full linear group.
genss:= GeneratorsOfGroup( s );
rep:= RepresentativeAction( GL( dim, Size( F ) ), genss, List( genss,
i -> ImagesRepresentative( hom, i ) ), OnTuples );
# Return the result.
if rep <> fail then
Assert( 1, ForAll( genss, i -> Image( hom, i ) = i^rep ) );
SetConjugatorOfConjugatorIsomorphism( hom, rep );
return true;
else
return false;
fi;
end );
#############################################################################
##
#F AffineActionByMatrixGroup( <M> )
##
InstallGlobalFunction( AffineActionByMatrixGroup, function(M)
local gens,V, G, A;
# build the vector space
V := DefaultFieldOfMatrixGroup( M ) ^ DimensionOfMatrixGroup( M );
# the linear part
G := Action( M, V );
# the translation part
gens:=List( Basis( V ), b -> Permutation( b, V, \+ ) );
# construct the affine group
A := GroupByGenerators(Concatenation(gens,GeneratorsOfGroup( G )));
SetSize( A, Size( M ) * Size( V ) );
if HasName( M ) then
SetName( A, Concatenation( String( Size( DefaultFieldOfMatrixGroup( M ) ) ),
"^", String( DimensionOfMatrixGroup( M ) ), ":",
Name( M ) ) );
fi;
# the !.matrixGroup component is not documented!
A!.matrixGroup := M;
#T what the hell shall this misuse be good for?
return A;
end );
#############################################################################
##
## n. Code needed for ``blow up isomorphisms'' of matrix groups
##
#############################################################################
##
#F IsBlowUpIsomorphism
##
## We define this filter for additive as well as for multiplicative
## general mappings,
## so the ``respectings'' of the mappings must be set explicitly.
##
DeclareFilter( "IsBlowUpIsomorphism", IsSPGeneralMapping and IsBijective );
#############################################################################
##
#M ImagesRepresentative( <iso>, <mat> ) . . . . . for a blow up isomorphism
##
InstallMethod( ImagesRepresentative,
"for a blow up isomorphism, and a matrix in the source",
FamSourceEqFamElm,
[ IsBlowUpIsomorphism, IsMatrix ],
function( iso, mat )
return BlownUpMat( Basis( iso ), mat );
end );
#############################################################################
##
#M PreImagesRepresentative( <iso>, <mat> ) . . . for a blow up isomorphism
##
InstallMethod( PreImagesRepresentative,
"for a blow up isomorphism, and a matrix in the range",
FamRangeEqFamElm,
[ IsBlowUpIsomorphism, IsMatrix ],
function( iso, mat )
local B,
d,
n,
Binv,
preim,
i,
row,
j,
submat,
elm,
k;
B:= Basis( iso );
d:= Length( B );
n:= Length( mat ) / d;
if not IsInt( n ) then
return fail;
fi;
Binv:= List( B, Inverse );
preim:= [];
for i in [ 1 .. n ] do
row:= [];
for j in [ 1 .. n ] do
# Compute the entry in the `i'-th row in the `j'-th column.
submat:= mat{ [ 1 .. d ] + (i-1)*d }{ [ 1 .. d ] + (j-1)*d };
elm:= Binv[1] * LinearCombination( B, submat[1] );
# Check that the matrix is in the image of the isomorphism.
for k in [ 2 .. d ] do
if B[k] * elm <> LinearCombination( B, submat[k] ) then
return fail;
fi;
od;
row[j]:= elm;
od;
preim[i]:= row;
od;
return preim;
end );
#############################################################################
##
#F BlowUpIsomorphism( <matgrp>, <B> )
##
InstallGlobalFunction( "BlowUpIsomorphism", function( matgrp, B )
local gens,
preimgs,
imgs,
range,
iso;
gens:= GeneratorsOfGroup( matgrp );
if IsEmpty( gens ) then
preimgs:= [ One( matgrp ) ];
imgs:= [ IdentityMat( Length( preimgs[1] ) * Length( B ),
LeftActingDomain( UnderlyingLeftModule( B ) ) ) ];
range:= GroupByGenerators( [], imgs[1] );
else
preimgs:= gens;
imgs:= List( gens, mat -> BlownUpMat( B, mat ) );
range:= GroupByGenerators( imgs );
fi;
iso:= rec();
ObjectifyWithAttributes( iso,
NewType( GeneralMappingsFamily( FamilyObj( preimgs[1] ),
FamilyObj( imgs[1] ) ),
IsBlowUpIsomorphism
and IsGroupGeneralMapping
and IsAttributeStoringRep ),
Source, matgrp,
Range, range,
Basis, B );
return iso;
end );
#############################################################################
##
## stuff concerning invariant forms of matrix groups
#T add code for computing invariant forms,
#T and transforming matrices for normalizing the forms
#T (which is useful, e.g., for embedding the groups from AtlasRep into
#T the unitary, symplectic, or orthogonal groups in question)
##
#############################################################################
##
#M InvariantBilinearForm( <matgrp> )
##
InstallMethod( InvariantBilinearForm,
"for a matrix group with known `InvariantQuadraticForm'",
[ IsMatrixGroup and HasInvariantQuadraticForm ],
function( matgrp )
local Q;
Q:= InvariantQuadraticForm( matgrp ).matrix;
return rec( matrix:= ( Q + TransposedMat( Q ) ) );
end );
#############################################################################
##
#E
|