/* File new.c. Contains functions to create new objects and delete objects so created. Actual allocation of memory is handled by invoking functions from storage.c. The functions included here are:
/* This function creates a new partition stack of specified degree and initializes it to a stack of height 1 in which the top (and only)
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 partition and initializes it to a stack of height 1 in which each cell is
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 initializes it to the identity. The name is set to a null string. 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 allocated for the image array (It remains uninitialized), but not for the inverse image array. The function returns a pointer to the new
permutation. */
Permutation *newUndefinedPerm( constUnsigned degree) /* The degree for the new permutation. */
{
Permutation *newPerm = allocPermutation();
/* The function newRelatorFromWord( w, fbRelFlag, doubleFlag) returns a new relator created from a word w. The length and rel fields are filled in. If fbRelFlag is true, the fRel and bRel fields are also filled in. If doubleFlag is true, the rel, fRel (if present), and bRel (if present) fields contain two copies of the relator. (The length counts one copy only.) Note the rel, fRel, and bRel arrays start at 1. Relators are reduced by removing consecutive entries that are inverses; the word w is similarly reduced. NOTE INVERSE PERMUTATIONS MUST BE PRESENT.
The function returns null if the relator reduces to a trivial word, 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
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet)
¤
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.