/* This function may be used to test if a permutation is the identity. It returnstrueifthepermutationistheidentityandfalseotherwise.Only thedegreeandimagefieldsofthepermutationarerequired.Ifthe permutationliesinagroupwithknownbase,thefasterfunction
isIdentityElt should be used instead. */
/* This function may be used to test if a permutation is an involution or is theidentity.Itreturnstrueifsoandfalseotherwise.Only thedegreeandimagefieldsofthepermutationarerequired.Ifthe permutationliesinagroupwithknownbase,thefasterfunction
isInvolutoryElt should be used instead. */
/* The function adjoinInvImage may be used to adjoin an array of inverse images(invImage)toapermutation.Thearrayimageofimagesmust alreadybepresent.IfthearrayinvImageisalreadypresent,the functiondoesnothing.Foranyinvolutorypermutation,thefunction
merely sets the pointer invImage to point to the existing array image. */
void adjoinInvImage(
Permutation *s) /* The permutation group (base and sgs known). */
{ Unsigned degree = s->degree; Unsigned pt;
/* Check if inverse image array already exists? If so, do nothing. */ if ( ! s->invImage ) {
/* Allocate and construct the array of inverse images. */
s->invImage = allocIntArrayDegree(); for ( pt = 1 ; pt <= degree ; ++pt )
s->invImage[s->image[pt]] = pt;
s->invImage[degree+1] = 0;
/* Check if the permutation is an involution, adjust if so. */ for ( pt = 1 ; pt <= degree && s->image[pt] == s->invImage[pt] ; ++pt )
; if ( pt > degree ) {
freeIntArrayDegree( s->invImage);
s->invImage = s->image;
}
}
}
/* The function rightMultiply( s, t) multiplies the permutation s on the right bythepermutationt.Ifscontainsinverseimagesinitially,theywill
be updated. Note that t need not have inverse images. */
/* The function rightMultiplyInv( s, t) multiplies the permutation s on the rightbytheinverseofthepermutationt.Ifscontainsinverseimages
initially, they will be updated. Note t must have inverse images. */
/* The function permOrder( perm) returns the order of permutation perm. The orderisreturnedasalonginteger.Thefunctionreturns0iftheorder
exceeds ULONG_MAX. */
/* The function raisePermToPower replaces a given permutation by a designated
power of that permutation. INVERSE PERMUTATIONS ARE NOT HANDLED. */
void raisePermToPower(
Permutation *const perm, /* The permutation to be replaced. */ constlong power) /* Upon return, perm has been replaced by
perm^power. */
{ Unsigned i, pt, img, imgIndex, cycleLen;
UnsignedS *cycle = allocIntArrayDegree(); char *found = allocBooleanArrayDegree();
/* Initialize found[pt] to false for all points pt. When the cycle of pt has
been constructed, found[pt] will be set to true. */ for ( pt = 1 ; pt <= perm->degree ; ++pt )
found[pt] = FALSE;
for ( pt = 1 ; pt <= perm->degree ; ++pt ) if ( !found[pt] ) {
/* Construct the cycle of point pt. */
cycleLen = 0;
img = pt; do {
cycle[cycleLen++] = img;
found[img] = TRUE;
img = perm->image[img];
} while( img != pt );
/* Replace perm by perm^power on cycle just constructed. */ for ( i = 0 ; i < cycleLen ; ++i ) {
imgIndex = (i + power) % cycleLen;
perm->image[cycle[i]] = cycle[imgIndex]; if ( perm->invImage )
perm->invImage[cycle[imgIndex]] = cycle[i];
}
}
/* Check if the power is an involution. */ if ( isInvolution(perm) && perm->invImage != perm->image ) {
freeIntArrayDegree( perm->invImage);
perm->invImage = perm->image;
}
/* This function returns a new permutation mapping given sequence of
integers to another. */
Permutation *permMapping( constUnsigned degree, /* The degree of the new permutation.*/ const UnsignedS seq1[], /* The first sequence (must have len = degree). */ const UnsignedS seq2[]) /* The second sequence (must have len = degree. */
{ Unsigned i;
Permutation *newPerm = newUndefinedPerm( degree);
for ( i = 1 ; i <= degree ; ++i )
newPerm->image[seq1[i]] = seq2[i];
adjoinInvImage( newPerm);
/* The function checkConjugacy( e, f, conjPerm) returns true if permutation conjPermconjugatespermutationetopermutationf,thatis,if
e ^ conjPerm = f, or equivalently, e * conjPerm = conjPerm * f. */
BOOLEAN checkConjugacy( const Permutation *const e, const Permutation *const f, const Permutation *const conjPerm)
{ int pt;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.