Annotation of OpenXM_contrib2/asir2000/engine/C.c, Revision 1.4
1.2 noro 1: /*
2: * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED
3: * All rights reserved.
4: *
5: * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited,
6: * non-exclusive and royalty-free license to use, copy, modify and
7: * redistribute, solely for non-commercial and non-profit purposes, the
8: * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and
9: * conditions of this Agreement. For the avoidance of doubt, you acquire
10: * only a limited right to use the SOFTWARE hereunder, and FLL or any
11: * third party developer retains all rights, including but not limited to
12: * copyrights, in and to the SOFTWARE.
13: *
14: * (1) FLL does not grant you a license in any way for commercial
15: * purposes. You may use the SOFTWARE only for non-commercial and
16: * non-profit purposes only, such as academic, research and internal
17: * business use.
18: * (2) The SOFTWARE is protected by the Copyright Law of Japan and
19: * international copyright treaties. If you make copies of the SOFTWARE,
20: * with or without modification, as permitted hereunder, you shall affix
21: * to all such copies of the SOFTWARE the above copyright notice.
22: * (3) An explicit reference to this SOFTWARE and its copyright owner
23: * shall be made on your publication or presentation in any form of the
24: * results obtained by use of the SOFTWARE.
25: * (4) In the event that you modify the SOFTWARE, you shall notify FLL by
1.3 noro 26: * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
1.2 noro 27: * for such modification or the source code of the modified part of the
28: * SOFTWARE.
29: *
30: * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL
31: * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND
32: * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS
33: * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES'
34: * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY
35: * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY.
36: * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT,
37: * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY
38: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
39: * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES
40: * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES
41: * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY
42: * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
43: * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART
44: * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
45: * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
46: * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
47: *
1.4 ! noro 48: * $OpenXM: OpenXM_contrib2/asir2000/engine/C.c,v 1.3 2000/08/22 05:04:03 noro Exp $
1.2 noro 49: */
1.1 noro 50: #include "ca.h"
51: #include "inline.h"
52: #include "base.h"
53:
54: V up_var;
55:
56: /* binary has at least 32 leading 0 chars. */
57: void binaryton(binary,np)
58: char *binary;
59: N *np;
60: {
61: int i,w,len;
62: N n;
63: char buf[33];
64:
65: binary += strlen(binary)%32;
66: len = strlen(binary);
67: w = len/32; /* sufficient for holding binary */
68: n = NALLOC(w);
69: for ( i = 0; i < w; i++ ) {
70: strncpy(buf,binary+len-32*(i+1),32); buf[32] = 0;
71: n->b[i] = strtoul(buf,0,2);
72: }
73: for ( i = w-1; i >= 0 && !n->b[i]; i-- );
74: if ( i < 0 )
75: *np = 0;
76: else {
77: n->p = i+1;
78: *np = n;
79: }
80: }
81:
82: /* hex has at least 8 leading 0 chars. */
83: void hexton(hex,np)
84: char *hex;
85: N *np;
86: {
87: int i,w,len;
88: N n;
89: char buf[9];
90:
91: hex += strlen(hex)%8;
92: len = strlen(hex);
93: w = len/8; /* sufficient for holding hex */
94: n = NALLOC(w);
95: for ( i = 0; i < w; i++ ) {
96: strncpy(buf,hex+len-8*(i+1),8); buf[8] = 0;
97: n->b[i] = strtoul(buf,0,16);
98: }
99: for ( i = w-1; i >= 0 && !n->b[i]; i-- );
100: if ( i < 0 )
101: *np = 0;
102: else {
103: n->p = i+1;
104: *np = n;
105: }
106: }
107:
108: void ntobn(base,n,nrp)
109: int base;
110: N n,*nrp;
111: {
112: int i,d,plc;
113: unsigned int *c,*x,*w;
114: unsigned int r;
115: L m;
116: N nr;
117:
118: if ( !n ) {
119: *nrp = NULL;
120: return;
121: }
122:
123: d = PL(n);
124: w = BD(n);
125:
126: for ( i = 1, m = 1; m <= LBASE/(L)base; m *= base, i++ );
127:
128: c = (unsigned int *)W_ALLOC(d*i+1);
129: x = (unsigned int *)W_ALLOC(d+1);
130: for ( i = 0; i < d; i++ )
131: x[i] = w[i];
132: for ( plc = 0; d >= 1; plc++ ) {
133: for ( i = d - 1, r = 0; i >= 0; i-- ) {
134: DSAB((unsigned int)base,r,x[i],x[i],r)
135: }
136: c[plc] = r;
137: if ( !x[d-1] ) d--;
138: }
139:
140: *nrp = nr = NALLOC(plc); INITRC(nr);
141: PL(nr) = plc;
142: for ( i = 0; i < plc; i++ )
143: BD(nr)[i] = c[i];
144: }
145:
146: void bnton(base,n,nrp)
147: int base;
148: N n,*nrp;
149: {
150: unsigned int carry;
151: unsigned int *x,*w;
152: int i,j,d,plc;
153: N nr;
154:
155: if ( !n ) {
156: *nrp = 0;
157: return;
158: }
159:
160: d = PL(n);
161: w = BD(n);
162: x = (unsigned int *)W_ALLOC(d + 1);
163:
164: for ( plc = 0, i = d - 1; i >= 0; i-- ) {
165: for ( carry = w[i],j = 0; j < plc; j++ ) {
166: DMA(x[j],(unsigned int)base,carry,carry,x[j])
167: }
168: if ( carry ) x[plc++] = carry;
169: }
170: *nrp = nr = NALLOC(plc); INITRC(nr);
171: PL(nr) = plc;
172: for ( i = 0; i < plc; i++ )
173: BD(nr)[i] = x[i];
174: }
175:
176: void ptomp(m,p,pr)
177: int m;
178: P p;
179: P *pr;
180: {
181: DCP dc,dcr,dcr0;
182: Q q;
183: unsigned int a,b;
184: P t;
185: MQ s;
186:
187: if ( !p )
188: *pr = 0;
189: else if ( NUM(p) ) {
190: q = (Q)p;
191: a = rem(NM(q),m);
192: if ( a && (SGN(q) < 0) )
193: a = m-a;
194: b = !DN(q)?1:rem(DN(q),m);
195: if ( !b )
196: error("ptomp : denominator = 0");
197: a = dmar(a,invm(b,m),0,m); STOMQ(a,s); *pr = (P)s;
198: } else {
199: for ( dc = DC(p), dcr0 = 0; dc; dc = NEXT(dc) ) {
200: ptomp(m,COEF(dc),&t);
201: if ( t ) {
202: NEXTDC(dcr0,dcr); DEG(dcr) = DEG(dc); COEF(dcr) = t;
203: }
204: }
205: if ( !dcr0 )
206: *pr = 0;
207: else {
208: NEXT(dcr) = 0; MKP(VR(p),dcr0,*pr);
209: }
210: }
211: }
212:
213: void mptop(f,gp)
214: P f;
215: P *gp;
216: {
217: DCP dc,dcr,dcr0;
218: Q q;
219:
220: if ( !f )
221: *gp = 0;
222: else if ( NUM(f) )
223: STOQ(CONT((MQ)f),q),*gp = (P)q;
224: else {
225: for ( dc = DC(f), dcr0 = 0; dc; dc = NEXT(dc) ) {
226: NEXTDC(dcr0,dcr); DEG(dcr) = DEG(dc); mptop(COEF(dc),&COEF(dcr));
1.4 ! noro 227: }
! 228: NEXT(dcr) = 0; MKP(VR(f),dcr0,*gp);
! 229: }
! 230: }
! 231:
! 232: void sfptop(f,gp)
! 233: P f;
! 234: P *gp;
! 235: {
! 236: DCP dc,dcr,dcr0;
! 237: Q q;
! 238:
! 239: if ( !f )
! 240: *gp = 0;
! 241: else if ( NUM(f) ) {
! 242: gfstomq((GFS)f,gp);
! 243: } else {
! 244: for ( dc = DC(f), dcr0 = 0; dc; dc = NEXT(dc) ) {
! 245: NEXTDC(dcr0,dcr); DEG(dcr) = DEG(dc); sfptop(COEF(dc),&COEF(dcr));
1.1 noro 246: }
247: NEXT(dcr) = 0; MKP(VR(f),dcr0,*gp);
248: }
249: }
250:
251: void ptolmp(p,pr)
252: P p;
253: P *pr;
254: {
255: DCP dc,dcr,dcr0;
256: LM a;
257: P t;
258:
259: if ( !p )
260: *pr = 0;
261: else if ( NUM(p) ) {
262: qtolm((Q)p,&a); *pr = (P)a;
263: } else {
264: for ( dc = DC(p), dcr0 = 0; dc; dc = NEXT(dc) ) {
265: ptolmp(COEF(dc),&t);
266: if ( t ) {
267: NEXTDC(dcr0,dcr); DEG(dcr) = DEG(dc); COEF(dcr) = t;
268: }
269: }
270: if ( !dcr0 )
271: *pr = 0;
272: else {
273: NEXT(dcr) = 0; MKP(VR(p),dcr0,*pr);
274: }
275: }
276: }
277:
278: void lmptop(f,gp)
279: P f;
280: P *gp;
281: {
282: DCP dc,dcr,dcr0;
283: Q q;
284:
285: if ( !f )
286: *gp = 0;
287: else if ( NUM(f) ) {
288: NTOQ(((LM)f)->body,1,q); *gp = (P)q;
289: } else {
290: for ( dc = DC(f), dcr0 = 0; dc; dc = NEXT(dc) ) {
291: NEXTDC(dcr0,dcr); DEG(dcr) = DEG(dc); lmptop(COEF(dc),&COEF(dcr));
292: }
293: NEXT(dcr) = 0; MKP(VR(f),dcr0,*gp);
294: }
295: }
296:
297: void ptoum(m,f,wf)
298: int m;
299: P f;
300: UM wf;
301: {
302: unsigned int r;
303: int i;
304: DCP dc;
305:
306: for ( i = UDEG(f); i >= 0; i-- )
307: COEF(wf)[i] = 0;
308:
309: for ( dc = DC(f); dc; dc = NEXT(dc) ) {
310: r = rem(NM((Q)COEF(dc)),m);
311: if ( r && (SGN((Q)COEF(dc)) < 0) )
312: r = m-r;
313: COEF(wf)[QTOS(DEG(dc))] = r;
314: }
315: degum(wf,UDEG(f));
316: }
317:
318: void umtop(v,w,f)
319: V v;
320: UM w;
321: P *f;
322: {
323: int *c;
324: DCP dc,dc0;
325: int i;
326: Q q;
327:
328: if ( DEG(w) < 0 )
329: *f = 0;
330: else if ( DEG(w) == 0 )
331: STOQ(COEF(w)[0],q), *f = (P)q;
332: else {
333: for ( i = DEG(w), c = COEF(w), dc0 = 0; i >= 0; i-- )
334: if ( c[i] ) {
335: NEXTDC(dc0,dc);
336: STOQ(i,DEG(dc));
337: STOQ(c[i],q), COEF(dc) = (P)q;
338: }
339: NEXT(dc) = 0;
340: MKP(v,dc0,*f);
341: }
342: }
343:
344: void ptoup(n,nr)
345: P n;
346: UP *nr;
347: {
348: DCP dc;
349: UP r;
350: int d;
351:
352: if ( !n )
353: *nr = 0;
354: else if ( OID(n) == O_N ) {
355: *nr = r = UPALLOC(0);
356: DEG(r) = 0; COEF(r)[0] = (Num)n;
357: } else {
358: d = UDEG(n);
359: up_var = VR(n);
360: *nr = r = UPALLOC(d); DEG(r) = d;
361: for ( dc = DC(n); dc; dc = NEXT(dc) ) {
362: COEF(r)[QTOS(DEG(dc))] = (Num)COEF(dc);
363: }
364: }
365: }
366:
367: void uptop(n,nr)
368: UP n;
369: P *nr;
370: {
371: int i;
372: DCP dc0,dc;
373:
374: if ( !n )
375: *nr = 0;
376: else if ( !DEG(n) )
377: *nr = (P)COEF(n)[0];
378: else {
379: for ( i = DEG(n), dc0 = 0; i >= 0; i-- )
380: if ( COEF(n)[i] ) {
381: NEXTDC(dc0,dc); STOQ(i,DEG(dc)); COEF(dc) = (P)COEF(n)[i];
382: }
383: if ( !up_var )
384: up_var = CO->v;
385: MKP(up_var,dc0,*nr);
386: }
387: }
388:
389: void ulmptoum(m,f,wf)
390: int m;
391: UP f;
392: UM wf;
393: {
394: int i,d;
395: LM *c;
396:
397: if ( !f )
398: wf->d = -1;
399: else {
400: wf->d = d = f->d;
401: c = (LM *)f->c;
402: for ( i = 0, d = f->d; i <= d; i++ )
403: COEF(wf)[i] = rem(c[i]->body,m);
404: }
405: }
406:
407: void objtobobj(base,p,rp)
408: int base;
409: Obj p;
410: Obj *rp;
411: {
412: if ( !p )
413: *rp = 0;
414: else
415: switch ( OID(p) ) {
416: case O_N:
417: numtobnum(base,(Num)p,(Num *)rp); break;
418: case O_P:
419: ptobp(base,(P)p,(P *)rp); break;
420: case O_LIST:
421: listtoblist(base,(LIST)p,(LIST *)rp); break;
422: case O_VECT:
423: vecttobvect(base,(VECT)p,(VECT *)rp); break;
424: case O_MAT:
425: mattobmat(base,(MAT)p,(MAT *)rp); break;
426: case O_STR:
427: *rp = p; break;
428: case O_COMP: default:
429: error("objtobobj : not implemented"); break;
430: }
431: }
432:
433: void bobjtoobj(base,p,rp)
434: int base;
435: Obj p;
436: Obj *rp;
437: {
438: if ( !p )
439: *rp = 0;
440: else
441: switch ( OID(p) ) {
442: case O_N:
443: bnumtonum(base,(Num)p,(Num *)rp); break;
444: case O_P:
445: bptop(base,(P)p,(P *)rp); break;
446: case O_LIST:
447: blisttolist(base,(LIST)p,(LIST *)rp); break;
448: case O_VECT:
449: bvecttovect(base,(VECT)p,(VECT *)rp); break;
450: case O_MAT:
451: bmattomat(base,(MAT)p,(MAT *)rp); break;
452: case O_STR:
453: *rp = p; break;
454: case O_COMP: default:
455: error("bobjtoobj : not implemented"); break;
456: }
457: }
458:
459: void numtobnum(base,p,rp)
460: int base;
461: Num p;
462: Num *rp;
463: {
464: N nm,dn,body;
465: Q q;
466: LM l;
467:
468: if ( !p )
469: *rp = 0;
470: else
471: switch ( NID(p) ) {
472: case N_Q:
473: ntobn(base,NM((Q)p),&nm);
474: if ( DN((Q)p) ) {
475: ntobn(base,DN((Q)p),&dn);
476: NDTOQ(nm,dn,SGN((Q)p),q);
477: } else
478: NTOQ(nm,SGN((Q)p),q);
479: *rp = (Num)q;
480: break;
481: case N_R:
482: *rp = p; break;
483: case N_LM:
484: ntobn(base,((LM)p)->body,&body);
485: MKLM(body,l); *rp = (Num)l;
486: break;
487: default:
488: error("numtobnum : not implemented"); break;
489: }
490: }
491:
492: void bnumtonum(base,p,rp)
493: int base;
494: Num p;
495: Num *rp;
496: {
497: N nm,dn,body;
498: Q q;
499: LM l;
500:
501: if ( !p )
502: *rp = 0;
503: else
504: switch ( NID(p) ) {
505: case N_Q:
506: bnton(base,NM((Q)p),&nm);
507: if ( DN((Q)p) ) {
508: bnton(base,DN((Q)p),&dn);
509: NDTOQ(nm,dn,SGN((Q)p),q);
510: } else
511: NTOQ(nm,SGN((Q)p),q);
512: *rp = (Num)q;
513: break;
514: case N_R:
515: *rp = p; break;
516: case N_LM:
517: bnton(base,((LM)p)->body,&body);
518: MKLM(body,l); *rp = (Num)l;
519: break;
520: default:
521: error("bnumtonum : not implemented"); break;
522: }
523: }
524:
525: void ptobp(base,p,rp)
526: int base;
527: P p;
528: P *rp;
529: {
530: DCP dcr0,dcr,dc;
531:
532: if ( !p )
533: *rp = p;
534: else {
535: for ( dcr0 = 0, dc = DC(p); dc; dc = NEXT(dc) ) {
536: NEXTDC(dcr0,dcr); DEG(dcr) = DEG(dc);
537: objtobobj(base,(Obj)COEF(dc),(Obj *)&COEF(dcr));
538: }
539: NEXT(dcr) = 0;
540: MKP(VR(p),dcr0,*rp);
541: }
542: }
543:
544: void bptop(base,p,rp)
545: int base;
546: P p;
547: P *rp;
548: {
549: DCP dcr0,dcr,dc;
550:
551: if ( !p )
552: *rp = p;
553: else {
554: for ( dcr0 = 0, dc = DC(p); dc; dc = NEXT(dc) ) {
555: NEXTDC(dcr0,dcr); DEG(dcr) = DEG(dc);
556: bobjtoobj(base,(Obj)COEF(dc),(Obj *)&COEF(dcr));
557: }
558: NEXT(dcr) = 0;
559: MKP(VR(p),dcr0,*rp);
560: }
561: }
562:
563: void listtoblist(base,p,rp)
564: int base;
565: LIST p;
566: LIST *rp;
567: {
568: NODE nr0,nr,n;
569:
570: if ( !p )
571: *rp = p;
572: else {
573: for ( nr0 = 0, n = BDY(p); n; n = NEXT(n) ) {
574: NEXTNODE(nr0,nr);
575: objtobobj(base,BDY(n),(Obj *)&BDY(nr));
576: }
577: NEXT(nr) = 0;
578: MKLIST(*rp,nr0);
579: }
580: }
581:
582: void blisttolist(base,p,rp)
583: int base;
584: LIST p;
585: LIST *rp;
586: {
587: NODE nr0,nr,n;
588:
589: if ( !p )
590: *rp = p;
591: else {
592: for ( nr0 = 0, n = BDY(p); n; n = NEXT(n) ) {
593: NEXTNODE(nr0,nr);
594: bobjtoobj(base,BDY(n),(Obj *)&BDY(nr));
595: }
596: NEXT(nr) = 0;
597: MKLIST(*rp,nr0);
598: }
599: }
600:
601: void vecttobvect(base,p,rp)
602: int base;
603: VECT p;
604: VECT *rp;
605: {
606: int i,l;
607: VECT r;
608:
609: if ( !p )
610: *rp = p;
611: else {
612: l = p->len;
613: MKVECT(r,l); *rp = r;
614: for ( i = 0; i < l; i++ )
615: objtobobj(base,p->body[i],(Obj *)&r->body[i]);
616: }
617: }
618:
619: void bvecttovect(base,p,rp)
620: int base;
621: VECT p;
622: VECT *rp;
623: {
624: int i,l;
625: VECT r;
626:
627: if ( !p )
628: *rp = p;
629: else {
630: l = p->len;
631: MKVECT(r,l); *rp = r;
632: for ( i = 0; i < l; i++ )
633: bobjtoobj(base,p->body[i],(Obj *)&r->body[i]);
634: }
635: }
636:
637: void mattobmat(base,p,rp)
638: int base;
639: MAT p;
640: MAT *rp;
641: {
642: int row,col,i,j;
643: MAT r;
644:
645: if ( !p )
646: *rp = p;
647: else {
648: row = p->row; col = p->col;
649: MKMAT(r,row,col); *rp = r;
650: for ( i = 0; i < row; i++ )
651: for ( j = 0; i < col; j++ )
652: objtobobj(base,p->body[i][j],(Obj *)&r->body[i][j]);
653: }
654: }
655:
656: void bmattomat(base,p,rp)
657: int base;
658: MAT p;
659: MAT *rp;
660: {
661: int row,col,i,j;
662: MAT r;
663:
664: if ( !p )
665: *rp = p;
666: else {
667: row = p->row; col = p->col;
668: MKMAT(r,row,col); *rp = r;
669: for ( i = 0; i < row; i++ )
670: for ( j = 0; i < col; j++ )
671: bobjtoobj(base,p->body[i][j],(Obj *)&r->body[i][j]);
672: }
673: }
674:
675: void n32ton27(g,rp)
676: N g;
677: N *rp;
678: {
679: int i,j,k,l,r,bits,words;
680: unsigned int t;
681: unsigned int *a,*b;
682: N z;
683:
684: l = PL(g); a = BD(g);
685: for ( i = 31, t = a[l-1]; !(t&(1<<i)); i-- );
686: bits = (l-1)*32+i+1; words = (bits+26)/27;
687: *rp = z = NALLOC(words); PL(z) = words;
688: bzero((char *)BD(z),words*sizeof(unsigned int));
689: for ( j = 0, b = BD(z); j < words; j++ ) {
690: k = (27*j)/32; r = (27*j)%32;
691: if ( r > 5 )
692: b[j] = (a[k]>>r)|(k==(l-1)?0:((a[k+1]&((1<<(r-5))-1))<<(32-r)));
693: else
694: b[j] = (a[k]>>r)&((1<<27)-1);
695: }
696: if ( !(r = bits%27) )
697: r = 27;
698: b[words-1] &= ((1<<r)-1);
699: }
700:
701: void n27ton32(a,rp)
702: N a;
703: N *rp;
704: {
705: int i,j,k,l,r,bits,words;
706: unsigned int t;
707: unsigned int *b,*c;
708: N z;
709:
710: l = PL(a); b = BD(a);
711: for ( i = 26, t = b[l-1]; !(t&(1<<i)); i-- );
712: bits = (l-1)*27+i+1; words = (bits+31)/32;
713: *rp = z = NALLOC(words); PL(z) = words;
714: bzero((char *)BD(z),words*sizeof(unsigned int));
715: for ( j = 0, c = BD(z); j < l; j++ ) {
716: k = (27*j)/32; r = (27*j)%32;
717: if ( r > 5 ) {
718: c[k] |= (b[j]&((1<<(32-r))-1))<<r;
719: if ( k+1 < words )
720: c[k+1] = (b[j]>>(32-r));
721: } else
722: c[k] |= (b[j]<<r);
723: }
724: }
725:
726: void mptoum(p,pr)
727: P p;
728: UM pr;
729: {
730: DCP dc;
731:
732: if ( !p )
733: DEG(pr) = -1;
734: else if ( NUM(p) ) {
735: DEG(pr) = 0; COEF(pr)[0] = CONT((MQ)p);
736: } else {
737: bzero((char *)pr,(int)((UDEG(p)+2)*sizeof(int)));
738: for ( dc = DC(p); dc; dc = NEXT(dc) )
739: COEF(pr)[QTOS(DEG(dc))] = CONT((MQ)COEF(dc));
740: degum(pr,UDEG(p));
741: }
742: }
743:
744: void umtomp(v,p,pr)
745: V v;
746: UM p;
747: P *pr;
748: {
749: DCP dc,dc0;
750: int i;
751: MQ q;
752:
753: if ( !p || (DEG(p) < 0) )
754: *pr = 0;
755: else if ( !DEG(p) )
756: STOMQ(COEF(p)[0],q), *pr = (P)q;
757: else {
758: for ( dc0 = 0, i = DEG(p); i >= 0; i-- )
759: if ( COEF(p)[i] ) {
760: NEXTDC(dc0,dc); STOQ(i,DEG(dc));
761: STOMQ(COEF(p)[i],q), COEF(dc) = (P)q;
762: }
763: NEXT(dc) = 0; MKP(v,dc0,*pr);
764: }
765: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>