/* File permut.c. Contains miscellaneous functions performing simple computations with permutations, as follows:
isIdentity: Returns true if a permutation is the identity and false otherwise. Requires on the degree and image fields of the permutation to be filled in.
adjoinInvImage: Adjoins the array invImage of inverse images to a permutation. The array image of images must already be present. For the identity or for an involution, a separate array is not allocated.
leftMultiply: Multiplies a given permutation s on the left by a permutation t (i.e., s is replaced by ts, and t
remains unchanged). */
/* This function may be used to test if a permutation is the identity. It returns true if the permutation is the identity and false otherwise. Only the degree and image fields of the permutation are required. If the permutation lies in a group with known base, the faster function
isIdentityElt should be used instead. */
/* This function may be used to test if a permutation is an involution or is the identity. It returns true if so and false otherwise. Only the degree and image fields of the permutation are required. If the permutation lies in a group with known base, the faster function
isInvolutoryElt should be used instead. */
/* The function pointMovedBy( perm) returns a point moved by the permutation perm. If perm is the identity, the program is terminated with an error
message. */
Unsigned pointMovedBy( const Permutation *const perm)
{ Unsigned pt; for ( pt = 1 ; pt <= perm->degree ; ++pt ) if ( perm->image[pt] != pt ) return pt;
ERROR( "pointMovedBy", "Attempt to find a point moved by identity " "permutation"); return 0; /* silence compiler warning */
}
/* The function adjoinInvImage may be used to adjoin an array of inverse images (invImage) to a permutation. The array image of images must already be present. If the array invImage is already present, the function does nothing. For any involutory permutation, the function
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 by the permutation t. If s contains inverse images initially, they will
be updated. Note that t need not have inverse images. */
/* The function rightMultiplyInv( s, t) multiplies the permutation s on the right by the inverse of the permutation t. If s contains inverse images
initially, they will be updated. Note t must have inverse images. */
/* The function permOrder( perm) returns the order of permutation perm. The order is returned as a long integer. The function returns 0 if the order
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 conjPerm conjugates permutation e to permutation f, that is, 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.