void Display ( void ) { if (!mtest ()) { DoDisplay (); } }
/* Oznacene plosky vyrizne jako extra-plosky - musi byt oznacene plosky pouze 1 objektu */ void oe_prikaz_vyrizni_plosky(K_EDITOR * p_cnf) { EDIT_KONTEJNER *p_kont; EDIT_OBJEKT *p_obj; OBJ_VERTEX *p_vertex; int vertexnum; int vertexakt; int i; int k, o, f, fg; if (!p_cnf->groupfacenum) { kprintf(TRUE, "Nejsou vybrane zadne plosky..."); return; } k = p_cnf->p_group_face[0].k; o = p_cnf->p_group_face[0].o; // 1 kontejner, 1 objekt for (i = 1; i < p_cnf->groupfacenum; i++) { if (k != p_cnf->p_group_face[i].k || o != p_cnf->p_group_face[i].o) { kprintf(TRUE, "Jsou vybrane plosky vice objektu/kontejneru..."); return; } } if (!(p_kont = p_cnf->p_kont[k]) || !(p_obj = p_cnf->p_kont[k]->p_obj[o])) { kprintf(TRUE, "Bordel!"); return; } vertexnum = p_obj->vertexnum + p_cnf->groupfacenum * 3; vertexakt = p_obj->vertexnum; p_vertex = malloc(sizeof(p_vertex[0]) * vertexnum); mtest(p_vertex); memcpy(p_vertex, p_obj->p_vertex, sizeof(p_vertex[0]) * vertexakt); for (fg = 0; fg < p_cnf->groupfacenum; fg++) { f = p_cnf->p_group_face[fg].f; p_vertex[vertexakt] = p_vertex[p_obj->p_face[f]]; p_obj->p_face[f] = vertexakt++; p_vertex[vertexakt] = p_vertex[p_obj->p_face[f + 1]]; p_obj->p_face[f + 1] = vertexakt++; p_vertex[vertexakt] = p_vertex[p_obj->p_face[f + 2]]; p_obj->p_face[f + 2] = vertexakt++; } assert(vertexnum == vertexakt); free(p_obj->p_vertex); p_obj->p_vertex = p_vertex; p_obj->vertexnum = vertexnum; vycisti_kontejner(p_kont); }
void mpolsub(MPOL *p, MPOL *q, MPOL *r) { register ip=0,iq=0,is=0; MPOL s; POL_ALLOC(&s,p->nterms + q->nterms); while ((ip<p->nterms)&&(iq<q->nterms)) { #if (! INTR) (*PollPtr)(); #endif switch ((*cmp_exp)(MEXPO(p,ip),MEXPO(q,iq))) { case 1 : expocopy(MEXPO(p,ip),MEXPO(&s,is)); MCOPY(&(p->coefs[ip]),&(s.coefs[is])); ip++;is++;break; case -1 : expocopy(MEXPO(q,iq),MEXPO(&s,is)); MCOPY(&(q->coefs[iq]),&(s.coefs[is])); mnegate(&(s.coefs[is])); iq++;is++;break; case 0 : MCOPY(&(q->coefs[iq]),&(s.coefs[is])); mnegate(&(s.coefs[is])); madd(&(p->coefs[ip]),&(s.coefs[is]),&(s.coefs[is])); if (mtest(&(s.coefs[is]))) { expocopy(MEXPO(p,ip),MEXPO(&s,is)); is++; }; ip++;iq++; }; }; while (ip<p->nterms) { #if (! INTR) (*PollPtr)(); #endif expocopy(MEXPO(p,ip),MEXPO(&s,is)); MCOPY(&(p->coefs[ip]),&(s.coefs[is])); ip++; is++; }; while (iq<q->nterms) { #if (! INTR) (*PollPtr)(); #endif expocopy(MEXPO(q,iq),MEXPO(&s,is)); MCOPY(&(q->coefs[iq]),&(s.coefs[is])); mnegate(&(s.coefs[is])); iq++; is++; }; s.nterms = is; if (is==0){ xfree((char *)s.coefs); xfree((char *)s.expos); }; mpolfree(r); MPOLMOVEFREE(&s,r); };
void oe_group_smaz_stejne(K_EDITOR * p_cnf) { I_VERTEX *p_group; BOD p, *p_bod; int i, j, k, o, v, m; m = 0; for (i = 0; i < p_cnf->groupnum; i++) { k = p_cnf->p_group[i].k; o = p_cnf->p_group[i].o; v = p_cnf->p_group[i].v; p.x = p_cnf->p_kont[k]->p_obj[o]->p_vertex[v].x; p.y = p_cnf->p_kont[k]->p_obj[o]->p_vertex[v].y; p.z = p_cnf->p_kont[k]->p_obj[o]->p_vertex[v].z; for (j = i + 1; j < p_cnf->groupnum; j++) { k = p_cnf->p_group[j].k; o = p_cnf->p_group[j].o; v = p_cnf->p_group[j].v; p_bod = (BOD *) p_cnf->p_kont[k]->p_obj[o]->p_vertex + v; if (p.x == p_bod->x && p.y == p_bod->y && p.z == p_bod->z) { p_cnf->p_group[j].k = -1; m++; } } } if (m) { p_group = malloc(sizeof(p_group[0]) * (p_cnf->groupnum - m)); mtest(p_group); for (m = 0, i = 0; i < p_cnf->groupnum; i++) { if (p_cnf->p_group[i].k != -1) { p_group[m].k = p_cnf->p_group[i].k; p_group[m].o = p_cnf->p_group[i].o; p_group[m].v = p_cnf->p_group[i].v; m++; } } null_free(&p_cnf->p_group); p_cnf->p_group = p_group; p_cnf->groupnum = m; p_cnf->vybr_group = 0; } }
FN minvert(MINT *a, MINT *b, MINT *c) { MINT x, y, z, w, Anew, Aold; int i = 0; static MINT one; static int oneinit = 1; if (oneinit) { oneinit = 0; MSET(1,&one); } MINIT(&x); MINIT(&y); MINIT(&z); MINIT(&w); MINIT(&Aold); MSET (1,&Anew); mcopy(b, &x); mcopy(a, &y); /* * Loop invariant: * * y = -1^i * Anew * a mod b */ while(mtest(&y) != 0) { mdiv(&x, &y, &w, &z); mcopy(&Anew, &x); mmult(&w, &Anew, &Anew); madd(&Anew, &Aold, &Anew); mmove(&x, &Aold); mmove(&y, &x); mmove(&z, &y); i++; } if (mcmp(&one,&x)) { mcopy(&one,c); } else { mmove(&Aold, c); if( (i&01) == 0) msub(b, c, c); } MFREE(&x); MFREE(&y); MFREE(&z); MFREE(&w); MFREE(&Aold); MFREE(&Anew); }
/*** delay * * Input: * * Output: * *************************************************************************/ void delay ( int cSec ) { long lTimeNow, lTimeThen; if (mtest () && !mlast ()) { return; } time (&lTimeThen); do { if (TypeAhead ()) { return; } Sleep (100); time (&lTimeNow); } while (lTimeNow - lTimeThen < cSec + 1); }
void mgcd(MINT *a, MINT *b, MINT *c) { MINT x,y,z,w; MCOPY(a,&x); MCOPY(b,&y); MINIT(&z); MINIT(&w); while( mtest(&y) != 0) { mdiv(&x,&y,&w,&z); mmove(&y,&x); mmove(&z,&y); #if (! INTR) (*PollPtr)(); #endif } mmove(&x,c); MFREE(&y); MFREE(&z); MFREE(&w); return; }
/*** fMacResponse - peek ahead and eat any embedded macro response * * Purpose: * Scans ahead in the macro text for an item beginning with a "<", which * supplies a response to the question asked by a preceding function. * * Input: * None * * Output: * Returns NULL if not found, -1 if the user is to be prompted, and a character * if a character is supplied. * * Exceptions: * none * *************************************************************************/ int fMacResponse ( void ) { int c; struct macroInstanceType *pMI; if (mtest()) { pMI = &mi[cMacUse-1]; if ((TESTFLAG (pMI->flags, INIT | GRAPH)) == 0) { if (*(pMI->text) != '<') return 0; c = (int)*(pMI->text+1); if ((c == 0) || (c == ' ')) { return -1; } pMI->text = whiteskip(pMI->text+2); return c; } } return -1; }
int main( int argc, char **argv ) { char letterset[ MAXLEN ], filename[ MAXLEN ], wordqty[ BINGOLEN ]; int wordno; if( argc == NOARGS ) { puts("Enter a LETTERSET to test ... "); fgets( letterset, MAXLEN, stdin ); chop( letterset ); printf( "\n\nHow many words in each anagram? "); fgets( wordqty, WDS, stdin ); } else strcpy( letterset, *( argv + 1 ) ); if( argc == NOARGS + 1 ) { printf( "\n\nHow many words in each anagram? "); fgets( wordqty, WDS, stdin ); } if( argc > NOARGS + 1 ) strcpy( wordqty, *( argv + 2 ) ); if( argc >= NOARGS + 2 ) if( ( ( !islower( **( argv + 1 ) ) ) && **( argv + 1 ) != '_' ) || ( !isdigit( **( argv + 2 ) ) ) ) { printf( "\nform: multi letterset number_of_words\n" ); exit( CMDLINEERR ); } if( argc == NOARGS + 3 ) strcpy( filename, *( argv + 3 ) ); else strcpy( filename, Wordfile ); if( strlen( wordqty ) > 1 ) { printf( "\nToo many words to anagram. It would take forever!\n" ); exit( CMDLINEERR ); } if( *( wordqty ) == '0' || *( wordqty ) == '1' ) { printf( "\nMust anagram more than 1 word.\n" ); exit( CMDLINEERR ); } wordno = atoi( wordqty ); getword( letterset, filename ); mtest( TMPFILENAME, letterset, wordno ); cleanup(); return (0); }