/* File new.c. Contains functions to create new objects and delete objects socreated.Actualallocationofmemoryishandledbyinvokingfunctions fromstorage.c.Thefunctionsincludedhereare:
/* This function creates a new partition stack of specified degree and initializesittoastackofheight1inwhichthetop(andonly)
partition is trivial. It returns a pointer to the new partition stack. */
PartitionStack *newPartitionStack( constUnsigned degree) /* The degree for the partition stack. */
{
PartitionStack *newStack = allocPartitionStack(); Unsigned i;
newStack->degree = degree;
newStack->height = 1;
newStack->pointList = allocIntArrayDegree();
newStack->invPointList = allocIntArrayDegree(); for ( i = 1 ; i <= degree ; ++i )
newStack->pointList[i] = newStack->invPointList[i] = i;
newStack->pointList[degree+1] = newStack->invPointList[degree+1] = 0;
newStack->cellNumber = allocIntArrayDegree(); for ( i = 1 ; i <= degree ; ++i )
newStack->cellNumber[i] = 1;
/* This function creates a new cell partition stack of based on a specified partitionandinitializesittoastackofheight1inwhicheachcellis
in its own cell group. It returns a pointer to the new partition stack. */
CellPartitionStack *newCellPartitionStack(
Partition *basePartn) /* The base partition. */
{
CellPartitionStack *newCellStack = (CellPartitionStack *) malloc( sizeof(CellPartitionStack) ); Unsigned i, cellCount;
/* This function creates a new permutation of a specified degree and initializesittotheidentity.Thenameissettoanullstring.The
returns a pointer to the permutation. */
Permutation *newIdentityPerm( Unsigned degree) /* The degree for the new permutation. */
{
Permutation *newPerm = allocPermutation(); Unsigned pt;
/* This function creates a new permutation of specified degree. Space is allocatedfortheimagearray(Itremainsuninitialized),butnotforthe inverseimagearray.Thefunctionreturnsapointertothenew
permutation. */
Permutation *newUndefinedPerm( constUnsigned degree) /* The degree for the new permutation. */
{
Permutation *newPerm = allocPermutation();
/* The function newRelatorFromWord( w, fbRelFlag, doubleFlag) returns a new relatorcreatedfromawordw.Thelengthandrelfieldsarefilledin. IffbRelFlagistrue,thefRelandbRelfieldsarealsofilledin.If doubleFlagistrue,therel,fRel(ifpresent),andbRel(ifpresent) fieldscontaintwocopiesoftherelator.(Thelengthcountsonecopy only.)Notetherel,fRel,andbRelarraysstartat1.Relatorsare reducedbyremovingconsecutiveentriesthatareinverses;thewordw issimilarlyreduced.NOTEINVERSEPERMUTATIONSMUSTBEPRESENT.
Thefunctionreturnsnulliftherelatorreducestoatrivialword,or
if it could not be allocated. */
Relator *newRelatorFromWord(
Word *const w, constUnsigned fbRelFlag, constUnsigned doubleFlag)
{
Relator *r; Unsigned i, j;
/* First we reduce w. If it attains length 0, return NULL. */
i = 1; while ( i < w->length-1 ) if ( w->position[i+1] == w->position[i]->invPermutation ) { for ( j = i ; j <= w->length-2 ; ++j )
w->position[j] = w->position[j+2];
w->length -= 2; if ( i > 1 )
--i;
} else
++i; if ( w->length == 0 ) return NULL;
/* Now we allocate and fill in fields of r. */
r = allocRelator();
r->length = w->length;
r->level = UNKNOWN;
r->rel = (Permutation **) malloc( (2+r->length+doubleFlag*r->length) * sizeof(Permutation *) ); if ( !r->rel )
ERROR( "newRelatorFromWord", "Out of memory.") for ( i = 1 ; i <= w->length ; ++i )
r->rel[i] = w->position[i]; if ( doubleFlag ) for ( i = w->length+1 ; i <= 2*w->length ; ++i )
r->rel[i] = w->position[i-w->length];
r->rel[i] = NULL; if ( fbRelFlag ) {
r->fRel = (Unsigned **) malloc( (2+r->length+doubleFlag*r->length) * sizeof(Unsigned *) ); if ( !r->fRel )
ERROR( "newRelatorFromWord", "Out of memory.")
r->bRel = (Unsigned **) malloc( (2+r->length+doubleFlag*r->length) * sizeof(Unsigned *) ); if ( !r->bRel )
ERROR( "newRelatorFromWord", "Out of memory.") for ( i = 1 ; i <= (1+doubleFlag)*w->length ; ++i ) {
r->fRel[i] = r->rel[i]->image;
r->bRel[i] = r->rel[i]->invImage;
}
r->fRel[i] = NULL;
r->bRel[i] = NULL;
}
return r;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.29 Sekunden
(vorverarbeitet am 2026-06-27)
¤
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.