permrec
*newpermrec(int n) /* Get a permrec of order n. This procedure and the next one are designed to be efficient if lots of group ops are done with the
same value of n. */
{
permrec *p;
if (freelist_n != n)
{ while (freelist != NULL)
{
p = freelist;
freelist = freelist->ptr;
free(p);
}
freelist_n = n;
}
if (freelist != NULL)
{
p = freelist;
freelist = freelist->ptr; return p;
}
p = (permrec*) malloc(sizeof(permrec)+(freelist_n-2)*sizeof(int));
if (p == NULL)
{
fprintf(ERRFILE,">E malloc failed in newpermrec()\n"); exit(1);
}
void
grouplevelproc(int *lab, int *ptn, int level, int *orbits, statsblk *stats, int tv, int index, int tcellsize, int numcells, int cc, int n)
{ int depth;
size_t sz;
if (numcells == n) /* first call */
{
depth = level - 1;
if (group) freegroup(group);
if (depth > group_depth || !group)
{ if (depth <= 1) sz = sizeof(grouprec); else sz = sizeof(grouprec) + (depth-1)*sizeof(levelrec); if (group) group = (grouprec*)realloc((void*)group,sz); else group = (grouprec*)malloc(sz); if (group == NULL)
{
fprintf(ERRFILE,">E malloc failed in grouplevelproc\n"); exit(1);
}
group_depth = depth;
}
void
makecosetreps(grouprec *grp) /* Make all coset representatives for this group */
{ int i,j,k,n,depth; int l,index; int *p,*q;
permrec *gen,*g;
cosetrec *cr; int head,tail;
DYNALLSTAT(int,queue,queue_sz);
DYNALLSTAT(int,lab,lab_sz);
int
permcycles(int *p, int n, int *len, boolean sort) /* Puts in len[0..] the cycle lengths of p. If sort, sort them.
Return the number of cycles. */
{ int m,i,j,k,h,nc,leni;
m = (n + WORDSIZE - 1) / WORDSIZE;
DYNALLOC1(set,workset,workset_sz,m,"malloc");
EMPTYSET(workset,m);
nc = 0; for (i = 0; i < n; ++i) if (!ISELEMENT(workset,i))
{
k = 1; for (j = p[i]; j != i; j = p[j])
{
ADDELEMENT(workset,j);
++k;
}
len[nc++] = k;
}
if (sort && nc > 1)
{
j = nc / 3;
h = 1; do
h = 3 * h + 1; while (h < j);
do
{ for (i = h; i < nc; ++i)
{
leni = len[i]; for (j = i; len[j-h] > leni; )
{
len[j] = len[j-h]; if ((j -= h) < h) break;
}
len[j] = leni;
}
h /= 3;
} while (h > 0);
}
staticvoid
groupelts(levelrec *lr, int n, int level, void (*action)(int*,int), int *before, int *after, int *id) /* Recursive routine used by allgroup. */
{ int i,j,orbsize; int *p,*cr;
cosetrec *coset;
void
allgroup(grouprec *grp, void (*action)(int*,int)) /* Call action(p,n) for every element of the group, including the identity.
The identity is always the first call. */
{ int i,depth,n;
depth = grp->depth;
n = grp->n;
DYNALLOC1(int,id,id_sz,n,"malloc"); for (i = 0; i < n; ++i) id[i] = i;
staticvoid
groupelts2(levelrec *lr, int n, int level, void (*action)(int*,int,int*), int *before, int *after, int *id, int *abort) /* Recursive routine used by allgroup2. */
{ int i,j,orbsize; int *p,*cr;
cosetrec *coset;
int
allgroup2(grouprec *grp, void (*action)(int*,int,int*)) /* Call action(p,n,&abort) for every element of the group, including the identity. The identity is always the first call. If action() stores a non-zero value in abort, group generation is aborted and the abort value is returned by this procedure. If no non-zero value is ever returned in abort by action(), this
procedure returns 0. */
{ int i,depth,n,abort;
depth = grp->depth;
n = grp->n;
DYNALLOC1(int,id,id_sz,n,"malloc"); for (i = 0; i < n; ++i) id[i] = i;
staticvoid
groupelts3(levelrec *lr, int n, int level, void (*action)(int*,int,int*,void*), int *before, int *after, int *id, int *abort, void *userptr) /* Recursive routine used by allgroup3. */
{ int i,j,orbsize; int *p,*cr;
cosetrec *coset;
int
allgroup3(grouprec *grp, void (*action)(int*,int,int*,void*), void *userptr) /* Call action(p,n,&abort,userptr) for every element of the group, including the identity. The identity is always the first call. If action() stores a non-zero value in abort, group generation is aborted and the abort value is returned by this procedure. If no non-zero value is ever returned in abort by action(), this procedure returns 0. The pointer userptr is not interpretted and
is passed to action() to use as it likes. */
{ int i,depth,n,abort;
depth = grp->depth;
n = grp->n;
DYNALLOC1(int,id,id_sz,n,"malloc"); for (i = 0; i < n; ++i) id[i] = i;
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.