Annotation of OpenXM_contrib2/asir2018/builtin/dp.c, Revision 1.28
1.1 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
26: * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
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.28 ! noro 48: * $OpenXM: OpenXM_contrib2/asir2018/builtin/dp.c,v 1.27 2021/01/25 00:39:51 noro Exp $
1.1 noro 49: */
50: #include "ca.h"
51: #include "base.h"
52: #include "parse.h"
53:
54: extern int dp_fcoeffs;
55: extern int dp_nelim;
56: extern int dp_order_pair_length;
57: extern struct order_pair *dp_order_pair;
58: extern struct order_spec *dp_current_spec;
59: extern struct modorder_spec *dp_current_modspec;
60: extern int nd_rref2;
61:
1.22 noro 62: extern int do_weyl;
1.1 noro 63:
1.3 noro 64: void Pdp_monomial_hilbert_poincare();
1.1 noro 65: void Pdp_sort();
66: void Pdp_mul_trunc(),Pdp_quo();
67: void Pdp_ord(), Pdp_ptod(), Pdp_dtop(), Phomogenize();
68: void Pdp_ptozp(), Pdp_ptozp2(), Pdp_red(), Pdp_red2(), Pdp_lcm(), Pdp_redble();
69: void Pdp_sp(), Pdp_hm(), Pdp_ht(), Pdp_hc(), Pdp_rest(), Pdp_td(), Pdp_sugar();
70: void Pdp_set_sugar();
71: void Pdp_cri1(),Pdp_cri2(),Pdp_subd(),Pdp_mod(),Pdp_red_mod(),Pdp_tdiv();
72: void Pdp_prim(),Pdp_red_coef(),Pdp_mag(),Pdp_set_kara(),Pdp_rat();
73: void Pdp_nf(),Pdp_true_nf(),Pdp_true_nf_marked(),Pdp_true_nf_marked_mod();
74:
75: void Pdp_true_nf_and_quotient(),Pdp_true_nf_and_quotient_mod();
76: void Pdp_true_nf_and_quotient_marked(),Pdp_true_nf_and_quotient_marked_mod();
77:
78: void Pdp_nf_mod(),Pdp_true_nf_mod();
79: void Pdp_criB(),Pdp_nelim();
80: void Pdp_minp(),Pdp_sp_mod();
81: void Pdp_homo(),Pdp_dehomo();
1.26 noro 82: void Pdpm_homo(),Pdpm_dehomo(),Pdpm_mod();
1.1 noro 83: void Pdp_gr_mod_main(),Pdp_gr_f_main();
84: void Pdp_gr_main(),Pdp_gr_hm_main(),Pdp_gr_d_main(),Pdp_gr_flags();
85: void Pdp_interreduce();
86: void Pdp_f4_main(),Pdp_f4_mod_main(),Pdp_f4_f_main();
87: void Pdp_gr_print();
88: void Pdp_mbase(),Pdp_lnf_mod(),Pdp_nf_tab_mod(),Pdp_mdtod(), Pdp_nf_tab_f();
89: void Pdp_vtoe(), Pdp_etov(), Pdp_dtov(), Pdp_idiv(), Pdp_sep();
90: void Pdp_cont();
91: void Pdp_gr_checklist();
92: void Pdp_ltod(),Pdpv_ord(),Pdpv_ht(),Pdpv_hm(),Pdpv_hc();
1.17 noro 93: void Pdpm_ltod(),Pdpm_dtol(),Pdpm_set_schreyer(),Pdpm_nf(),Pdpm_weyl_nf(),Pdpm_sp(),Pdpm_weyl_sp(),Pdpm_nf_and_quotient(),Pdpm_nf_and_quotient2();
1.18 noro 94: void Pdpm_schreyer_frame(),Pdpm_set_schreyer_level();
1.19 noro 95: void Pdpm_list_to_array(),Pdpm_sp_nf(),Pdpm_insert_to_zlist();
1.21 noro 96: void Pdpm_hm(),Pdpm_ht(),Pdpm_hc(),Pdpm_hp(),Pdpm_rest(),Pdpm_shift(),Pdpm_split(),Pdpm_extract(),Pdpm_sort(),Pdpm_dptodpm(),Pdpm_redble();
1.15 noro 97: void Pdpm_schreyer_base(),Pdpm_simplify_syz(),Pdpm_td();
1.21 noro 98: void Pdpm_remove_cont();
1.1 noro 99:
100: void Pdp_weyl_red();
101: void Pdp_weyl_sp();
102:
103: void Pdp_weyl_nf(),Pdp_weyl_nf_mod();
104: void Pdp_weyl_true_nf_and_quotient(),Pdp_weyl_true_nf_and_quotient_mod();
105: void Pdp_weyl_true_nf_and_quotient_marked(),Pdp_weyl_true_nf_and_quotient_marked_mod();
106:
107: void Pdp_weyl_gr_main(),Pdp_weyl_gr_mod_main(),Pdp_weyl_gr_f_main();
108: void Pdp_weyl_f4_main(),Pdp_weyl_f4_mod_main(),Pdp_weyl_f4_f_main();
109: void Pdp_weyl_mul(),Pdp_weyl_mul_mod(),Pdp_weyl_act();
110: void Pdp_weyl_set_weight();
111: void Pdp_set_weight(),Pdp_set_top_weight(),Pdp_set_module_weight();
112: void Pdp_nf_f(),Pdp_weyl_nf_f();
113: void Pdpm_nf_f(),Pdpm_weyl_nf_f();
114: void Pdp_lnf_f();
115: void Pnd_gr(),Pnd_gr_trace(),Pnd_f4(),Pnd_f4_trace();
1.25 noro 116: void Pnd_sba(),Pnd_sba_f4();
1.27 noro 117: void Pnd_weyl_sba();
1.1 noro 118: void Pnd_gr_postproc(), Pnd_weyl_gr_postproc();
119: void Pnd_gr_recompute_trace(), Pnd_btog();
120: void Pnd_weyl_gr(),Pnd_weyl_gr_trace();
121: void Pnd_nf(),Pnd_weyl_nf();
122: void Pdp_initial_term();
123: void Pdp_order();
124: void Pdp_inv_or_split();
125: void Pdp_compute_last_t();
126: void Pdp_compute_last_w();
127: void Pdp_compute_essential_df();
128: void Pdp_get_denomlist();
129: void Pdp_symb_add();
130: void Pdp_mono_raddec();
131: void Pdp_mono_reduce();
132: void Pdp_rref2(),Psumi_updatepairs(),Psumi_symbolic();
133:
134: LIST dp_initial_term();
135: LIST dp_order();
136: void parse_gr_option(LIST f,NODE opt,LIST *v,Num *homo,
137: int *modular,struct order_spec **ord);
138: NODE dp_inv_or_split(NODE gb,DP f,struct order_spec *spec, DP *inv);
139:
140: LIST remove_zero_from_list(LIST);
141:
142: struct ftab dp_tab[] = {
143: /* content reduction */
144: {"dp_ptozp",Pdp_ptozp,1},
145: {"dp_ptozp2",Pdp_ptozp2,2},
146: {"dp_prim",Pdp_prim,1},
147: {"dp_red_coef",Pdp_red_coef,2},
148: {"dp_cont",Pdp_cont,1},
1.21 noro 149: {"dpm_remove_cont",Pdpm_remove_cont,1},
1.1 noro 150:
151: /* polynomial ring */
152: /* special operations */
153: {"dp_mul_trunc",Pdp_mul_trunc,3},
154: {"dp_quo",Pdp_quo,2},
155:
156: /* s-poly */
157: {"dp_sp",Pdp_sp,2},
158: {"dp_sp_mod",Pdp_sp_mod,3},
159:
160: /* m-reduction */
161: {"dp_red",Pdp_red,3},
162: {"dp_red_mod",Pdp_red_mod,4},
163:
164: /* normal form */
165: {"dp_nf",Pdp_nf,4},
166: {"dp_nf_mod",Pdp_nf_mod,5},
167: {"dp_nf_f",Pdp_nf_f,4},
1.9 noro 168: {"dpm_nf_and_quotient",Pdpm_nf_and_quotient,-3},
1.17 noro 169: {"dpm_nf_and_quotient2",Pdpm_nf_and_quotient2,-3},
1.11 noro 170: {"dpm_nf_f",Pdpm_nf_f,-4},
171: {"dpm_weyl_nf_f",Pdpm_weyl_nf_f,-4},
172: {"dpm_nf",Pdpm_nf,-4},
1.1 noro 173: {"dpm_sp",Pdpm_sp,2},
174: {"dpm_weyl_sp",Pdpm_weyl_sp,2},
175:
176: {"dp_true_nf",Pdp_true_nf,4},
177: {"dp_true_nf_mod",Pdp_true_nf_mod,5},
178: {"dp_true_nf_marked",Pdp_true_nf_marked,4},
179: {"dp_true_nf_marked_mod",Pdp_true_nf_marked_mod,5},
180:
181: {"dp_true_nf_and_quotient",Pdp_true_nf_and_quotient,3},
182: {"dp_true_nf_and_quotient_mod",Pdp_true_nf_and_quotient_mod,4},
183: {"dp_true_nf_and_quotient_marked",Pdp_true_nf_and_quotient_marked,4},
184: {"dp_true_nf_and_quotient_marked_mod",Pdp_true_nf_and_quotient_marked_mod,5},
185:
186: {"dp_lnf_mod",Pdp_lnf_mod,3},
187: {"dp_nf_tab_f",Pdp_nf_tab_f,2},
188: {"dp_nf_tab_mod",Pdp_nf_tab_mod,3},
189: {"dp_lnf_f",Pdp_lnf_f,2},
190:
191: /* Buchberger algorithm */
192: {"dp_gr_main",Pdp_gr_main,-5},
193: {"dp_interreduce",Pdp_interreduce,3},
194: {"dp_gr_mod_main",Pdp_gr_mod_main,5},
195: {"dp_gr_f_main",Pdp_gr_f_main,4},
196: {"dp_gr_checklist",Pdp_gr_checklist,2},
197: {"nd_f4",Pnd_f4,-4},
198: {"nd_gr",Pnd_gr,-4},
1.24 noro 199: {"nd_sba",Pnd_sba,-4},
1.27 noro 200: {"nd_weyl_sba",Pnd_weyl_sba,-4},
1.25 noro 201: {"nd_sba_f4",Pnd_sba_f4,-4},
1.1 noro 202: {"nd_gr_trace",Pnd_gr_trace,-5},
203: {"nd_f4_trace",Pnd_f4_trace,-5},
204: {"nd_gr_postproc",Pnd_gr_postproc,5},
205: {"nd_gr_recompute_trace",Pnd_gr_recompute_trace,5},
206: {"nd_btog",Pnd_btog,-6},
207: {"nd_weyl_gr_postproc",Pnd_weyl_gr_postproc,5},
208: {"nd_weyl_gr",Pnd_weyl_gr,-4},
209: {"nd_weyl_gr_trace",Pnd_weyl_gr_trace,-5},
210: {"nd_nf",Pnd_nf,5},
211: {"nd_weyl_nf",Pnd_weyl_nf,5},
212:
213: /* F4 algorithm */
214: {"dp_f4_main",Pdp_f4_main,3},
215: {"dp_f4_mod_main",Pdp_f4_mod_main,4},
216:
217: /* weyl algebra */
218: /* multiplication */
219: {"dp_weyl_mul",Pdp_weyl_mul,2},
220: {"dp_weyl_mul_mod",Pdp_weyl_mul_mod,3},
221: {"dp_weyl_act",Pdp_weyl_act,2},
222:
223: /* s-poly */
224: {"dp_weyl_sp",Pdp_weyl_sp,2},
225:
226: /* m-reduction */
227: {"dp_weyl_red",Pdp_weyl_red,3},
228:
229: /* normal form */
230: {"dp_weyl_nf",Pdp_weyl_nf,4},
1.11 noro 231: {"dpm_weyl_nf",Pdpm_weyl_nf,-4},
1.1 noro 232: {"dp_weyl_nf_mod",Pdp_weyl_nf_mod,5},
233: {"dp_weyl_nf_f",Pdp_weyl_nf_f,4},
234:
235: {"dp_weyl_true_nf_and_quotient",Pdp_weyl_true_nf_and_quotient,3},
236: {"dp_weyl_true_nf_and_quotient_mod",Pdp_weyl_true_nf_and_quotient_mod,4},
237: {"dp_weyl_true_nf_and_quotient_marked",Pdp_weyl_true_nf_and_quotient_marked,4},
238: {"dp_weyl_true_nf_and_quotient_marked_mod",Pdp_weyl_true_nf_and_quotient_marked_mod,5},
239:
240:
241: /* Buchberger algorithm */
242: {"dp_weyl_gr_main",Pdp_weyl_gr_main,-5},
243: {"dp_weyl_gr_mod_main",Pdp_weyl_gr_mod_main,5},
244: {"dp_weyl_gr_f_main",Pdp_weyl_gr_f_main,4},
245:
246: /* F4 algorithm */
247: {"dp_weyl_f4_main",Pdp_weyl_f4_main,3},
248: {"dp_weyl_f4_mod_main",Pdp_weyl_f4_mod_main,4},
249:
1.3 noro 250: /* Hilbert function */
251: {"dp_monomial_hilbert_poincare",Pdp_monomial_hilbert_poincare,2},
252:
1.1 noro 253: /* misc */
254: {"dp_inv_or_split",Pdp_inv_or_split,3},
255: {"dp_set_weight",Pdp_set_weight,-1},
256: {"dp_set_module_weight",Pdp_set_module_weight,-1},
257: {"dp_set_top_weight",Pdp_set_top_weight,-1},
258: {"dp_weyl_set_weight",Pdp_weyl_set_weight,-1},
259:
260: {"dp_get_denomlist",Pdp_get_denomlist,0},
261: {0,0,0},
262: };
263:
264: struct ftab dp_supp_tab[] = {
265: /* setting flags */
266: {"dp_sort",Pdp_sort,1},
267: {"dp_ord",Pdp_ord,-1},
1.9 noro 268: {"dpm_set_schreyer",Pdpm_set_schreyer,-1},
1.18 noro 269: {"dpm_set_schreyer_level",Pdpm_set_schreyer_level,1},
270: {"dpm_schreyer_frame",Pdpm_schreyer_frame,1},
1.1 noro 271: {"dpv_ord",Pdpv_ord,-2},
272: {"dp_set_kara",Pdp_set_kara,-1},
273: {"dp_nelim",Pdp_nelim,-1},
274: {"dp_gr_flags",Pdp_gr_flags,-1},
275: {"dp_gr_print",Pdp_gr_print,-1},
276:
277: /* converters */
278: {"homogenize",Phomogenize,3},
279: {"dp_ptod",Pdp_ptod,-2},
280: {"dp_dtop",Pdp_dtop,2},
281: {"dp_homo",Pdp_homo,1},
282: {"dp_dehomo",Pdp_dehomo,1},
283: {"dp_etov",Pdp_etov,1},
284: {"dp_vtoe",Pdp_vtoe,1},
285: {"dp_dtov",Pdp_dtov,1},
286: {"dp_mdtod",Pdp_mdtod,1},
287: {"dp_mod",Pdp_mod,3},
288: {"dp_rat",Pdp_rat,1},
289: {"dp_ltod",Pdp_ltod,-2},
290:
291: {"dpm_ltod",Pdpm_ltod,2},
1.9 noro 292: {"dpm_dptodpm",Pdpm_dptodpm,2},
1.14 noro 293: {"dpm_dtol",Pdpm_dtol,2},
1.16 noro 294: {"dpm_homo",Pdpm_homo,1},
295: {"dpm_dehomo",Pdpm_dehomo,1},
1.26 noro 296: {"dpm_mod",Pdpm_mod,2},
1.1 noro 297:
298: /* criteria */
299: {"dp_cri1",Pdp_cri1,2},
300: {"dp_cri2",Pdp_cri2,2},
301: {"dp_criB",Pdp_criB,3},
302:
303: /* simple operation */
304: {"dp_subd",Pdp_subd,2},
305: {"dp_lcm",Pdp_lcm,2},
306: {"dp_hm",Pdp_hm,1},
307: {"dp_ht",Pdp_ht,1},
308: {"dp_hc",Pdp_hc,1},
309: {"dpv_hm",Pdpv_hm,1},
310: {"dpv_ht",Pdpv_ht,1},
311: {"dpv_hc",Pdpv_hc,1},
312: {"dpm_hm",Pdpm_hm,1},
313: {"dpm_ht",Pdpm_ht,1},
314: {"dpm_hc",Pdpm_hc,1},
1.10 noro 315: {"dpm_hp",Pdpm_hp,1},
316: {"dpm_rest",Pdpm_rest,1},
1.9 noro 317: {"dpm_shift",Pdpm_shift,2},
318: {"dpm_split",Pdpm_split,2},
1.21 noro 319: {"dpm_extract",Pdpm_extract,2},
1.9 noro 320: {"dpm_sort",Pdpm_sort,1},
1.1 noro 321: {"dp_rest",Pdp_rest,1},
322: {"dp_initial_term",Pdp_initial_term,1},
323: {"dp_order",Pdp_order,1},
324: {"dp_symb_add",Pdp_symb_add,2},
325:
326: /* degree and size */
327: {"dp_td",Pdp_td,1},
328: {"dp_mag",Pdp_mag,1},
329: {"dp_sugar",Pdp_sugar,1},
330: {"dp_set_sugar",Pdp_set_sugar,2},
1.15 noro 331: {"dpm_td",Pdpm_td,1},
1.1 noro 332:
333: /* misc */
334: {"dp_mbase",Pdp_mbase,1},
335: {"dp_redble",Pdp_redble,2},
1.9 noro 336: {"dpm_redble",Pdpm_redble,2},
1.1 noro 337: {"dp_sep",Pdp_sep,2},
338: {"dp_idiv",Pdp_idiv,2},
339: {"dp_tdiv",Pdp_tdiv,2},
340: {"dp_minp",Pdp_minp,2},
341: {"dp_compute_last_w",Pdp_compute_last_w,5},
342: {"dp_compute_last_t",Pdp_compute_last_t,5},
343: {"dp_compute_essential_df",Pdp_compute_essential_df,2},
344: {"dp_mono_raddec",Pdp_mono_raddec,2},
345: {"dp_mono_reduce",Pdp_mono_reduce,2},
1.11 noro 346: {"dpm_schreyer_base",Pdpm_schreyer_base,1},
1.19 noro 347: {"dpm_list_to_array",Pdpm_list_to_array,1},
348: {"dpm_sp_nf",Pdpm_sp_nf,4},
349: {"dpm_insert_to_zlist",Pdpm_insert_to_zlist,3},
1.12 noro 350: {"dpm_simplify_syz",Pdpm_simplify_syz,2},
1.1 noro 351:
352: {"dp_rref2",Pdp_rref2,2},
353: {"sumi_updatepairs",Psumi_updatepairs,3},
354: {"sumi_symbolic",Psumi_symbolic,5},
355:
356: {0,0,0}
357: };
358:
359: NODE compute_last_w(NODE g,NODE gh,int n,int **v,int row1,int **m1,int row2,int **m2);
360: Q compute_last_t(NODE g,NODE gh,Q t,VECT w1,VECT w2,NODE *homo,VECT *wp);
361:
1.3 noro 362: int comp_by_tdeg(DP *a,DP *b)
363: {
364: int da,db;
365:
366: da = BDY(*a)->dl->td;
367: db = BDY(*b)->dl->td;
368: if ( da>db ) return 1;
369: else if ( da<db ) return -1;
370: else return 0;
371: }
372:
373: void dl_print(DL d,int n)
374: {
375: int i;
376:
377: printf("<<");
378: for ( i = 0; i < n; i++ )
379: printf("%d ",d->d[i]);
380: printf(">>\n");
381: }
382:
383: int simple_check(VECT b,int nv)
384: {
385: int n,i,j;
386: DL *p;
387:
388: n = b->len; p = (DL *)b->body;
389: for ( i = 0; i < n; i++ ) {
390: for ( j = 0; j < nv; j++ ) {
391: if ( p[i]->d[j] ) break;
392: }
393: if ( p[i]->d[j] != p[i]->td ) return 0;
394: }
395: return 1;
396: }
397:
398: void make_reduced(VECT b,int nv)
399: {
400: int n,i,j;
401: DL *p;
402: DL pi;
403:
404: n = b->len;
405: p = (DL *)BDY(b);
406: for ( i = 0; i < n; i++ ) {
407: pi = p[i];
408: if ( !pi ) continue;
409: for ( j = 0; j < n; j++ )
410: if ( i != j && p[j] && _dl_redble(pi,p[j],nv) ) p[j] = 0;
411: }
412: for ( i = j = 0; i < n; i++ )
413: if ( p[i] ) p[j++] = p[i];
414: b->len = j;
415: }
416:
417: void make_reduced2(VECT b,int k,int nv)
418: {
419: int n,i,j,l;
420: DL *p;
421: DL pi;
422:
423: n = b->len;
424: p = (DL *)BDY(b);
425: for ( i = l = k; i < n; i++ ) {
426: pi = p[i];
427: for ( j = 0; j < k; j++ )
428: if ( _dl_redble(p[j],pi,nv) ) break;
429: if ( j == k )
430: p[l++] = pi;
431: }
432: b->len = l;
433: }
434:
435: int i_all,i_simple;
436:
437: P mhp_simple(VECT b,VECT x,P t)
438: {
439: int n,i,j,nv;
440: DL *p;
441: P hp,mt,s,w;
442: Z z;
443:
444: n = b->len; nv = x->len; p = (DL *)BDY(b);
445: hp = (P)ONE;
446: for ( i = 0; i < n; i++ ) {
447: for ( j = 0; j < nv; j++ )
448: if ( p[i]->d[j] ) break;
449: STOZ(p[i]->d[j],z);
450: chsgnp(t,&mt); mt->dc->d =z;
451: addp(CO,mt,(P)ONE,&s); mulp(CO,hp,s,&w); hp = w;
452: }
453: return hp;
454: }
455:
456: struct oEGT eg_comp;
457:
458: void mhp_rec(VECT b,VECT x,P t,P *r)
459: {
460: int n,i,j,k,l,i2,nv,len;
461: int *d;
462: Z mone,z;
463: DCP dc,dc1;
464: P s;
465: P *r2;
466: DL *p,*q;
467: DL pi,xj,d1;
468: VECT c;
469: struct oEGT eg0,eg1;
470:
471: i_all++;
472: n = b->len; nv = x->len; p = (DL *)BDY(b);
473: if ( !n ) {
474: r[0] = (P)ONE;
475: return;
476: }
477: if ( n == 1 && p[0]->td == 0 )
478: return;
479: for ( i = 0; i < n; i++ )
480: if ( p[i]->td > 1 ) break;
481: if ( i == n ) {
482: r[n] = (P)ONE;
483: return;
484: }
485: #if 0
486: if ( simple_check(b,nv) ) {
487: i_simple++;
488: r[0] = mhp_simple(b,x,t);
489: return;
490: }
491: #endif
492: for ( j = 0, d = p[i]->d; j < nv; j++ )
493: if ( d[j] ) break;
494: xj = BDY(x)[j];
495: MKVECT(c,n); q = (DL *)BDY(c);
496: for ( i = k = l = 0; i < n; i++ )
497: if ( p[i]->d[j] ) {
498: pi = p[i];
499: NEWDL(d1,nv); d1->td =pi->td - 1;
500: memcpy(d1->d,pi->d,nv*sizeof(int));
501: d1->d[j]--;
502: p[k++] = d1;
503: } else
504: q[l++] = p[i];
505: for ( i = k, i2 = 0; i2 < l; i++, i2++ )
506: p[i] = q[i2];
507: /* b=(b[0]/xj,...,b[k-1]/xj,b[k],...b[n-1]) where
508: b[0],...,b[k-1] are divisible by k */
509: make_reduced2(b,k,nv);
510: mhp_rec(b,x,t,r);
511: /* c = (b[0],...,b[l-1],xj) */
512: q[l] = xj; c->len = l+1;
513: r2 = (P *)CALLOC(nv+1,sizeof(P));
514: mhp_rec(c,x,t,r2);
515: // get_eg(&eg0);
516: for ( i = 0; i <= nv; i++ ) {
517: mulp(CO,r[i],t,&s); addp(CO,s,r2[i],&r[i]);
518: }
519: // get_eg(&eg1); add_eg(&eg_comp,&eg0,&eg1);
520: }
521:
1.4 noro 522: /* (n+a)Cb as a polynomial of n; return (n+a)*...*(n+a-b+1) */
523:
524: P binpoly(P n,int a,int b)
525: {
526: Z z;
527: P s,r,t;
528: int i;
529:
530: STOZ(a,z); addp(CO,n,(P)z,&s); r = (P)ONE;
531: for ( i = 0; i < b; i++ ) {
532: mulp(CO,r,s,&t); r = t;
533: subp(CO,s,(P)ONE,&t); s = t;
534: }
535: return r;
536: }
537:
1.9 noro 538: void ibin(unsigned long int n,unsigned long int k,Z *r);
539:
1.8 noro 540: void mhp_to_hf(VL vl,P hp,int n,P *plist,VECT *head,P *hf)
1.5 noro 541: {
542: P tv,gcd,q,h,hphead,tt,ai,hpoly,nv,bp,w;
1.8 noro 543: Z d,z;
1.5 noro 544: DCP dc,topdc;
545: VECT hfhead;
546: int i,s,qd;
547:
548: if ( !hp ) {
549: MKVECT(hfhead,0); *head = hfhead;
1.8 noro 550: *hf = 0;
1.5 noro 551: } else {
552: makevar("t",&tv);
553: ezgcdp(CO,hp,plist[n],&gcd);
554: if ( NUM(gcd) ) {
555: s = n;
556: q = hp;
557: } else {
558: s = n-ZTOS(DEG(DC(gcd)));
559: divsp(CO,hp,plist[n-s],&q);
560: }
561: if ( NUM(q) ) qd = 0;
562: else qd = ZTOS(DEG(DC(q)));
1.6 noro 563: if ( s == 0 ) {
564: MKVECT(hfhead,qd+1);
565: for ( i = 0; i <= qd; i++ ) {
566: coefp(q,i,(P *)&BDY(hfhead)[i]);
1.5 noro 567: }
1.6 noro 568: *head = hfhead;
569: *hf = 0;
570: } else {
571: if ( qd ) {
572: topdc = 0;
573: for ( i = 0; i < qd; i++ ) {
574: NEWDC(dc); NEXT(dc) = topdc;
1.9 noro 575: ibin(i+s-1,s-1,(Z *)&COEF(dc));
1.6 noro 576: STOZ(i,d); DEG(dc) = d;
577: topdc = dc;
578: }
579: MKP(VR(tv),topdc,h);
580: mulp(CO,h,q,&hphead);
581: }
582: MKVECT(hfhead,qd);
583: for ( i = 0; i < qd; i++ )
584: coefp(hphead,i,(P *)&BDY(hfhead)[i]);
585: *head = hfhead;
586: hpoly = 0;
587: makevar("n",&nv);
588: for ( i = 0; i <= qd; i++ ) {
589: coefp(q,i,&ai);
590: bp = binpoly(nv,s-i-1,s-1);
591: mulp(CO,ai,bp,&tt);
592: addp(CO,hpoly,tt,&w);
593: hpoly = w;
594: }
1.8 noro 595: if ( s > 2 ) {
596: factorialz(s-1,&z);
597: divsp(CO,hpoly,(P)z,&tt); hpoly = tt;
598: }
1.6 noro 599: *hf = hpoly;
1.8 noro 600: for ( i = qd-1; i >= 0; i-- ) {
601: UTOZ(i,z);
602: substp(CO,hpoly,VR(nv),(P)z,&tt);
603: if ( cmpz((Z)tt,(Z)BDY(hfhead)[i]) ) break;
604: }
605: hfhead->len = i+1;
1.5 noro 606: }
607: }
608: }
609:
610: /* create (1,1-t,...,(1-t)^n) */
611:
612: P *mhp_prep(int n,P *tv) {
613: P *plist;
614: P mt,t1;
615: int i;
616:
617: plist = (P *)MALLOC((n+1)*sizeof(P));
618: /* t1 = 1-t */
619: makevar("t",tv); chsgnp(*tv,&mt); addp(CO,mt,(P)ONE,&t1);
620: for ( plist[0] = (P)ONE, i = 1; i <= n; i++ )
621: mulp(CO,plist[i-1],t1,&plist[i]);
622: return plist;
623: }
624:
625: P mhp_ctop(P *r,P *plist,int n)
626: {
627: int i;
628: P hp,u,w;
629:
630: for ( hp = 0, i = 0; i <= n; i++ ) {
631: mulp(CO,plist[i],r[i],&u); addp(CO,u,hp,&w); hp = w;
632: }
633: return hp;
634: }
635:
1.3 noro 636: void Pdp_monomial_hilbert_poincare(NODE arg,LIST *rp)
637: {
638: LIST g,v;
639: VL vl;
1.5 noro 640: int m,n,i;
641: VECT b,x,hfhead;
1.3 noro 642: NODE t,nd;
1.5 noro 643: Z z,den;
644: P hp,tv,mt,t1,u,w,hpoly;
1.3 noro 645: DP a;
646: DL *p;
647: P *plist,*r;
1.4 noro 648: Obj val;
1.3 noro 649:
650: i_simple = i_all = 0;
651: g = (LIST)ARG0(arg); v = (LIST)ARG1(arg);
652: pltovl(v,&vl);
653: m = length(BDY(g)); MKVECT(b,m); p = (DL *)BDY(b);
654: for ( t = BDY(g), i = 0; t; t = NEXT(t), i++ ) {
1.5 noro 655: if ( !BDY(t) )
656: p[i] = 0;
657: else {
658: ptod(CO,vl,(P)BDY(t),&a); p[i] = BDY(a)->dl;
659: }
1.3 noro 660: }
661: n = length(BDY(v)); MKVECT(x,n); p = (DL *)BDY(x);
662: for ( t = BDY(v), i = 0; t; t = NEXT(t), i++ ) {
663: ptod(CO,vl,(P)BDY(t),&a); p[i] = BDY(a)->dl;
664: }
1.5 noro 665:
1.3 noro 666: r = (P *)CALLOC(n+1,sizeof(P));
1.5 noro 667: plist = mhp_prep(n,&tv);
1.3 noro 668: make_reduced(b,n);
669: mhp_rec(b,x,tv,r);
1.5 noro 670: hp = mhp_ctop(r,plist,n);
1.8 noro 671: mhp_to_hf(CO,hp,n,plist,&hfhead,&hpoly);
1.4 noro 672: UTOZ(n,z);
1.8 noro 673: nd = mknode(4,hp,z,hfhead,hpoly);
1.5 noro 674: MKLIST(*rp,nd);
1.3 noro 675: }
1.5 noro 676:
1.1 noro 677: void Pdp_compute_last_t(NODE arg,LIST *rp)
678: {
679: NODE g,gh,homo,n;
680: LIST hlist;
681: VECT v1,v2,w;
682: Q t;
683:
684: g = (NODE)BDY((LIST)ARG0(arg));
685: gh = (NODE)BDY((LIST)ARG1(arg));
686: t = (Q)ARG2(arg);
687: v1 = (VECT)ARG3(arg);
688: v2 = (VECT)ARG4(arg);
689: t = compute_last_t(g,gh,t,v1,v2,&homo,&w);
690: MKLIST(hlist,homo);
691: n = mknode(3,t,w,hlist);
692: MKLIST(*rp,n);
693: }
694:
695: void Pdp_compute_last_w(NODE arg,LIST *rp)
696: {
697: NODE g,gh,r;
698: VECT w,rv;
699: LIST l;
700: MAT w1,w2;
701: int row1,row2,i,j,n;
702: int *v;
703: int **m1,**m2;
704: Z q;
705:
706: g = (NODE)BDY((LIST)ARG0(arg));
707: gh = (NODE)BDY((LIST)ARG1(arg));
708: w = (VECT)ARG2(arg);
709: w1 = (MAT)ARG3(arg);
710: w2 = (MAT)ARG4(arg);
711: n = w1->col;
712: row1 = w1->row;
713: row2 = w2->row;
714: if ( w ) {
715: v = W_ALLOC(n);
1.2 noro 716: for ( i = 0; i < n; i++ ) v[i] = ZTOS((Q)w->body[i]);
1.1 noro 717: } else v = 0;
718: m1 = almat(row1,n);
719: for ( i = 0; i < row1; i++ )
1.2 noro 720: for ( j = 0; j < n; j++ ) m1[i][j] = ZTOS((Q)w1->body[i][j]);
1.1 noro 721: m2 = almat(row2,n);
722: for ( i = 0; i < row2; i++ )
1.2 noro 723: for ( j = 0; j < n; j++ ) m2[i][j] = ZTOS((Q)w2->body[i][j]);
1.1 noro 724: r = compute_last_w(g,gh,n,&v,row1,m1,row2,m2);
725: if ( !r ) *rp = 0;
726: else {
727: MKVECT(rv,n);
728: for ( i = 0; i < n; i++ ) {
1.2 noro 729: STOZ(v[i],q); rv->body[i] = (pointer)q;
1.1 noro 730: }
731: MKLIST(l,r);
732: r = mknode(2,rv,l);
733: MKLIST(*rp,r);
734: }
735: }
736:
737: NODE compute_essential_df(DP *g,DP *gh,int n);
738:
739: void Pdp_compute_essential_df(NODE arg,LIST *rp)
740: {
741: VECT g,gh;
742: NODE r;
743:
744: g = (VECT)ARG0(arg);
745: gh = (VECT)ARG1(arg);
746: r = (NODE)compute_essential_df((DP *)BDY(g),(DP *)BDY(gh),g->len);
747: MKLIST(*rp,r);
748: }
749:
750: void Pdp_inv_or_split(NODE arg,Obj *rp)
751: {
752: NODE gb,newgb;
753: DP f,inv;
754: struct order_spec *spec;
755: LIST list;
756:
757: do_weyl = 0; dp_fcoeffs = 0;
758: asir_assert(ARG0(arg),O_LIST,"dp_inv_or_split");
759: asir_assert(ARG1(arg),O_DP,"dp_inv_or_split");
760: if ( !create_order_spec(0,(Obj)ARG2(arg),&spec) )
761: error("dp_inv_or_split : invalid order specification");
762: gb = BDY((LIST)ARG0(arg));
763: f = (DP)ARG1(arg);
764: newgb = (NODE)dp_inv_or_split(gb,f,spec,&inv);
765: if ( !newgb ) {
766: /* invertible */
767: *rp = (Obj)inv;
768: } else {
769: MKLIST(list,newgb);
770: *rp = (Obj)list;
771: }
772: }
773:
774: void Pdp_sort(NODE arg,DP *rp)
775: {
776: dp_sort((DP)ARG0(arg),rp);
777: }
778:
779: void Pdp_mdtod(NODE arg,DP *rp)
780: {
781: MP m,mr,mr0;
782: DP p;
783: P t;
784:
785: p = (DP)ARG0(arg);
786: if ( !p )
787: *rp = 0;
788: else {
789: for ( mr0 = 0, m = BDY(p); m; m = NEXT(m) ) {
790: mptop((P)m->c,&t); NEXTMP(mr0,mr); mr->c = (Obj)t; mr->dl = m->dl;
791: }
792: NEXT(mr) = 0; MKDP(p->nv,mr0,*rp); (*rp)->sugar = p->sugar;
793: }
794: }
795:
796: void Pdp_sep(NODE arg,VECT *rp)
797: {
798: DP p,r;
799: MP m,t;
800: MP *w0,*w;
801: int i,n,d,nv,sugar;
802: VECT v;
803: pointer *pv;
804:
805: p = (DP)ARG0(arg); m = BDY(p);
1.2 noro 806: d = ZTOS((Q)ARG1(arg));
1.1 noro 807: for ( t = m, n = 0; t; t = NEXT(t), n++ );
808: if ( d > n )
809: d = n;
810: MKVECT(v,d); *rp = v;
811: pv = BDY(v); nv = p->nv; sugar = p->sugar;
812: w0 = (MP *)MALLOC(d*sizeof(MP)); bzero(w0,d*sizeof(MP));
813: w = (MP *)MALLOC(d*sizeof(MP)); bzero(w,d*sizeof(MP));
814: for ( t = BDY(p), i = 0; t; t = NEXT(t), i++, i %= d ) {
815: NEXTMP(w0[i],w[i]); w[i]->c = t->c; w[i]->dl = t->dl;
816: }
817: for ( i = 0; i < d; i++ ) {
818: NEXT(w[i]) = 0; MKDP(nv,w0[i],r); r->sugar = sugar;
819: pv[i] = (pointer)r;
820: }
821: }
822:
823: void Pdp_idiv(NODE arg,DP *rp)
824: {
825: dp_idiv((DP)ARG0(arg),(Z)ARG1(arg),rp);
826: }
827:
828: void Pdp_cont(NODE arg,Z *rp)
829: {
830: dp_cont((DP)ARG0(arg),rp);
831: }
832:
1.21 noro 833: void dpm_ptozp(DPM p,Z *cont,DPM *r);
834:
835: void Pdpm_remove_cont(NODE arg,LIST *rp)
836: {
837: NODE nd;
838: Z cont;
839: DPM p;
840:
841: dpm_ptozp((DPM)ARG0(arg),&cont,&p);
842: nd = mknode(2,cont,p);
843: MKLIST(*rp,nd);
844: }
845:
1.1 noro 846: void Pdp_dtov(NODE arg,VECT *rp)
847: {
848: dp_dtov((DP)ARG0(arg),rp);
849: }
850:
851: void Pdp_mbase(NODE arg,LIST *rp)
852: {
853: NODE mb;
854:
855: asir_assert(ARG0(arg),O_LIST,"dp_mbase");
856: dp_mbase(BDY((LIST)ARG0(arg)),&mb);
857: MKLIST(*rp,mb);
858: }
859:
860: void Pdp_etov(NODE arg,VECT *rp)
861: {
862: DP dp;
863: int n,i;
864: int *d;
865: VECT v;
866: Z t;
867:
868: dp = (DP)ARG0(arg);
869: asir_assert(dp,O_DP,"dp_etov");
870: n = dp->nv; d = BDY(dp)->dl->d;
871: MKVECT(v,n);
872: for ( i = 0; i < n; i++ ) {
1.2 noro 873: STOZ(d[i],t); v->body[i] = (pointer)t;
1.1 noro 874: }
875: *rp = v;
876: }
877:
878: void Pdp_vtoe(NODE arg,DP *rp)
879: {
880: DP dp;
881: DL dl;
882: MP m;
883: int n,i,td;
884: int *d;
885: VECT v;
886:
887: v = (VECT)ARG0(arg);
888: asir_assert(v,O_VECT,"dp_vtoe");
889: n = v->len;
890: NEWDL(dl,n); d = dl->d;
891: for ( i = 0, td = 0; i < n; i++ ) {
1.2 noro 892: d[i] = ZTOS((Q)(v->body[i])); td += MUL_WEIGHT(d[i],i);
1.1 noro 893: }
894: dl->td = td;
895: NEWMP(m); m->dl = dl; m->c = (Obj)ONE; NEXT(m) = 0;
896: MKDP(n,m,dp); dp->sugar = td;
897: *rp = dp;
898: }
899:
900: void Pdp_lnf_mod(NODE arg,LIST *rp)
901: {
902: DP r1,r2;
903: NODE b,g,n;
904: int mod;
905:
906: asir_assert(ARG0(arg),O_LIST,"dp_lnf_mod");
907: asir_assert(ARG1(arg),O_LIST,"dp_lnf_mod");
908: asir_assert(ARG2(arg),O_N,"dp_lnf_mod");
909: b = BDY((LIST)ARG0(arg)); g = BDY((LIST)ARG1(arg));
1.2 noro 910: mod = ZTOS((Q)ARG2(arg));
1.1 noro 911: dp_lnf_mod((DP)BDY(b),(DP)BDY(NEXT(b)),g,mod,&r1,&r2);
912: NEWNODE(n); BDY(n) = (pointer)r1;
913: NEWNODE(NEXT(n)); BDY(NEXT(n)) = (pointer)r2;
914: NEXT(NEXT(n)) = 0; MKLIST(*rp,n);
915: }
916:
917: void Pdp_lnf_f(NODE arg,LIST *rp)
918: {
919: DP r1,r2;
920: NODE b,g,n;
921:
922: asir_assert(ARG0(arg),O_LIST,"dp_lnf_f");
923: asir_assert(ARG1(arg),O_LIST,"dp_lnf_f");
924: b = BDY((LIST)ARG0(arg)); g = BDY((LIST)ARG1(arg));
925: dp_lnf_f((DP)BDY(b),(DP)BDY(NEXT(b)),g,&r1,&r2);
926: NEWNODE(n); BDY(n) = (pointer)r1;
927: NEWNODE(NEXT(n)); BDY(NEXT(n)) = (pointer)r2;
928: NEXT(NEXT(n)) = 0; MKLIST(*rp,n);
929: }
930:
931: void Pdp_nf_tab_mod(NODE arg,DP *rp)
932: {
933: asir_assert(ARG0(arg),O_DP,"dp_nf_tab_mod");
934: asir_assert(ARG1(arg),O_VECT,"dp_nf_tab_mod");
935: asir_assert(ARG2(arg),O_N,"dp_nf_tab_mod");
936: dp_nf_tab_mod((DP)ARG0(arg),(LIST *)BDY((VECT)ARG1(arg)),
1.2 noro 937: ZTOS((Q)ARG2(arg)),rp);
1.1 noro 938: }
939:
940: void Pdp_nf_tab_f(NODE arg,DP *rp)
941: {
942: asir_assert(ARG0(arg),O_DP,"dp_nf_tab_f");
943: asir_assert(ARG1(arg),O_VECT,"dp_nf_tab_f");
944: dp_nf_tab_f((DP)ARG0(arg),(LIST *)BDY((VECT)ARG1(arg)),rp);
945: }
946:
1.9 noro 947: extern int dpm_ordtype;
948:
1.1 noro 949: void Pdp_ord(NODE arg,Obj *rp)
950: {
951: struct order_spec *spec;
952: LIST v;
953: struct oLIST f;
954: Num homo;
955: int modular;
956:
957: f.id = O_LIST; f.body = 0;
958: if ( !arg && !current_option )
959: *rp = dp_current_spec->obj;
960: else {
961: if ( current_option )
962: parse_gr_option(&f,current_option,&v,&homo,&modular,&spec);
963: else if ( !create_order_spec(0,(Obj)ARG0(arg),&spec) )
964: error("dp_ord : invalid order specification");
965: initd(spec); *rp = spec->obj;
1.15 noro 966: if ( spec->id >= 256 ) dpm_ordtype = spec->module_ordtype;
1.1 noro 967: }
968: }
969:
970: void Pdp_ptod(NODE arg,DP *rp)
971: {
972: P p;
973: NODE n;
974: VL vl,tvl;
975: struct oLIST f;
976: int ac;
977: LIST v;
978: Num homo;
979: int modular;
980: struct order_spec *ord;
981:
982: asir_assert(ARG0(arg),O_P,"dp_ptod");
983: p = (P)ARG0(arg);
984: ac = argc(arg);
985: if ( ac == 1 ) {
986: if ( current_option ) {
987: f.id = O_LIST; f.body = mknode(1,p);
988: parse_gr_option(&f,current_option,&v,&homo,&modular,&ord);
989: initd(ord);
990: } else
991: error("dp_ptod : invalid argument");
992: } else {
993: asir_assert(ARG1(arg),O_LIST,"dp_ptod");
994: v = (LIST)ARG1(arg);
995: }
996: for ( vl = 0, n = BDY(v); n; n = NEXT(n) ) {
997: if ( !vl ) {
998: NEWVL(vl); tvl = vl;
999: } else {
1000: NEWVL(NEXT(tvl)); tvl = NEXT(tvl);
1001: }
1002: VR(tvl) = VR((P)BDY(n));
1003: }
1004: if ( vl )
1005: NEXT(tvl) = 0;
1006: ptod(CO,vl,p,rp);
1007: }
1008:
1009: void Phomogenize(NODE arg,Obj *rp)
1010: {
1011: P p;
1012: DP d,h;
1013: NODE n;
1014: V hv;
1015: VL vl,tvl,last;
1016: struct oLIST f;
1017: LIST v;
1018:
1019: asir_assert(ARG0(arg),O_P,"homogenize");
1020: p = (P)ARG0(arg);
1021: asir_assert(ARG1(arg),O_LIST,"homogenize");
1022: v = (LIST)ARG1(arg);
1023: asir_assert(ARG2(arg),O_P,"homogenize");
1024: hv = VR((P)ARG2(arg));
1025: for ( vl = 0, n = BDY(v); n; n = NEXT(n) ) {
1026: if ( !vl ) {
1027: NEWVL(vl); tvl = vl;
1028: } else {
1029: NEWVL(NEXT(tvl)); tvl = NEXT(tvl);
1030: }
1031: VR(tvl) = VR((P)BDY(n));
1032: }
1033: if ( vl ) {
1034: last = tvl;
1035: NEXT(tvl) = 0;
1036: }
1037: ptod(CO,vl,p,&d);
1038: dp_homo(d,&h);
1039: NEWVL(NEXT(last)); last = NEXT(last);
1040: VR(last) = hv; NEXT(last) = 0;
1041: dtop(CO,vl,h,rp);
1042: }
1043:
1044: void Pdp_ltod(NODE arg,DPV *rp)
1045: {
1046: NODE n;
1047: VL vl,tvl;
1048: LIST f,v;
1049: int sugar,i,len,ac,modular;
1050: Num homo;
1051: struct order_spec *ord;
1052: DP *e;
1053: NODE nd,t;
1054:
1055: ac = argc(arg);
1056: asir_assert(ARG0(arg),O_LIST,"dp_ptod");
1057: f = (LIST)ARG0(arg);
1058: if ( ac == 1 ) {
1059: if ( current_option ) {
1060: parse_gr_option(f,current_option,&v,&homo,&modular,&ord);
1061: initd(ord);
1062: } else
1063: error("dp_ltod : invalid argument");
1064: } else {
1065: asir_assert(ARG1(arg),O_LIST,"dp_ptod");
1066: v = (LIST)ARG1(arg);
1067: }
1068: for ( vl = 0, n = BDY(v); n; n = NEXT(n) ) {
1069: if ( !vl ) {
1070: NEWVL(vl); tvl = vl;
1071: } else {
1072: NEWVL(NEXT(tvl)); tvl = NEXT(tvl);
1073: }
1074: VR(tvl) = VR((P)BDY(n));
1075: }
1076: if ( vl )
1077: NEXT(tvl) = 0;
1078:
1079: nd = BDY(f);
1080: len = length(nd);
1081: e = (DP *)MALLOC(len*sizeof(DP));
1082: sugar = 0;
1083: for ( i = 0, t = nd; i < len; i++, t = NEXT(t) ) {
1084: ptod(CO,vl,(P)BDY(t),&e[i]);
1085: if ( e[i] )
1086: sugar = MAX(sugar,e[i]->sugar);
1087: }
1088: MKDPV(len,e,*rp);
1089: }
1090:
1091: void Pdpm_ltod(NODE arg,DPM *rp)
1092: {
1093: NODE n;
1094: VL vl,tvl;
1095: LIST f,v;
1096: int i,len;
1097: NODE nd;
1098: NODE t;
1099: DP d;
1100: DPM s,u,w;
1101:
1102: f = (LIST)ARG0(arg);
1103: v = (LIST)ARG1(arg);
1104: for ( vl = 0, n = BDY(v); n; n = NEXT(n) ) {
1105: if ( !vl ) {
1106: NEWVL(vl); tvl = vl;
1107: } else {
1108: NEWVL(NEXT(tvl)); tvl = NEXT(tvl);
1109: }
1110: VR(tvl) = VR((P)BDY(n));
1111: }
1112: if ( vl )
1113: NEXT(tvl) = 0;
1114:
1115: nd = BDY(f);
1116: len = length(nd);
1.9 noro 1117: for ( i = 1, t = nd, s = 0; i <= len; i++, t = NEXT(t) ) {
1.1 noro 1118: ptod(CO,vl,(P)BDY(t),&d);
1119: dtodpm(d,i,&u);
1120: adddpm(CO,s,u,&w); s = w;
1121: }
1122: *rp = s;
1123: }
1124:
1.9 noro 1125: // c*[monomial,i]+... -> c*<<monomial:i>>+...
1126:
1127: void Pdpm_dptodpm(NODE arg,DPM *rp)
1128: {
1129: DP p;
1130: MP mp;
1.16 noro 1131: int pos,shift;
1.9 noro 1132: DMM m0,m;
1133:
1134: p = (DP)ARG0(arg);
1135: pos = ZTOS((Z)ARG1(arg));
1136: if ( pos <= 0 )
1137: error("dpm_mtod : position must be positive");
1138: if ( !p ) *rp = 0;
1139: else {
1140: for ( m0 = 0, mp = BDY(p); mp; mp = NEXT(mp) ) {
1141: NEXTDMM(m0,m); m->dl = mp->dl; m->c = mp->c; m->pos = pos;
1142: }
1.21 noro 1143: if ( dp_current_spec->module_top_weight ) {
1.16 noro 1144: if ( pos > dp_current_spec->module_rank )
1145: error("dpm_dptodpm : inconsistent order spec");
1146: shift = dp_current_spec->module_top_weight[pos-1];
1147: m->dl->td += shift;
1148: } else
1149: shift = 0;
1150:
1151: MKDPM(p->nv,m0,*rp); (*rp)->sugar = p->sugar+shift;
1.9 noro 1152: }
1153: }
1154:
1.1 noro 1155: void Pdpm_dtol(NODE arg,LIST *rp)
1156: {
1157: DPM a;
1158: NODE nd,nd1;
1159: VL vl,tvl;
1160: int n,len,i,pos,nv;
1161: MP *w;
1162: DMM t;
1163: DMM *wa;
1164: MP m;
1165: DP u;
1166: Obj s;
1167:
1168: a = (DPM)ARG0(arg);
1.14 noro 1169: if ( !a ) {
1170: MKLIST(*rp,0);
1171: return;
1172: }
1.1 noro 1173: for ( vl = 0, nd = BDY((LIST)ARG1(arg)), nv = 0; nd; nd = NEXT(nd), nv++ ) {
1174: if ( !vl ) {
1175: NEWVL(vl); tvl = vl;
1176: } else {
1177: NEWVL(NEXT(tvl)); tvl = NEXT(tvl);
1178: }
1179: VR(tvl) = VR((P)BDY(nd));
1180: }
1181: if ( vl )
1182: NEXT(tvl) = 0;
1.14 noro 1183: for ( t = BDY(a), n = 0; t; t = NEXT(t) )
1184: if ( t->pos > n ) n = t->pos;
1.1 noro 1185: w = (MP *)CALLOC(n,sizeof(MP));
1186: for ( t = BDY(a), len = 0; t; t = NEXT(t) ) len++;
1187: wa = (DMM *)MALLOC(len*sizeof(DMM));
1188: for ( t = BDY(a), i = 0; t; t = NEXT(t), i++ ) wa[i] = t;
1189: for ( i = len-1; i >= 0; i-- ) {
1190: NEWMP(m); m->dl = wa[i]->dl; C(m) = C(wa[i]);
1191: pos = wa[i]->pos;
1.14 noro 1192: NEXT(m) = w[pos-1];
1193: w[pos-1] = m;
1.1 noro 1194: }
1195: nd = 0;
1196: for ( i = n-1; i >= 0; i-- ) {
1197: MKDP(nv,w[i],u); u->sugar = a->sugar; /* XXX */
1198: dtop(CO,vl,u,&s);
1199: MKNODE(nd1,s,nd); nd = nd1;
1200: }
1201: MKLIST(*rp,nd);
1202: }
1203:
1204: void Pdp_dtop(NODE arg,Obj *rp)
1205: {
1206: NODE n;
1207: VL vl,tvl;
1208:
1209: asir_assert(ARG0(arg),O_DP,"dp_dtop");
1210: asir_assert(ARG1(arg),O_LIST,"dp_dtop");
1211: for ( vl = 0, n = BDY((LIST)ARG1(arg)); n; n = NEXT(n) ) {
1212: if ( !vl ) {
1213: NEWVL(vl); tvl = vl;
1214: } else {
1215: NEWVL(NEXT(tvl)); tvl = NEXT(tvl);
1216: }
1217: VR(tvl) = VR((P)BDY(n));
1218: }
1219: if ( vl )
1220: NEXT(tvl) = 0;
1221: dtop(CO,vl,(DP)ARG0(arg),rp);
1222: }
1223:
1224: extern LIST Dist;
1225:
1226: void Pdp_ptozp(NODE arg,Obj *rp)
1227: {
1228: Z t;
1229: NODE tt,p;
1230: NODE n,n0;
1231: char *key;
1232: DP pp;
1233: LIST list;
1234: int get_factor=0;
1235:
1236: asir_assert(ARG0(arg),O_DP,"dp_ptozp");
1237:
1238: /* analyze the option */
1239: if ( current_option ) {
1240: for ( tt = current_option; tt; tt = NEXT(tt) ) {
1241: p = BDY((LIST)BDY(tt));
1242: key = BDY((STRING)BDY(p));
1243: /* value = (Obj)BDY(NEXT(p)); */
1244: if ( !strcmp(key,"factor") ) get_factor=1;
1245: else {
1246: error("ptozp: unknown option.");
1247: }
1248: }
1249: }
1250:
1251: dp_ptozp3((DP)ARG0(arg),&t,&pp);
1252:
1253: /* printexpr(NULL,t); */
1254: /* if the option factor is given, then it returns the answer
1255: in the format [zpoly, num] where num*zpoly is equal to the argument.*/
1256: if (get_factor) {
1257: n0 = mknode(2,pp,t);
1258: MKLIST(list,n0);
1259: *rp = (Obj)list;
1260: } else
1261: *rp = (Obj)pp;
1262: }
1263:
1264: void Pdp_ptozp2(NODE arg,LIST *rp)
1265: {
1266: DP p0,p1,h,r;
1267: NODE n0;
1268:
1269: p0 = (DP)ARG0(arg); p1 = (DP)ARG1(arg);
1270: asir_assert(p0,O_DP,"dp_ptozp2");
1271: asir_assert(p1,O_DP,"dp_ptozp2");
1272: dp_ptozp2(p0,p1,&h,&r);
1273: NEWNODE(n0); BDY(n0) = (pointer)h;
1274: NEWNODE(NEXT(n0)); BDY(NEXT(n0)) = (pointer)r;
1275: NEXT(NEXT(n0)) = 0;
1276: MKLIST(*rp,n0);
1277: }
1278:
1279: void Pdp_prim(NODE arg,DP *rp)
1280: {
1281: DP t;
1282:
1283: asir_assert(ARG0(arg),O_DP,"dp_prim");
1284: dp_prim((DP)ARG0(arg),&t); dp_ptozp(t,rp);
1285: }
1286:
1287: void Pdp_mod(NODE arg,DP *rp)
1288: {
1289: DP p;
1290: int mod;
1291: NODE subst;
1292:
1293: asir_assert(ARG0(arg),O_DP,"dp_mod");
1294: asir_assert(ARG1(arg),O_N,"dp_mod");
1295: asir_assert(ARG2(arg),O_LIST,"dp_mod");
1.2 noro 1296: p = (DP)ARG0(arg); mod = ZTOS((Q)ARG1(arg));
1.1 noro 1297: subst = BDY((LIST)ARG2(arg));
1298: dp_mod(p,mod,subst,rp);
1299: }
1300:
1.26 noro 1301: void dpm_mod(DPM,int,DPM *);
1302:
1303: void Pdpm_mod(NODE arg,DPM *rp)
1304: {
1305: DPM p;
1306: int mod;
1307: NODE subst;
1308:
1309: asir_assert(ARG0(arg),O_DP,"dp_mod");
1310: asir_assert(ARG1(arg),O_N,"dp_mod");
1311: p = (DPM)ARG0(arg); mod = ZTOS((Q)ARG1(arg));
1312: dpm_mod(p,mod,rp);
1313: }
1314:
1315:
1.1 noro 1316: void Pdp_rat(NODE arg,DP *rp)
1317: {
1318: asir_assert(ARG0(arg),O_DP,"dp_rat");
1319: dp_rat((DP)ARG0(arg),rp);
1320: }
1321:
1322: extern int DP_Multiple;
1323:
1324: void Pdp_nf(NODE arg,DP *rp)
1325: {
1326: NODE b;
1327: DP *ps;
1328: DP g;
1329: int full;
1330:
1331: do_weyl = 0; dp_fcoeffs = 0;
1332: asir_assert(ARG0(arg),O_LIST,"dp_nf");
1333: asir_assert(ARG1(arg),O_DP,"dp_nf");
1334: asir_assert(ARG2(arg),O_VECT,"dp_nf");
1335: asir_assert(ARG3(arg),O_N,"dp_nf");
1336: if ( !(g = (DP)ARG1(arg)) ) {
1337: *rp = 0; return;
1338: }
1339: b = BDY((LIST)ARG0(arg)); ps = (DP *)BDY((VECT)ARG2(arg));
1340: full = (Q)ARG3(arg) ? 1 : 0;
1341: dp_nf_z(b,g,ps,full,DP_Multiple,rp);
1342: }
1343:
1344: void Pdp_weyl_nf(NODE arg,DP *rp)
1345: {
1346: NODE b;
1347: DP *ps;
1348: DP g;
1349: int full;
1350:
1351: asir_assert(ARG0(arg),O_LIST,"dp_weyl_nf");
1352: asir_assert(ARG1(arg),O_DP,"dp_weyl_nf");
1353: asir_assert(ARG2(arg),O_VECT,"dp_weyl_nf");
1354: asir_assert(ARG3(arg),O_N,"dp_weyl_nf");
1355: if ( !(g = (DP)ARG1(arg)) ) {
1356: *rp = 0; return;
1357: }
1358: b = BDY((LIST)ARG0(arg)); ps = (DP *)BDY((VECT)ARG2(arg));
1359: full = (Q)ARG3(arg) ? 1 : 0;
1360: do_weyl = 1;
1361: dp_nf_z(b,g,ps,full,DP_Multiple,rp);
1362: do_weyl = 0;
1363: }
1364:
1365: void Pdpm_nf(NODE arg,DPM *rp)
1366: {
1367: NODE b;
1.11 noro 1368: VECT ps;
1.1 noro 1369: DPM g;
1.11 noro 1370: int ac,full;
1.1 noro 1371:
1372: if ( !(g = (DPM)ARG1(arg)) ) {
1373: *rp = 0; return;
1374: }
1375: do_weyl = 0; dp_fcoeffs = 0;
1.11 noro 1376: ac = argc(arg);
1377: if ( ac < 3 )
1378: error("dpm_nf: invalid arguments");
1379: else if ( ac == 3 ) {
1380: asir_assert(ARG1(arg),O_VECT,"dpm_nf");
1381: b = 0; g = (DPM)ARG0(arg); ps = (VECT)ARG1(arg);
1382: } else if ( ac == 4 ) {
1383: asir_assert(ARG0(arg),O_LIST,"dpm_nf");
1384: asir_assert(ARG2(arg),O_VECT,"dpm_nf");
1385: b = BDY((LIST)ARG0(arg)); g = (DPM)ARG1(arg); ps = (VECT)ARG2(arg);
1386: full = (Q)ARG3(arg) ? 1 : 0;
1387: }
1.1 noro 1388: dpm_nf_z(b,g,ps,full,DP_Multiple,rp);
1389: }
1390:
1.9 noro 1391: DP *dpm_nf_and_quotient(NODE b,DPM g,VECT ps,DPM *rp,P *dnp);
1.17 noro 1392: DPM dpm_nf_and_quotient2(NODE b,DPM g,VECT ps,DPM *rp,P *dnp);
1.9 noro 1393:
1394: void Pdpm_nf_and_quotient(NODE arg,LIST *rp)
1395: {
1396: NODE b;
1397: VECT ps;
1398: DPM g,nm;
1399: P dn;
1400: VECT quo;
1401: NODE n;
1402: int ac;
1403:
1404: do_weyl = 0; dp_fcoeffs = 0;
1405: ac = argc(arg);
1406: if ( ac < 2 )
1407: error("dpm_nf_and_quotient : invalid arguments");
1408: else if ( ac == 2 ) {
1.11 noro 1409: asir_assert(ARG1(arg),O_VECT,"dpm_nf_and_quotient");
1.9 noro 1410: b = 0; g = (DPM)ARG0(arg); ps = (VECT)ARG1(arg);
1411: } else if ( ac == 3 ) {
1.11 noro 1412: asir_assert(ARG0(arg),O_LIST,"dpm_nf_and_quotient");
1413: asir_assert(ARG2(arg),O_VECT,"dpm_nf_and_quotient");
1.9 noro 1414: b = BDY((LIST)ARG0(arg)); g = (DPM)ARG1(arg); ps = (VECT)ARG2(arg);
1415: }
1.10 noro 1416: NEWVECT(quo); quo->len = ps->len;
1417: if ( g ) {
1418: quo->body = (pointer *)dpm_nf_and_quotient(b,g,ps,&nm,&dn);
1419: } else {
1420: quo->body = (pointer *)MALLOC(quo->len*sizeof(pointer));
1421: nm = 0; dn = (P)ONE;
1.9 noro 1422: }
1423: n = mknode(3,nm,dn,quo);
1424: MKLIST(*rp,n);
1425: }
1426:
1.17 noro 1427: void Pdpm_nf_and_quotient2(NODE arg,LIST *rp)
1428: {
1429: NODE b;
1430: VECT ps;
1431: DPM g,nm,q;
1432: P dn;
1433: NODE n;
1434: int ac;
1435:
1436: do_weyl = 0; dp_fcoeffs = 0;
1437: ac = argc(arg);
1438: if ( ac < 2 )
1439: error("dpm_nf_and_quotient2 : invalid arguments");
1440: else if ( ac == 2 ) {
1441: asir_assert(ARG1(arg),O_VECT,"dpm_nf_and_quotient2");
1442: b = 0; g = (DPM)ARG0(arg); ps = (VECT)ARG1(arg);
1443: } else if ( ac == 3 ) {
1444: asir_assert(ARG0(arg),O_LIST,"dpm_nf_and_quotient2");
1445: asir_assert(ARG2(arg),O_VECT,"dpm_nf_and_quotient2");
1446: b = BDY((LIST)ARG0(arg)); g = (DPM)ARG1(arg); ps = (VECT)ARG2(arg);
1447: }
1448: if ( g ) {
1449: q = dpm_nf_and_quotient2(b,g,ps,&nm,&dn);
1450: } else {
1451: q = 0; nm = 0; dn = (P)ONE;
1452: }
1453: n = mknode(3,nm,dn,q);
1454: MKLIST(*rp,n);
1455: }
1456:
1.1 noro 1457: void Pdpm_weyl_nf(NODE arg,DPM *rp)
1458: {
1459: NODE b;
1.11 noro 1460: VECT ps;
1.1 noro 1461: DPM g;
1.11 noro 1462: int ac,full;
1.1 noro 1463:
1464: if ( !(g = (DPM)ARG1(arg)) ) {
1465: *rp = 0; return;
1466: }
1.11 noro 1467: do_weyl = 1; dp_fcoeffs = 0;
1468: ac = argc(arg);
1469: if ( ac < 3 )
1470: error("dpm_weyl_nf: invalid arguments");
1471: else if ( ac == 3 ) {
1472: asir_assert(ARG1(arg),O_VECT,"dpm_nf");
1473: b = 0; g = (DPM)ARG0(arg); ps = (VECT)ARG1(arg);
1474: } else if ( ac == 4 ) {
1475: asir_assert(ARG0(arg),O_LIST,"dpm_weyl_nf");
1476: asir_assert(ARG2(arg),O_VECT,"dpm_weyl_nf");
1477: b = BDY((LIST)ARG0(arg)); g = (DPM)ARG1(arg); ps = (VECT)ARG2(arg);
1478: full = (Q)ARG3(arg) ? 1 : 0;
1479: }
1.1 noro 1480: dpm_nf_z(b,g,ps,full,DP_Multiple,rp);
1481: do_weyl = 0;
1482: }
1483:
1484: /* nf computation using field operations */
1485:
1486: void Pdp_nf_f(NODE arg,DP *rp)
1487: {
1488: NODE b;
1489: DP *ps;
1490: DP g;
1491: int full;
1492:
1493: do_weyl = 0;
1494: asir_assert(ARG0(arg),O_LIST,"dp_nf_f");
1495: asir_assert(ARG1(arg),O_DP,"dp_nf_f");
1496: asir_assert(ARG2(arg),O_VECT,"dp_nf_f");
1497: asir_assert(ARG3(arg),O_N,"dp_nf_f");
1498: if ( !(g = (DP)ARG1(arg)) ) {
1499: *rp = 0; return;
1500: }
1501: b = BDY((LIST)ARG0(arg)); ps = (DP *)BDY((VECT)ARG2(arg));
1502: full = (Q)ARG3(arg) ? 1 : 0;
1503: dp_nf_f(b,g,ps,full,rp);
1504: }
1505:
1506: void Pdp_weyl_nf_f(NODE arg,DP *rp)
1507: {
1508: NODE b;
1509: DP *ps;
1510: DP g;
1511: int full;
1512:
1513: asir_assert(ARG0(arg),O_LIST,"dp_weyl_nf_f");
1514: asir_assert(ARG1(arg),O_DP,"dp_weyl_nf_f");
1515: asir_assert(ARG2(arg),O_VECT,"dp_weyl_nf_f");
1516: asir_assert(ARG3(arg),O_N,"dp_weyl_nf_f");
1517: if ( !(g = (DP)ARG1(arg)) ) {
1518: *rp = 0; return;
1519: }
1520: b = BDY((LIST)ARG0(arg)); ps = (DP *)BDY((VECT)ARG2(arg));
1521: full = (Q)ARG3(arg) ? 1 : 0;
1522: do_weyl = 1;
1523: dp_nf_f(b,g,ps,full,rp);
1524: do_weyl = 0;
1525: }
1526:
1527: void Pdpm_nf_f(NODE arg,DPM *rp)
1528: {
1529: NODE b;
1.11 noro 1530: VECT ps;
1.1 noro 1531: DPM g;
1.11 noro 1532: int ac,full;
1.1 noro 1533:
1534: if ( !(g = (DPM)ARG1(arg)) ) {
1535: *rp = 0; return;
1536: }
1.11 noro 1537: ac = argc(arg);
1538: if ( ac < 3 )
1539: error("dpm_nf_f: invalid arguments");
1540: else if ( ac == 3 ) {
1541: asir_assert(ARG1(arg),O_VECT,"dpm_nf_f");
1542: b = 0; g = (DPM)ARG0(arg); ps = (VECT)ARG1(arg);
1543: } else if ( ac == 4 ) {
1544: asir_assert(ARG0(arg),O_LIST,"dpm_nf_f");
1545: asir_assert(ARG2(arg),O_VECT,"dpm_nf_f");
1546: b = BDY((LIST)ARG0(arg)); g = (DPM)ARG1(arg); ps = (VECT)ARG2(arg);
1547: full = (Q)ARG3(arg) ? 1 : 0;
1548: }
1549: do_weyl = 0;
1.1 noro 1550: dpm_nf_f(b,g,ps,full,rp);
1551: }
1552:
1553: void Pdpm_weyl_nf_f(NODE arg,DPM *rp)
1554: {
1555: NODE b;
1.11 noro 1556: VECT ps;
1.1 noro 1557: DPM g;
1.11 noro 1558: int ac,full;
1.1 noro 1559:
1560: if ( !(g = (DPM)ARG1(arg)) ) {
1561: *rp = 0; return;
1562: }
1.11 noro 1563: ac = argc(arg);
1564: if ( ac < 3 )
1565: error("dpm_weyl_nf_f: invalid arguments");
1566: else if ( ac == 3 ) {
1567: asir_assert(ARG1(arg),O_VECT,"dpm_weyl_nf_f");
1568: b = 0; g = (DPM)ARG0(arg); ps = (VECT)ARG1(arg);
1569: } else if ( ac == 4 ) {
1570: asir_assert(ARG0(arg),O_LIST,"dpm_weyl_nf_f");
1571: asir_assert(ARG2(arg),O_VECT,"dpm_weyl_nf_f");
1572: b = BDY((LIST)ARG0(arg)); g = (DPM)ARG1(arg); ps = (VECT)ARG2(arg);
1573: full = (Q)ARG3(arg) ? 1 : 0;
1574: }
1.1 noro 1575: do_weyl = 1;
1576: dpm_nf_f(b,g,ps,full,rp);
1577: do_weyl = 0;
1578: }
1579:
1580:
1581: void Pdp_nf_mod(NODE arg,DP *rp)
1582: {
1583: NODE b;
1584: DP g;
1585: DP *ps;
1586: int mod,full,ac;
1587: NODE n,n0;
1588:
1589: do_weyl = 0;
1590: ac = argc(arg);
1591: asir_assert(ARG0(arg),O_LIST,"dp_nf_mod");
1592: asir_assert(ARG1(arg),O_DP,"dp_nf_mod");
1593: asir_assert(ARG2(arg),O_VECT,"dp_nf_mod");
1594: asir_assert(ARG3(arg),O_N,"dp_nf_mod");
1595: asir_assert(ARG4(arg),O_N,"dp_nf_mod");
1596: if ( !(g = (DP)ARG1(arg)) ) {
1597: *rp = 0; return;
1598: }
1599: b = BDY((LIST)ARG0(arg)); ps = (DP *)BDY((VECT)ARG2(arg));
1.2 noro 1600: full = ZTOS((Q)ARG3(arg)); mod = ZTOS((Q)ARG4(arg));
1.1 noro 1601: for ( n0 = n = 0; b; b = NEXT(b) ) {
1602: NEXTNODE(n0,n);
1.2 noro 1603: BDY(n) = (pointer)ZTOS((Q)BDY(b));
1.1 noro 1604: }
1605: if ( n0 )
1606: NEXT(n) = 0;
1607: dp_nf_mod(n0,g,ps,mod,full,rp);
1608: }
1609:
1610: void Pdp_true_nf(NODE arg,LIST *rp)
1611: {
1612: NODE b,n;
1613: DP *ps;
1614: DP g;
1615: DP nm;
1616: P dn;
1617: int full;
1618:
1619: do_weyl = 0; dp_fcoeffs = 0;
1620: asir_assert(ARG0(arg),O_LIST,"dp_true_nf");
1621: asir_assert(ARG1(arg),O_DP,"dp_true_nf");
1622: asir_assert(ARG2(arg),O_VECT,"dp_true_nf");
1623: asir_assert(ARG3(arg),O_N,"dp_nf");
1624: if ( !(g = (DP)ARG1(arg)) ) {
1625: nm = 0; dn = (P)ONE;
1626: } else {
1627: b = BDY((LIST)ARG0(arg)); ps = (DP *)BDY((VECT)ARG2(arg));
1628: full = (Q)ARG3(arg) ? 1 : 0;
1629: dp_true_nf(b,g,ps,full,&nm,&dn);
1630: }
1631: NEWNODE(n); BDY(n) = (pointer)nm;
1632: NEWNODE(NEXT(n)); BDY(NEXT(n)) = (pointer)dn;
1633: NEXT(NEXT(n)) = 0; MKLIST(*rp,n);
1634: }
1635:
1636: DP *dp_true_nf_and_quotient_marked(NODE b,DP g,DP *ps,DP *hps,DP *rp,P *dnp);
1637:
1638: void Pdp_true_nf_and_quotient_marked(NODE arg,LIST *rp)
1639: {
1640: NODE b,n;
1641: DP *ps,*hps;
1642: DP g;
1643: DP nm;
1644: VECT quo;
1645: P dn;
1646: int full;
1647:
1648: do_weyl = 0; dp_fcoeffs = 0;
1649: asir_assert(ARG0(arg),O_LIST,"dp_true_nf_and_quotient_marked");
1650: asir_assert(ARG1(arg),O_DP,"dp_true_nf_and_quotient_marked");
1651: asir_assert(ARG2(arg),O_VECT,"dp_true_nf_and_quotient_marked");
1652: asir_assert(ARG3(arg),O_VECT,"dp_true_nf_and_quotient_marked");
1653: if ( !(g = (DP)ARG1(arg)) ) {
1654: nm = 0; dn = (P)ONE;
1655: } else {
1656: b = BDY((LIST)ARG0(arg));
1657: ps = (DP *)BDY((VECT)ARG2(arg));
1658: hps = (DP *)BDY((VECT)ARG3(arg));
1659: NEWVECT(quo); quo->len = ((VECT)ARG2(arg))->len;
1660: quo->body = (pointer *)dp_true_nf_and_quotient_marked(b,g,ps,hps,&nm,&dn);
1661: }
1662: n = mknode(3,nm,dn,quo);
1663: MKLIST(*rp,n);
1664: }
1665:
1666: void Pdp_true_nf_and_quotient(NODE arg,LIST *rp)
1667: {
1668: NODE narg = mknode(4,ARG0(arg),ARG1(arg),ARG2(arg),ARG2(arg));
1669: Pdp_true_nf_and_quotient_marked(narg,rp);
1670: }
1671:
1672:
1673: DP *dp_true_nf_and_quotient_marked_mod (NODE b,DP g,DP *ps,DP *hps,int mod,DP *rp,P *dnp);
1674:
1675: void Pdp_true_nf_and_quotient_marked_mod(NODE arg,LIST *rp)
1676: {
1677: NODE b,n;
1678: DP *ps,*hps;
1679: DP g;
1680: DP nm;
1681: VECT quo;
1682: P dn;
1683: int full,mod;
1684:
1685: do_weyl = 0; dp_fcoeffs = 0;
1686: asir_assert(ARG0(arg),O_LIST,"dp_true_nf_and_quotient_marked_mod");
1687: asir_assert(ARG1(arg),O_DP,"dp_true_nf_and_quotient_marked_mod");
1688: asir_assert(ARG2(arg),O_VECT,"dp_true_nf_and_quotient_marked_mod");
1689: asir_assert(ARG3(arg),O_VECT,"dp_true_nf_and_quotient_marked_mod");
1690: asir_assert(ARG4(arg),O_N,"dp_true_nf_and_quotient_marked_mod");
1691: if ( !(g = (DP)ARG1(arg)) ) {
1692: nm = 0; dn = (P)ONE;
1693: } else {
1694: b = BDY((LIST)ARG0(arg));
1695: ps = (DP *)BDY((VECT)ARG2(arg));
1696: hps = (DP *)BDY((VECT)ARG3(arg));
1.2 noro 1697: mod = ZTOS((Q)ARG4(arg));
1.1 noro 1698: NEWVECT(quo); quo->len = ((VECT)ARG2(arg))->len;
1699: quo->body = (pointer *)dp_true_nf_and_quotient_marked_mod(b,g,ps,hps,mod,&nm,&dn);
1700: }
1701: n = mknode(3,nm,dn,quo);
1702: MKLIST(*rp,n);
1703: }
1704:
1705: void Pdp_true_nf_and_quotient_mod(NODE arg,LIST *rp)
1706: {
1707: NODE narg = mknode(5,ARG0(arg),ARG1(arg),ARG2(arg),ARG2(arg),ARG3(arg));
1708: Pdp_true_nf_and_quotient_marked_mod(narg,rp);
1709: }
1710:
1711: void Pdp_true_nf_marked(NODE arg,LIST *rp)
1712: {
1713: NODE b,n;
1714: DP *ps,*hps;
1715: DP g;
1716: DP nm;
1717: Q cont;
1718: P dn;
1719: int full;
1720:
1721: do_weyl = 0; dp_fcoeffs = 0;
1722: asir_assert(ARG0(arg),O_LIST,"dp_true_nf_marked");
1723: asir_assert(ARG1(arg),O_DP,"dp_true_nf_marked");
1724: asir_assert(ARG2(arg),O_VECT,"dp_true_nf_marked");
1725: asir_assert(ARG3(arg),O_VECT,"dp_true_nf_marked");
1726: if ( !(g = (DP)ARG1(arg)) ) {
1727: nm = 0; dn = (P)ONE;
1728: } else {
1729: b = BDY((LIST)ARG0(arg));
1730: ps = (DP *)BDY((VECT)ARG2(arg));
1731: hps = (DP *)BDY((VECT)ARG3(arg));
1732: dp_true_nf_marked(b,g,ps,hps,&nm,(P *)&cont,(P *)&dn);
1733: }
1734: n = mknode(3,nm,cont,dn);
1735: MKLIST(*rp,n);
1736: }
1737:
1738: void Pdp_true_nf_marked_mod(NODE arg,LIST *rp)
1739: {
1740: NODE b,n;
1741: DP *ps,*hps;
1742: DP g;
1743: DP nm;
1744: P dn;
1745: int mod;
1746:
1747: do_weyl = 0; dp_fcoeffs = 0;
1748: asir_assert(ARG0(arg),O_LIST,"dp_true_nf_marked_mod");
1749: asir_assert(ARG1(arg),O_DP,"dp_true_nf_marked_mod");
1750: asir_assert(ARG2(arg),O_VECT,"dp_true_nf_marked_mod");
1751: asir_assert(ARG3(arg),O_VECT,"dp_true_nf_marked_mod");
1752: asir_assert(ARG4(arg),O_N,"dp_true_nf_marked_mod");
1753: if ( !(g = (DP)ARG1(arg)) ) {
1754: nm = 0; dn = (P)ONE;
1755: } else {
1756: b = BDY((LIST)ARG0(arg));
1757: ps = (DP *)BDY((VECT)ARG2(arg));
1758: hps = (DP *)BDY((VECT)ARG3(arg));
1.2 noro 1759: mod = ZTOS((Q)ARG4(arg));
1.1 noro 1760: dp_true_nf_marked_mod(b,g,ps,hps,mod,&nm,&dn);
1761: }
1762: n = mknode(2,nm,dn);
1763: MKLIST(*rp,n);
1764: }
1765:
1766: void Pdp_weyl_nf_mod(NODE arg,DP *rp)
1767: {
1768: NODE b;
1769: DP g;
1770: DP *ps;
1771: int mod,full,ac;
1772: NODE n,n0;
1773:
1774: ac = argc(arg);
1775: asir_assert(ARG0(arg),O_LIST,"dp_weyl_nf_mod");
1776: asir_assert(ARG1(arg),O_DP,"dp_weyl_nf_mod");
1777: asir_assert(ARG2(arg),O_VECT,"dp_weyl_nf_mod");
1778: asir_assert(ARG3(arg),O_N,"dp_weyl_nf_mod");
1779: asir_assert(ARG4(arg),O_N,"dp_weyl_nf_mod");
1780: if ( !(g = (DP)ARG1(arg)) ) {
1781: *rp = 0; return;
1782: }
1783: b = BDY((LIST)ARG0(arg)); ps = (DP *)BDY((VECT)ARG2(arg));
1.2 noro 1784: full = ZTOS((Q)ARG3(arg)); mod = ZTOS((Q)ARG4(arg));
1.1 noro 1785: for ( n0 = n = 0; b; b = NEXT(b) ) {
1786: NEXTNODE(n0,n);
1.2 noro 1787: BDY(n) = (pointer)ZTOS((Q)BDY(b));
1.1 noro 1788: }
1789: if ( n0 )
1790: NEXT(n) = 0;
1791: do_weyl = 1;
1792: dp_nf_mod(n0,g,ps,mod,full,rp);
1793: do_weyl = 0;
1794: }
1795:
1796: void Pdp_true_nf_mod(NODE arg,LIST *rp)
1797: {
1798: NODE b;
1799: DP g,nm;
1800: P dn;
1801: DP *ps;
1802: int mod,full;
1803: NODE n;
1804:
1805: do_weyl = 0;
1806: asir_assert(ARG0(arg),O_LIST,"dp_nf_mod");
1807: asir_assert(ARG1(arg),O_DP,"dp_nf_mod");
1808: asir_assert(ARG2(arg),O_VECT,"dp_nf_mod");
1809: asir_assert(ARG3(arg),O_N,"dp_nf_mod");
1810: asir_assert(ARG4(arg),O_N,"dp_nf_mod");
1811: if ( !(g = (DP)ARG1(arg)) ) {
1812: nm = 0; dn = (P)ONEM;
1813: } else {
1814: b = BDY((LIST)ARG0(arg)); ps = (DP *)BDY((VECT)ARG2(arg));
1.2 noro 1815: full = ZTOS((Q)ARG3(arg)); mod = ZTOS((Q)ARG4(arg));
1.1 noro 1816: dp_true_nf_mod(b,g,ps,mod,full,&nm,&dn);
1817: }
1818: NEWNODE(n); BDY(n) = (pointer)nm;
1819: NEWNODE(NEXT(n)); BDY(NEXT(n)) = (pointer)dn;
1820: NEXT(NEXT(n)) = 0; MKLIST(*rp,n);
1821: }
1822:
1823: void Pdp_weyl_true_nf_and_quotient_marked(NODE arg,LIST *rp)
1824: {
1825: NODE b,n;
1826: DP *ps,*hps;
1827: DP g;
1828: DP nm;
1829: VECT quo;
1830: P dn;
1831: int full;
1832:
1833: do_weyl = 1; dp_fcoeffs = 0;
1834: asir_assert(ARG0(arg),O_LIST,"dp_weyl_true_nf_and_quotient_marked");
1835: asir_assert(ARG1(arg),O_DP,"dp_weyl_true_nf_and_quotient_marked");
1836: asir_assert(ARG2(arg),O_VECT,"dp_weyl_true_nf_and_quotient_marked");
1837: asir_assert(ARG3(arg),O_VECT,"dp_weyl_true_nf_and_quotient_marked");
1838: if ( !(g = (DP)ARG1(arg)) ) {
1839: nm = 0; dn = (P)ONE;
1840: } else {
1841: b = BDY((LIST)ARG0(arg));
1842: ps = (DP *)BDY((VECT)ARG2(arg));
1843: hps = (DP *)BDY((VECT)ARG3(arg));
1844: NEWVECT(quo); quo->len = ((VECT)ARG2(arg))->len;
1845: quo->body = (pointer *)dp_true_nf_and_quotient_marked(b,g,ps,hps,&nm,&dn);
1846: }
1847: n = mknode(3,nm,dn,quo);
1848: MKLIST(*rp,n);
1849: }
1850:
1851: void Pdp_weyl_true_nf_and_quotient(NODE arg,LIST *rp)
1852: {
1853: NODE narg = mknode(4,ARG0(arg),ARG1(arg),ARG2(arg),ARG2(arg));
1854: Pdp_weyl_true_nf_and_quotient_marked(narg,rp);
1855: }
1856:
1857:
1858: void Pdp_weyl_true_nf_and_quotient_marked_mod(NODE arg,LIST *rp)
1859: {
1860: NODE b,n;
1861: DP *ps,*hps;
1862: DP g;
1863: DP nm;
1864: VECT quo;
1865: P dn;
1866: int full,mod;
1867:
1868: do_weyl = 1; dp_fcoeffs = 0;
1869: asir_assert(ARG0(arg),O_LIST,"dp_weyl_true_nf_and_quotient_marked_mod");
1870: asir_assert(ARG1(arg),O_DP,"dp_weyl_true_nf_and_quotient_marked_mod");
1871: asir_assert(ARG2(arg),O_VECT,"dp_weyl_true_nf_and_quotient_marked_mod");
1872: asir_assert(ARG3(arg),O_VECT,"dp_weyl_true_nf_and_quotient_marked_mod");
1873: asir_assert(ARG4(arg),O_N,"dp_weyl_true_nf_and_quotient_marked_mod");
1874: if ( !(g = (DP)ARG1(arg)) ) {
1875: nm = 0; dn = (P)ONE;
1876: } else {
1877: b = BDY((LIST)ARG0(arg));
1878: ps = (DP *)BDY((VECT)ARG2(arg));
1879: hps = (DP *)BDY((VECT)ARG3(arg));
1.2 noro 1880: mod = ZTOS((Q)ARG4(arg));
1.1 noro 1881: NEWVECT(quo); quo->len = ((VECT)ARG2(arg))->len;
1882: quo->body = (pointer *)dp_true_nf_and_quotient_marked_mod(b,g,ps,hps,mod,&nm,&dn);
1883: }
1884: n = mknode(3,nm,dn,quo);
1885: MKLIST(*rp,n);
1886: }
1887:
1888: void Pdp_weyl_true_nf_and_quotient_mod(NODE arg,LIST *rp)
1889: {
1890: NODE narg = mknode(5,ARG0(arg),ARG1(arg),ARG2(arg),ARG2(arg),ARG3(arg));
1891: Pdp_weyl_true_nf_and_quotient_marked_mod(narg,rp);
1892: }
1893:
1894:
1895: void Pdp_tdiv(NODE arg,DP *rp)
1896: {
1897: MP m,mr,mr0;
1898: DP p;
1899: Z d,q,r;
1900: int sgn;
1901:
1902: asir_assert(ARG0(arg),O_DP,"dp_tdiv");
1903: asir_assert(ARG1(arg),O_N,"dp_tdiv");
1904: p = (DP)ARG0(arg); d = (Z)ARG1(arg);
1905: if ( !p )
1906: *rp = 0;
1907: else {
1908: for ( mr0 = 0, m = BDY(p); m; m = NEXT(m) ) {
1909: divqrz((Z)m->c,d,&q,&r);
1910: if ( r ) {
1911: *rp = 0; return;
1912: } else {
1913: NEXTMP(mr0,mr);
1914: mr->c = (Obj)q; mr->dl = m->dl;
1915: }
1916: }
1917: NEXT(mr) = 0; MKDP(p->nv,mr0,*rp); (*rp)->sugar = p->sugar;
1918: }
1919: }
1920:
1921: void Pdp_red_coef(NODE arg,DP *rp)
1922: {
1923: MP m,mr,mr0;
1924: P q,r;
1925: DP p;
1926: P mod;
1927:
1928: p = (DP)ARG0(arg); mod = (P)ARG1(arg);
1929: asir_assert(p,O_DP,"dp_red_coef");
1930: asir_assert(mod,O_P,"dp_red_coef");
1931: if ( !p )
1932: *rp = 0;
1933: else {
1934: for ( mr0 = 0, m = BDY(p); m; m = NEXT(m) ) {
1935: divsrp(CO,(P)m->c,mod,&q,&r);
1936: if ( r ) {
1937: NEXTMP(mr0,mr); mr->c = (Obj)r; mr->dl = m->dl;
1938: }
1939: }
1940: if ( mr0 ) {
1941: NEXT(mr) = 0; MKDP(p->nv,mr0,*rp); (*rp)->sugar = p->sugar;
1942: } else
1943: *rp = 0;
1944: }
1945: }
1946:
1947: void Pdp_redble(NODE arg,Z *rp)
1948: {
1949: asir_assert(ARG0(arg),O_DP,"dp_redble");
1950: asir_assert(ARG1(arg),O_DP,"dp_redble");
1951: if ( dp_redble((DP)ARG0(arg),(DP)ARG1(arg)) )
1952: *rp = ONE;
1953: else
1954: *rp = 0;
1955: }
1956:
1.9 noro 1957: void Pdpm_redble(NODE arg,Z *rp)
1958: {
1959: asir_assert(ARG0(arg),O_DPM,"dpm_redble");
1960: asir_assert(ARG1(arg),O_DPM,"dpm_redble");
1961: if ( dpm_redble((DPM)ARG0(arg),(DPM)ARG1(arg)) )
1962: *rp = ONE;
1963: else
1964: *rp = 0;
1965: }
1966:
1.11 noro 1967: void dpm_schreyer_base(LIST g,LIST *s);
1.19 noro 1968: void dpm_schreyer_base_zlist(LIST g,LIST *s);
1.11 noro 1969:
1970: void Pdpm_schreyer_base(NODE arg,LIST *rp)
1971: {
1972: asir_assert(ARG0(arg),O_LIST,"dpm_schreyer_base");
1.19 noro 1973: dpm_schreyer_base_zlist((LIST)ARG0(arg),rp);
1.11 noro 1974: }
1975:
1.19 noro 1976: void dpm_list_to_array(LIST g,VECT *psv,VECT *psiv);
1977:
1978: void Pdpm_list_to_array(NODE arg,LIST *rp)
1979: {
1980: VECT psv,psiv;
1981: NODE nd;
1982:
1983: asir_assert(ARG0(arg),O_LIST,"dpm_list_to_array");
1984: dpm_list_to_array((LIST)ARG0(arg),&psv,&psiv);
1985: nd = mknode(2,psv,psiv);
1986: MKLIST(*rp,nd);
1987: }
1988:
1.21 noro 1989: /* [quo,nf] = dpm_sp_nf(psv,psiv,i,j,top) */
1990: DPM dpm_sp_nf_zlist(VECT psv,VECT psiv,int i,int j,int top,DPM *nf);
1.19 noro 1991:
1992: void Pdpm_sp_nf(NODE arg,LIST *rp)
1993: {
1994: VECT psv,psiv;
1995: DPM quo,nf;
1.21 noro 1996: Obj val;
1997: int i,j,top;
1.19 noro 1998: NODE nd;
1999:
2000: asir_assert(ARG0(arg),O_VECT,"dpm_sp_nf"); psv = (VECT)ARG0(arg);
2001: asir_assert(ARG1(arg),O_VECT,"dpm_sp_nf"); psiv = (VECT)ARG1(arg);
2002: asir_assert(ARG2(arg),O_N,"dpm_sp_nf"); i = ZTOS((Q)ARG2(arg));
2003: asir_assert(ARG3(arg),O_N,"dpm_sp_nf"); j = ZTOS((Q)ARG3(arg));
1.21 noro 2004: if ( get_opt("top",&val) && val )
2005: top = 1;
2006: else
2007: top = 0;
2008: quo = dpm_sp_nf_zlist(psv,psiv,i,j,top,&nf);
1.19 noro 2009: nd = mknode(2,quo,nf);
2010: MKLIST(*rp,nd);
2011: }
2012:
2013: void dpm_insert_to_zlist(VECT psiv,int pos,int i);
2014:
2015: /* insert_to_zlist(indarray,dpm_hp(f),i) */
2016: void Pdpm_insert_to_zlist(NODE arg,VECT *rp)
2017: {
2018: VECT psiv;
2019: int i,pos;
2020:
2021: asir_assert(ARG0(arg),O_VECT,"dpm_insert_to_zlist"); psiv = (VECT)ARG0(arg);
2022: asir_assert(ARG1(arg),O_N,"dpm_insert_to_zlist"); pos = ZTOS((Q)ARG1(arg));
2023: asir_assert(ARG2(arg),O_N,"dpm_insert_to_zlist"); i = ZTOS((Q)ARG2(arg));
2024: dpm_insert_to_zlist(psiv,pos,i);
2025: *rp = psiv;
2026: }
2027:
2028:
1.16 noro 2029: void dpm_simplify_syz(LIST m,LIST s,LIST *m1,LIST *s1,LIST *w1);
1.12 noro 2030:
2031: void Pdpm_simplify_syz(NODE arg,LIST *rp)
2032: {
1.16 noro 2033: LIST s1,m1,w1;
1.12 noro 2034: NODE t;
2035:
2036: asir_assert(ARG0(arg),O_LIST,"dpm_simplify_syz");
2037: asir_assert(ARG1(arg),O_LIST,"dpm_simplify_syz");
1.16 noro 2038: dpm_simplify_syz((LIST)ARG0(arg),(LIST)ARG1(arg),&s1,&m1,&w1);
2039: t = mknode(3,s1,m1,w1);
1.12 noro 2040: MKLIST(*rp,t);
2041: }
2042:
2043:
1.1 noro 2044: void Pdp_red_mod(NODE arg,LIST *rp)
2045: {
2046: DP h,r;
2047: P dmy;
2048: NODE n;
2049:
2050: do_weyl = 0;
2051: asir_assert(ARG0(arg),O_DP,"dp_red_mod");
2052: asir_assert(ARG1(arg),O_DP,"dp_red_mod");
2053: asir_assert(ARG2(arg),O_DP,"dp_red_mod");
2054: asir_assert(ARG3(arg),O_N,"dp_red_mod");
1.2 noro 2055: dp_red_mod((DP)ARG0(arg),(DP)ARG1(arg),(DP)ARG2(arg),ZTOS((Q)ARG3(arg)),
1.1 noro 2056: &h,&r,&dmy);
2057: NEWNODE(n); BDY(n) = (pointer)h;
2058: NEWNODE(NEXT(n)); BDY(NEXT(n)) = (pointer)r;
2059: NEXT(NEXT(n)) = 0; MKLIST(*rp,n);
2060: }
2061:
2062: void Pdp_subd(NODE arg,DP *rp)
2063: {
2064: DP p1,p2;
2065:
2066: p1 = (DP)ARG0(arg); p2 = (DP)ARG1(arg);
2067: asir_assert(p1,O_DP,"dp_subd");
2068: asir_assert(p2,O_DP,"dp_subd");
2069: dp_subd(p1,p2,rp);
2070: }
2071:
2072: void Pdp_symb_add(NODE arg,DP *rp)
2073: {
2074: DP p1,p2,r;
2075: NODE s0;
2076: MP mp0,mp;
2077: int nv;
2078:
2079: p1 = (DP)ARG0(arg); p2 = (DP)ARG1(arg);
2080: asir_assert(p1,O_DP,"dp_symb_add");
2081: asir_assert(p2,O_DP,"dp_symb_add");
2082: if ( !p1 ) { *rp = p2; return; }
2083: else if ( !p2 ) { *rp = p1; return; }
2084: if ( p1->nv != p2->nv )
2085: error("dp_sumb_add : invalid input");
2086: nv = p1->nv;
2087: s0 = symb_merge(dp_dllist(p1),dp_dllist(p2),nv);
2088: for ( mp0 = 0; s0; s0 = NEXT(s0) ) {
2089: NEXTMP(mp0,mp); mp->dl = (DL)BDY(s0); mp->c = (Obj)ONE;
2090: }
2091: NEXT(mp) = 0;
2092: MKDP(nv,mp0,r); r->sugar = MAX(p1->sugar,p2->sugar);
2093: *rp = r;
2094: }
2095:
2096: void Pdp_mul_trunc(NODE arg,DP *rp)
2097: {
2098: DP p1,p2,p;
2099:
2100: p1 = (DP)ARG0(arg); p2 = (DP)ARG1(arg); p = (DP)ARG2(arg);
2101: asir_assert(p1,O_DP,"dp_mul_trunc");
2102: asir_assert(p2,O_DP,"dp_mul_trunc");
2103: asir_assert(p,O_DP,"dp_mul_trunc");
2104: comm_muld_trunc(CO,p1,p2,BDY(p)->dl,rp);
2105: }
2106:
2107: void Pdp_quo(NODE arg,DP *rp)
2108: {
2109: DP p1,p2;
2110:
2111: p1 = (DP)ARG0(arg); p2 = (DP)ARG1(arg);
2112: asir_assert(p1,O_DP,"dp_quo");
2113: asir_assert(p2,O_DP,"dp_quo");
2114: comm_quod(CO,p1,p2,rp);
2115: }
2116:
2117: void Pdp_weyl_mul(NODE arg,DP *rp)
2118: {
2119: DP p1,p2;
2120:
2121: p1 = (DP)ARG0(arg); p2 = (DP)ARG1(arg);
2122: asir_assert(p1,O_DP,"dp_weyl_mul"); asir_assert(p2,O_DP,"dp_weyl_mul");
2123: do_weyl = 1;
2124: muld(CO,p1,p2,rp);
2125: do_weyl = 0;
2126: }
2127:
2128: void Pdp_weyl_act(NODE arg,DP *rp)
2129: {
2130: DP p1,p2;
2131:
2132: p1 = (DP)ARG0(arg); p2 = (DP)ARG1(arg);
2133: asir_assert(p1,O_DP,"dp_weyl_act"); asir_assert(p2,O_DP,"dp_weyl_act");
2134: weyl_actd(CO,p1,p2,rp);
2135: }
2136:
2137:
2138: void Pdp_weyl_mul_mod(NODE arg,DP *rp)
2139: {
2140: DP p1,p2;
2141: Q m;
2142:
2143: p1 = (DP)ARG0(arg); p2 = (DP)ARG1(arg); m = (Q)ARG2(arg);
2144: asir_assert(p1,O_DP,"dp_weyl_mul_mod");
2145: asir_assert(p2,O_DP,"dp_mul_mod");
2146: asir_assert(m,O_N,"dp_mul_mod");
2147: do_weyl = 1;
1.2 noro 2148: mulmd(CO,ZTOS(m),p1,p2,rp);
1.1 noro 2149: do_weyl = 0;
2150: }
2151:
2152: void Pdp_red(NODE arg,LIST *rp)
2153: {
2154: NODE n;
2155: DP head,rest,dmy1;
2156: P dmy;
2157:
2158: do_weyl = 0;
2159: asir_assert(ARG0(arg),O_DP,"dp_red");
2160: asir_assert(ARG1(arg),O_DP,"dp_red");
2161: asir_assert(ARG2(arg),O_DP,"dp_red");
2162: dp_red((DP)ARG0(arg),(DP)ARG1(arg),(DP)ARG2(arg),&head,&rest,&dmy,&dmy1);
2163: NEWNODE(n); BDY(n) = (pointer)head;
2164: NEWNODE(NEXT(n)); BDY(NEXT(n)) = (pointer)rest;
2165: NEXT(NEXT(n)) = 0; MKLIST(*rp,n);
2166: }
2167:
2168: void Pdp_weyl_red(NODE arg,LIST *rp)
2169: {
2170: NODE n;
2171: DP head,rest,dmy1;
2172: P dmy;
2173:
2174: asir_assert(ARG0(arg),O_DP,"dp_weyl_red");
2175: asir_assert(ARG1(arg),O_DP,"dp_weyl_red");
2176: asir_assert(ARG2(arg),O_DP,"dp_weyl_red");
2177: do_weyl = 1;
2178: dp_red((DP)ARG0(arg),(DP)ARG1(arg),(DP)ARG2(arg),&head,&rest,&dmy,&dmy1);
2179: do_weyl = 0;
2180: NEWNODE(n); BDY(n) = (pointer)head;
2181: NEWNODE(NEXT(n)); BDY(NEXT(n)) = (pointer)rest;
2182: NEXT(NEXT(n)) = 0; MKLIST(*rp,n);
2183: }
2184:
2185: void Pdp_sp(NODE arg,DP *rp)
2186: {
2187: DP p1,p2;
2188:
2189: do_weyl = 0;
2190: p1 = (DP)ARG0(arg); p2 = (DP)ARG1(arg);
2191: asir_assert(p1,O_DP,"dp_sp"); asir_assert(p2,O_DP,"dp_sp");
2192: dp_sp(p1,p2,rp);
2193: }
2194:
2195: void Pdp_weyl_sp(NODE arg,DP *rp)
2196: {
2197: DP p1,p2;
2198:
2199: p1 = (DP)ARG0(arg); p2 = (DP)ARG1(arg);
2200: asir_assert(p1,O_DP,"dp_weyl_sp"); asir_assert(p2,O_DP,"dp_weyl_sp");
2201: do_weyl = 1;
2202: dp_sp(p1,p2,rp);
2203: do_weyl = 0;
2204: }
2205:
1.9 noro 2206: void Pdpm_sp(NODE arg,Obj *rp)
1.1 noro 2207: {
1.9 noro 2208: DPM p1,p2,sp;
2209: DP mul1,mul2;
2210: Obj val;
2211: NODE nd;
2212: LIST l;
1.1 noro 2213:
2214: do_weyl = 0;
2215: p1 = (DPM)ARG0(arg); p2 = (DPM)ARG1(arg);
2216: asir_assert(p1,O_DPM,"dpm_sp"); asir_assert(p2,O_DPM,"dpm_sp");
1.9 noro 2217: dpm_sp(p1,p2,&sp,&mul1,&mul2);
2218: if ( get_opt("coef",&val) && val ) {
2219: nd = mknode(3,sp,mul1,mul2);
2220: MKLIST(l,nd);
2221: *rp = (Obj)l;
2222: } else {
2223: *rp = (Obj)sp;
2224: }
1.1 noro 2225: }
2226:
1.9 noro 2227: void Pdpm_weyl_sp(NODE arg,Obj *rp)
1.1 noro 2228: {
1.9 noro 2229: DPM p1,p2,sp;
2230: DP mul1,mul2;
2231: Obj val;
2232: NODE nd;
2233: LIST l;
1.1 noro 2234:
2235: p1 = (DPM)ARG0(arg); p2 = (DPM)ARG1(arg);
2236: asir_assert(p1,O_DPM,"dpm_weyl_sp"); asir_assert(p2,O_DPM,"dpm_weyl_sp");
2237: do_weyl = 1;
1.9 noro 2238: dpm_sp(p1,p2,&sp,&mul1,&mul2);
1.1 noro 2239: do_weyl = 0;
1.9 noro 2240: if ( get_opt("coef",&val) && val ) {
2241: nd = mknode(3,sp,mul1,mul2);
2242: MKLIST(l,nd);
2243: *rp = (Obj)l;
2244: } else {
2245: *rp = (Obj)sp;
2246: }
1.1 noro 2247: }
2248:
2249: void Pdp_sp_mod(NODE arg,DP *rp)
2250: {
2251: DP p1,p2;
2252: int mod;
2253:
2254: do_weyl = 0;
2255: p1 = (DP)ARG0(arg); p2 = (DP)ARG1(arg);
2256: asir_assert(p1,O_DP,"dp_sp_mod"); asir_assert(p2,O_DP,"dp_sp_mod");
2257: asir_assert(ARG2(arg),O_N,"dp_sp_mod");
1.2 noro 2258: mod = ZTOS((Q)ARG2(arg));
1.1 noro 2259: dp_sp_mod(p1,p2,mod,rp);
2260: }
2261:
2262: void Pdp_lcm(NODE arg,DP *rp)
2263: {
2264: int i,n,td;
2265: DL d1,d2,d;
2266: MP m;
2267: DP p1,p2;
2268:
2269: p1 = (DP)ARG0(arg); p2 = (DP)ARG1(arg);
2270: asir_assert(p1,O_DP,"dp_lcm"); asir_assert(p2,O_DP,"dp_lcm");
2271: n = p1->nv; d1 = BDY(p1)->dl; d2 = BDY(p2)->dl;
2272: NEWDL(d,n);
2273: for ( i = 0, td = 0; i < n; i++ ) {
2274: d->d[i] = MAX(d1->d[i],d2->d[i]); td += MUL_WEIGHT(d->d[i],i);
2275: }
2276: d->td = td;
2277: NEWMP(m); m->dl = d; m->c = (Obj)ONE; NEXT(m) = 0;
2278: MKDP(n,m,*rp); (*rp)->sugar = td; /* XXX */
2279: }
2280:
2281: void Pdp_hm(NODE arg,DP *rp)
2282: {
2283: DP p;
2284:
2285: p = (DP)ARG0(arg); asir_assert(p,O_DP,"dp_hm");
2286: dp_hm(p,rp);
2287: }
2288:
2289: void Pdp_ht(NODE arg,DP *rp)
2290: {
2291: DP p;
2292: MP m,mr;
2293:
2294: p = (DP)ARG0(arg); asir_assert(p,O_DP,"dp_ht");
2295: dp_ht(p,rp);
2296: }
2297:
2298: void Pdp_hc(NODE arg,Obj *rp)
2299: {
2300: asir_assert(ARG0(arg),O_DP,"dp_hc");
2301: if ( !ARG0(arg) )
2302: *rp = 0;
2303: else
2304: *rp = BDY((DP)ARG0(arg))->c;
2305: }
2306:
2307: void Pdp_rest(NODE arg,DP *rp)
2308: {
2309: asir_assert(ARG0(arg),O_DP,"dp_rest");
2310: if ( !ARG0(arg) )
2311: *rp = 0;
2312: else
2313: dp_rest((DP)ARG0(arg),rp);
2314: }
2315:
2316: void Pdp_td(NODE arg,Z *rp)
2317: {
2318: DP p;
2319:
2320: p = (DP)ARG0(arg); asir_assert(p,O_DP,"dp_td");
2321: if ( !p )
2322: *rp = 0;
2323: else
1.2 noro 2324: STOZ(BDY(p)->dl->td,*rp);
1.1 noro 2325: }
2326:
1.15 noro 2327: void Pdpm_td(NODE arg,Z *rp)
2328: {
2329: DPM p;
2330:
2331: p = (DPM)ARG0(arg); asir_assert(p,O_DPM,"dpm_td");
2332: if ( !p )
2333: *rp = 0;
2334: else
2335: STOZ(BDY(p)->dl->td,*rp);
2336: }
2337:
1.1 noro 2338: void Pdp_sugar(NODE arg,Z *rp)
2339: {
2340: DP p;
2341:
2342: p = (DP)ARG0(arg); asir_assert(p,O_DP,"dp_sugar");
2343: if ( !p )
2344: *rp = 0;
2345: else
1.2 noro 2346: STOZ(p->sugar,*rp);
1.1 noro 2347: }
2348:
2349: void Pdp_initial_term(NODE arg,Obj *rp)
2350: {
2351: struct order_spec *ord;
2352: Num homo;
2353: int modular,is_list;
2354: LIST v,f,l,initiallist;
2355: NODE n;
2356:
2357: f = (LIST)ARG0(arg);
2358: if ( f && OID(f) == O_LIST )
2359: is_list = 1;
2360: else {
2361: n = mknode(1,f); MKLIST(l,n); f = l;
2362: is_list = 0;
2363: }
2364: if ( current_option ) {
2365: parse_gr_option(f,current_option,&v,&homo,&modular,&ord);
2366: initd(ord);
2367: } else
2368: ord = dp_current_spec;
2369: initiallist = dp_initial_term(f,ord);
2370: if ( !is_list )
2371: *rp = (Obj)BDY(BDY(initiallist));
2372: else
2373: *rp = (Obj)initiallist;
2374: }
2375:
2376: void Pdp_order(NODE arg,Obj *rp)
2377: {
2378: struct order_spec *ord;
2379: Num homo;
2380: int modular,is_list;
2381: LIST v,f,l,ordlist;
2382: NODE n;
2383:
2384: f = (LIST)ARG0(arg);
2385: if ( f && OID(f) == O_LIST )
2386: is_list = 1;
2387: else {
2388: n = mknode(1,f); MKLIST(l,n); f = l;
2389: is_list = 0;
2390: }
2391: if ( current_option ) {
2392: parse_gr_option(f,current_option,&v,&homo,&modular,&ord);
2393: initd(ord);
2394: } else
2395: ord = dp_current_spec;
2396: ordlist = dp_order(f,ord);
2397: if ( !is_list )
2398: *rp = (Obj)BDY(BDY(ordlist));
2399: else
2400: *rp = (Obj)ordlist;
2401: }
2402:
2403: void Pdp_set_sugar(NODE arg,Q *rp)
2404: {
2405: DP p;
2406: Q q;
2407: int i;
2408:
2409: p = (DP)ARG0(arg);
2410: q = (Q)ARG1(arg);
2411: if ( p && q) {
2412: asir_assert(p,O_DP,"dp_set_sugar");
2413: asir_assert(q,O_N, "dp_set_sugar");
1.2 noro 2414: i = ZTOS(q);
1.1 noro 2415: if (p->sugar < i) {
2416: p->sugar = i;
2417: }
2418: }
2419: *rp = 0;
2420: }
2421:
2422: void Pdp_cri1(NODE arg,Z *rp)
2423: {
2424: DP p1,p2;
2425: int *d1,*d2;
2426: int i,n;
2427:
2428: p1 = (DP)ARG0(arg); p2 = (DP)ARG1(arg);
2429: asir_assert(p1,O_DP,"dp_cri1"); asir_assert(p2,O_DP,"dp_cri1");
2430: n = p1->nv; d1 = BDY(p1)->dl->d; d2 = BDY(p2)->dl->d;
2431: for ( i = 0; i < n; i++ )
2432: if ( d1[i] > d2[i] )
2433: break;
2434: *rp = i == n ? ONE : 0;
2435: }
2436:
2437: void Pdp_cri2(NODE arg,Z *rp)
2438: {
2439: DP p1,p2;
2440: int *d1,*d2;
2441: int i,n;
2442:
2443: p1 = (DP)ARG0(arg); p2 = (DP)ARG1(arg);
2444: asir_assert(p1,O_DP,"dp_cri2"); asir_assert(p2,O_DP,"dp_cri2");
2445: n = p1->nv; d1 = BDY(p1)->dl->d; d2 = BDY(p2)->dl->d;
2446: for ( i = 0; i < n; i++ )
2447: if ( MIN(d1[i],d2[i]) >= 1 )
2448: break;
2449: *rp = i == n ? ONE : 0;
2450: }
2451:
2452: void Pdp_minp(NODE arg,LIST *rp)
2453: {
2454: NODE tn,tn1,d,dd,dd0,p,tp;
2455: LIST l,minp;
2456: DP lcm,tlcm;
2457: int s,ts;
2458:
2459: asir_assert(ARG0(arg),O_LIST,"dp_minp");
2460: d = BDY((LIST)ARG0(arg)); minp = (LIST)BDY(d);
2461: p = BDY(minp); p = NEXT(NEXT(p)); lcm = (DP)BDY(p); p = NEXT(p);
2462: if ( !ARG1(arg) ) {
1.2 noro 2463: s = ZTOS((Q)BDY(p)); p = NEXT(p);
1.1 noro 2464: for ( dd0 = 0, d = NEXT(d); d; d = NEXT(d) ) {
2465: tp = BDY((LIST)BDY(d)); tp = NEXT(NEXT(tp));
2466: tlcm = (DP)BDY(tp); tp = NEXT(tp);
1.2 noro 2467: ts = ZTOS((Q)BDY(tp)); tp = NEXT(tp);
1.1 noro 2468: NEXTNODE(dd0,dd);
2469: if ( ts < s ) {
2470: BDY(dd) = (pointer)minp;
2471: minp = (LIST)BDY(d); lcm = tlcm; s = ts;
2472: } else if ( ts == s ) {
2473: if ( compd(CO,lcm,tlcm) > 0 ) {
2474: BDY(dd) = (pointer)minp;
2475: minp = (LIST)BDY(d); lcm = tlcm; s = ts;
2476: } else
2477: BDY(dd) = BDY(d);
2478: } else
2479: BDY(dd) = BDY(d);
2480: }
2481: } else {
2482: for ( dd0 = 0, d = NEXT(d); d; d = NEXT(d) ) {
2483: tp = BDY((LIST)BDY(d)); tp = NEXT(NEXT(tp));
2484: tlcm = (DP)BDY(tp);
2485: NEXTNODE(dd0,dd);
2486: if ( compd(CO,lcm,tlcm) > 0 ) {
2487: BDY(dd) = (pointer)minp; minp = (LIST)BDY(d); lcm = tlcm;
2488: } else
2489: BDY(dd) = BDY(d);
2490: }
2491: }
2492: if ( dd0 )
2493: NEXT(dd) = 0;
2494: MKLIST(l,dd0); MKNODE(tn,l,0); MKNODE(tn1,minp,tn); MKLIST(*rp,tn1);
2495: }
2496:
2497: void Pdp_criB(NODE arg,LIST *rp)
2498: {
2499: NODE d,ij,dd,ddd;
2500: int i,j,s,n;
2501: DP *ps;
2502: DL ts,ti,tj,lij,tdl;
2503:
2504: asir_assert(ARG0(arg),O_LIST,"dp_criB"); d = BDY((LIST)ARG0(arg));
1.2 noro 2505: asir_assert(ARG1(arg),O_N,"dp_criB"); s = ZTOS((Q)ARG1(arg));
1.1 noro 2506: asir_assert(ARG2(arg),O_VECT,"dp_criB"); ps = (DP *)BDY((VECT)ARG2(arg));
2507: if ( !d )
2508: *rp = (LIST)ARG0(arg);
2509: else {
2510: ts = BDY(ps[s])->dl;
2511: n = ps[s]->nv;
2512: NEWDL(tdl,n);
2513: for ( dd = 0; d; d = NEXT(d) ) {
2514: ij = BDY((LIST)BDY(d));
1.2 noro 2515: i = ZTOS((Q)BDY(ij)); ij = NEXT(ij);
2516: j = ZTOS((Q)BDY(ij)); ij = NEXT(ij);
1.1 noro 2517: lij = BDY((DP)BDY(ij))->dl;
2518: ti = BDY(ps[i])->dl; tj = BDY(ps[j])->dl;
2519: if ( lij->td != lcm_of_DL(n,lij,ts,tdl)->td
2520: || !dl_equal(n,lij,tdl)
2521: || (lij->td == lcm_of_DL(n,ti,ts,tdl)->td
2522: && dl_equal(n,tdl,lij))
2523: || (lij->td == lcm_of_DL(n,tj,ts,tdl)->td
2524: && dl_equal(n,tdl,lij)) ) {
2525: MKNODE(ddd,BDY(d),dd);
2526: dd = ddd;
2527: }
2528: }
2529: MKLIST(*rp,dd);
2530: }
2531: }
2532:
2533: void Pdp_nelim(NODE arg,Z *rp)
2534: {
2535: if ( arg ) {
2536: asir_assert(ARG0(arg),O_N,"dp_nelim");
1.2 noro 2537: dp_nelim = ZTOS((Q)ARG0(arg));
1.1 noro 2538: }
1.2 noro 2539: STOZ(dp_nelim,*rp);
1.1 noro 2540: }
2541:
2542: void Pdp_mag(NODE arg,Z *rp)
2543: {
2544: DP p;
2545: int s;
2546: MP m;
2547:
2548: p = (DP)ARG0(arg);
2549: asir_assert(p,O_DP,"dp_mag");
2550: if ( !p )
2551: *rp = 0;
2552: else {
2553: for ( s = 0, m = BDY(p); m; m = NEXT(m) )
2554: s += p_mag((P)m->c);
1.2 noro 2555: STOZ(s,*rp);
1.1 noro 2556: }
2557: }
2558:
2559: /* kara_mag is no longer used. */
2560:
2561: void Pdp_set_kara(NODE arg,Z *rp)
2562: {
2563: *rp = 0;
2564: }
2565:
2566: void Pdp_homo(NODE arg,DP *rp)
2567: {
2568: asir_assert(ARG0(arg),O_DP,"dp_homo");
2569: dp_homo((DP)ARG0(arg),rp);
2570: }
2571:
2572: void Pdp_dehomo(NODE arg,DP *rp)
2573: {
2574: asir_assert(ARG0(arg),O_DP,"dp_dehomo");
2575: dp_dehomo((DP)ARG0(arg),rp);
2576: }
2577:
1.16 noro 2578: void dpm_homo(DPM a,DPM *b);
2579: void dpm_dehomo(DPM a,DPM *b);
2580:
2581: void Pdpm_homo(NODE arg,DPM *rp)
2582: {
2583: asir_assert(ARG0(arg),O_DPM,"dpm_homo");
2584: dpm_homo((DPM)ARG0(arg),rp);
2585: }
2586:
2587: void Pdpm_dehomo(NODE arg,DPM *rp)
2588: {
2589: asir_assert(ARG0(arg),O_DPM,"dpm_dehomo");
2590: dpm_dehomo((DPM)ARG0(arg),rp);
2591: }
2592:
2593:
1.1 noro 2594: void Pdp_gr_flags(NODE arg,LIST *rp)
2595: {
2596: Obj name,value;
2597: NODE n;
2598:
2599: if ( arg ) {
2600: asir_assert(ARG0(arg),O_LIST,"dp_gr_flags");
2601: n = BDY((LIST)ARG0(arg));
2602: while ( n ) {
2603: name = (Obj)BDY(n); n = NEXT(n);
2604: if ( !n )
2605: break;
2606: else {
2607: value = (Obj)BDY(n); n = NEXT(n);
2608: }
2609: dp_set_flag(name,value);
2610: }
2611: }
2612: dp_make_flaglist(rp);
2613: }
2614:
2615: extern int DP_Print, DP_PrintShort;
2616:
2617: void Pdp_gr_print(NODE arg,Z *rp)
2618: {
2619: Z q;
2620: int s;
2621:
2622: if ( arg ) {
2623: asir_assert(ARG0(arg),O_N,"dp_gr_print");
2624: q = (Z)ARG0(arg);
1.2 noro 2625: s = ZTOS(q);
1.1 noro 2626: switch ( s ) {
2627: case 0:
2628: DP_Print = 0; DP_PrintShort = 0;
2629: break;
2630: case 1:
2631: DP_Print = 1;
2632: break;
2633: case 2:
2634: DP_Print = 0; DP_PrintShort = 1;
2635: break;
2636: default:
2637: DP_Print = s; DP_PrintShort = 0;
2638: break;
2639: }
2640: } else {
2641: if ( DP_Print ) {
1.2 noro 2642: STOZ(1,q);
1.1 noro 2643: } else if ( DP_PrintShort ) {
1.2 noro 2644: STOZ(2,q);
1.1 noro 2645: } else
2646: q = 0;
2647: }
2648: *rp = q;
2649: }
2650:
2651: void parse_gr_option(LIST f,NODE opt,LIST *v,Num *homo,
2652: int *modular,struct order_spec **ord)
2653: {
2654: NODE t,p;
2655: Z m,z;
2656: char *key;
2657: Obj value,dmy;
2658: int ord_is_set = 0;
2659: int modular_is_set = 0;
2660: int homo_is_set = 0;
2661: VL vl,vl0;
2662: LIST vars;
2663: char xiname[BUFSIZ];
2664: NODE x0,x;
2665: DP d;
2666: P xi;
2667: int nv,i;
2668:
2669: /* extract vars */
2670: vars = 0;
2671: for ( t = opt; t; t = NEXT(t) ) {
2672: p = BDY((LIST)BDY(t));
2673: key = BDY((STRING)BDY(p));
2674: value = (Obj)BDY(NEXT(p));
2675: if ( !strcmp(key,"v") ) {
2676: /* variable list */
2677: vars = (LIST)value;
2678: break;
2679: }
2680: }
2681: if ( vars ) {
2682: *v = vars; pltovl(vars,&vl);
2683: } else {
2684: for ( t = BDY(f); t; t = NEXT(t) )
2685: if ( BDY(t) && OID((Obj)BDY(t))==O_DP )
2686: break;
2687: if ( t ) {
2688: /* f is DP list */
2689: /* create dummy var list */
2690: d = (DP)BDY(t);
2691: nv = NV(d);
2692: for ( i = 0, vl0 = 0, x0 = 0; i < nv; i++ ) {
2693: NEXTVL(vl0,vl);
2694: NEXTNODE(x0,x);
2695: sprintf(xiname,"x%d",i);
2696: makevar(xiname,&xi);
2697: x->body = (pointer)xi;
2698: vl->v = VR((P)xi);
2699: }
2700: if ( vl0 ) {
2701: NEXT(vl) = 0;
2702: NEXT(x) = 0;
2703: }
2704: MKLIST(vars,x0);
2705: *v = vars;
2706: vl = vl0;
2707: } else {
2708: get_vars((Obj)f,&vl); vltopl(vl,v);
2709: }
2710: }
2711:
2712: for ( t = opt; t; t = NEXT(t) ) {
2713: p = BDY((LIST)BDY(t));
2714: key = BDY((STRING)BDY(p));
2715: value = (Obj)BDY(NEXT(p));
2716: if ( !strcmp(key,"v") ) {
2717: /* variable list; ignore */
2718: } else if ( !strcmp(key,"order") ) {
2719: /* order spec */
2720: if ( !vl )
2721: error("parse_gr_option : variables must be specified");
2722: create_order_spec(vl,value,ord);
2723: ord_is_set = 1;
2724: } else if ( !strcmp(key,"block") ) {
2725: create_order_spec(0,value,ord);
2726: ord_is_set = 1;
2727: } else if ( !strcmp(key,"matrix") ) {
2728: create_order_spec(0,value,ord);
2729: ord_is_set = 1;
2730: } else if ( !strcmp(key,"sugarweight") ) {
2731: /* weight */
2732: Pdp_set_weight(NEXT(p),&dmy);
2733: } else if ( !strcmp(key,"homo") ) {
2734: *homo = (Num)value;
2735: homo_is_set = 1;
2736: } else if ( !strcmp(key,"trace") ) {
2737: m = (Z)value;
1.2 noro 2738: STOZ(0x80000000,z);
1.1 noro 2739: if ( !m )
2740: *modular = 0;
2741: else if ( cmpz(m,z) >= 0 )
2742: error("parse_gr_option : too large modulus");
2743: else
1.2 noro 2744: *modular = ZTOS(m);
1.1 noro 2745: modular_is_set = 1;
2746: } else if ( !strcmp(key,"dp") ) {
2747: /* XXX : ignore */
2748: } else
2749: error("parse_gr_option : not implemented");
2750: }
2751: if ( !ord_is_set ) create_order_spec(0,0,ord);
2752: if ( !modular_is_set ) *modular = 0;
2753: if ( !homo_is_set ) *homo = 0;
2754: }
2755:
2756: void Pdp_gr_main(NODE arg,LIST *rp)
2757: {
2758: LIST f,v;
2759: VL vl;
2760: Num homo;
2761: Z m,z;
2762: int modular,ac;
2763: struct order_spec *ord;
2764:
2765: do_weyl = 0;
2766: asir_assert(ARG0(arg),O_LIST,"dp_gr_main");
2767: f = (LIST)ARG0(arg);
2768: f = remove_zero_from_list(f);
2769: if ( !BDY(f) ) {
2770: *rp = f; return;
2771: }
2772: if ( (ac = argc(arg)) == 5 ) {
2773: asir_assert(ARG1(arg),O_LIST,"dp_gr_main");
2774: asir_assert(ARG2(arg),O_N,"dp_gr_main");
2775: asir_assert(ARG3(arg),O_N,"dp_gr_main");
2776: v = (LIST)ARG1(arg);
2777: homo = (Num)ARG2(arg);
2778: m = (Z)ARG3(arg);
1.2 noro 2779: STOZ(0x80000000,z);
1.1 noro 2780: if ( !m )
2781: modular = 0;
2782: else if ( cmpz(m,z) >= 0 )
2783: error("dp_gr_main : too large modulus");
2784: else
1.2 noro 2785: modular = ZTOS(m);
1.1 noro 2786: create_order_spec(0,ARG4(arg),&ord);
2787: } else if ( current_option )
2788: parse_gr_option(f,current_option,&v,&homo,&modular,&ord);
2789: else if ( ac == 1 )
2790: parse_gr_option(f,0,&v,&homo,&modular,&ord);
2791: else
2792: error("dp_gr_main : invalid argument");
2793: dp_gr_main(f,v,homo,modular,0,ord,rp);
2794: }
2795:
2796: void Pdp_interreduce(NODE arg,LIST *rp)
2797: {
2798: LIST f,v;
2799: VL vl;
2800: int ac;
2801: struct order_spec *ord;
2802:
2803: do_weyl = 0;
2804: asir_assert(ARG0(arg),O_LIST,"dp_interreduce");
2805: f = (LIST)ARG0(arg);
2806: f = remove_zero_from_list(f);
2807: if ( !BDY(f) ) {
2808: *rp = f; return;
2809: }
2810: if ( (ac = argc(arg)) == 3 ) {
2811: asir_assert(ARG1(arg),O_LIST,"dp_interreduce");
2812: v = (LIST)ARG1(arg);
2813: create_order_spec(0,ARG2(arg),&ord);
2814: }
2815: dp_interreduce(f,v,0,ord,rp);
2816: }
2817:
2818: void Pdp_gr_f_main(NODE arg,LIST *rp)
2819: {
2820: LIST f,v;
2821: Num homo;
2822: int m,field,t;
2823: struct order_spec *ord;
2824: NODE n;
2825:
2826: do_weyl = 0;
2827: asir_assert(ARG0(arg),O_LIST,"dp_gr_f_main");
2828: asir_assert(ARG1(arg),O_LIST,"dp_gr_f_main");
2829: asir_assert(ARG2(arg),O_N,"dp_gr_f_main");
2830: f = (LIST)ARG0(arg); v = (LIST)ARG1(arg);
2831: f = remove_zero_from_list(f);
2832: if ( !BDY(f) ) {
2833: *rp = f; return;
2834: }
2835: homo = (Num)ARG2(arg);
2836: #if 0
2837: asir_assert(ARG3(arg),O_N,"dp_gr_f_main");
1.2 noro 2838: m = ZTOS((Q)ARG3(arg));
1.1 noro 2839: if ( m )
2840: error("dp_gr_f_main : trace lifting is not implemented yet");
2841: create_order_spec(0,ARG4(arg),&ord);
2842: #else
2843: m = 0;
2844: create_order_spec(0,ARG3(arg),&ord);
2845: #endif
2846: field = 0;
2847: for ( n = BDY(f); n; n = NEXT(n) ) {
2848: t = get_field_type(BDY(n));
2849: if ( !t )
2850: continue;
2851: if ( t < 0 )
2852: error("dp_gr_f_main : incosistent coefficients");
2853: if ( !field )
2854: field = t;
2855: else if ( t != field )
2856: error("dp_gr_f_main : incosistent coefficients");
2857: }
2858: dp_gr_main(f,v,homo,m?1:0,field,ord,rp);
2859: }
2860:
2861: void Pdp_f4_main(NODE arg,LIST *rp)
2862: {
2863: LIST f,v;
2864: struct order_spec *ord;
2865:
2866: do_weyl = 0;
2867: asir_assert(ARG0(arg),O_LIST,"dp_f4_main");
2868: asir_assert(ARG1(arg),O_LIST,"dp_f4_main");
2869: f = (LIST)ARG0(arg); v = (LIST)ARG1(arg);
2870: f = remove_zero_from_list(f);
2871: if ( !BDY(f) ) {
2872: *rp = f; return;
2873: }
2874: create_order_spec(0,ARG2(arg),&ord);
2875: dp_f4_main(f,v,ord,rp);
2876: }
2877:
2878: /* dp_gr_checklist(list of dp) */
2879:
2880: void Pdp_gr_checklist(NODE arg,LIST *rp)
2881: {
2882: VECT g;
2883: LIST dp;
2884: NODE r;
2885: int n;
2886:
2887: do_weyl = 0;
2888: asir_assert(ARG0(arg),O_LIST,"dp_gr_checklist");
2889: asir_assert(ARG1(arg),O_N,"dp_gr_checklist");
1.2 noro 2890: n = ZTOS((Q)ARG1(arg));
1.1 noro 2891: gbcheck_list(BDY((LIST)ARG0(arg)),n,&g,&dp);
2892: r = mknode(2,g,dp);
2893: MKLIST(*rp,r);
2894: }
2895:
2896: void Pdp_f4_mod_main(NODE arg,LIST *rp)
2897: {
2898: LIST f,v;
2899: int m;
2900: struct order_spec *ord;
2901:
2902: do_weyl = 0;
2903: asir_assert(ARG0(arg),O_LIST,"dp_f4_mod_main");
2904: asir_assert(ARG1(arg),O_LIST,"dp_f4_mod_main");
2905: asir_assert(ARG2(arg),O_N,"dp_f4_mod_main");
1.2 noro 2906: f = (LIST)ARG0(arg); v = (LIST)ARG1(arg); m = ZTOS((Q)ARG2(arg));
1.1 noro 2907: f = remove_zero_from_list(f);
2908: if ( !BDY(f) ) {
2909: *rp = f; return;
2910: }
2911: if ( !m )
2912: error("dp_f4_mod_main : invalid argument");
2913: create_order_spec(0,ARG3(arg),&ord);
2914: dp_f4_mod_main(f,v,m,ord,rp);
2915: }
2916:
2917: void Pdp_gr_mod_main(NODE arg,LIST *rp)
2918: {
2919: LIST f,v;
2920: Num homo;
2921: int m;
2922: struct order_spec *ord;
2923:
2924: do_weyl = 0;
2925: asir_assert(ARG0(arg),O_LIST,"dp_gr_mod_main");
2926: asir_assert(ARG1(arg),O_LIST,"dp_gr_mod_main");
2927: asir_assert(ARG2(arg),O_N,"dp_gr_mod_main");
2928: asir_assert(ARG3(arg),O_N,"dp_gr_mod_main");
2929: f = (LIST)ARG0(arg); v = (LIST)ARG1(arg);
2930: f = remove_zero_from_list(f);
2931: if ( !BDY(f) ) {
2932: *rp = f; return;
2933: }
1.2 noro 2934: homo = (Num)ARG2(arg); m = ZTOS((Q)ARG3(arg));
1.1 noro 2935: if ( !m )
2936: error("dp_gr_mod_main : invalid argument");
2937: create_order_spec(0,ARG4(arg),&ord);
2938: dp_gr_mod_main(f,v,homo,m,ord,rp);
2939: }
2940:
2941: void Psetmod_ff(NODE node, Obj *val);
2942:
2943: void Pnd_f4(NODE arg,LIST *rp)
2944: {
2945: LIST f,v;
2946: int m,homo,retdp,ac;
2947: Obj val;
2948: Z mq,z;
2949: Num nhomo;
2950: NODE node;
2951: struct order_spec *ord;
2952:
2953: do_weyl = 0;
2954: nd_rref2 = 0;
2955: retdp = 0;
2956: if ( (ac = argc(arg)) == 4 ) {
2957: asir_assert(ARG0(arg),O_LIST,"nd_f4");
2958: asir_assert(ARG1(arg),O_LIST,"nd_f4");
2959: asir_assert(ARG2(arg),O_N,"nd_f4");
2960: f = (LIST)ARG0(arg); v = (LIST)ARG1(arg);
2961: f = remove_zero_from_list(f);
2962: if ( !BDY(f) ) {
2963: *rp = f; return;
2964: }
2965: mq = (Z)ARG2(arg);
1.2 noro 2966: STOZ((unsigned long)0x40000000,z);
1.1 noro 2967: if ( cmpz(mq,z) >= 0 ) {
2968: node = mknode(1,mq);
2969: Psetmod_ff(node,&val);
2970: m = -2;
2971: } else
1.2 noro 2972: m = ZTOS(mq);
1.1 noro 2973: create_order_spec(0,ARG3(arg),&ord);
2974: homo = 0;
2975: if ( get_opt("homo",&val) && val ) homo = 1;
2976: if ( get_opt("dp",&val) && val ) retdp = 1;
2977: if ( get_opt("rref2",&val) && val ) nd_rref2 = 1;
2978: } else if ( ac == 1 ) {
2979: f = (LIST)ARG0(arg);
2980: parse_gr_option(f,current_option,&v,&nhomo,&m,&ord);
1.2 noro 2981: homo = ZTOS((Q)nhomo);
1.1 noro 2982: if ( get_opt("dp",&val) && val ) retdp = 1;
2983: if ( get_opt("rref2",&val) && val ) nd_rref2 = 1;
2984: } else
2985: error("nd_f4 : invalid argument");
2986: nd_gr(f,v,m,homo,retdp,1,ord,rp);
2987: }
2988:
2989: void Pnd_gr(NODE arg,LIST *rp)
2990: {
2991: LIST f,v;
2992: int m,homo,retdp,ac;
2993: Obj val;
2994: Z mq,z;
2995: Num nhomo;
2996: NODE node;
2997: struct order_spec *ord;
2998:
2999: do_weyl = 0;
3000: retdp = 0;
3001: if ( (ac=argc(arg)) == 4 ) {
3002: asir_assert(ARG0(arg),O_LIST,"nd_gr");
3003: asir_assert(ARG1(arg),O_LIST,"nd_gr");
3004: asir_assert(ARG2(arg),O_N,"nd_gr");
3005: f = (LIST)ARG0(arg); v = (LIST)ARG1(arg);
3006: f = remove_zero_from_list(f);
3007: if ( !BDY(f) ) {
3008: *rp = f; return;
3009: }
3010: mq = (Z)ARG2(arg);
1.2 noro 3011: STOZ(0x40000000,z);
1.1 noro 3012: if ( cmpz(mq,z) >= 0 ) {
3013: node = mknode(1,mq);
3014: Psetmod_ff(node,&val);
3015: m = -2;
3016: } else
1.2 noro 3017: m = ZTOS(mq);
1.1 noro 3018: create_order_spec(0,ARG3(arg),&ord);
3019: homo = 0;
3020: if ( get_opt("homo",&val) && val ) homo = 1;
3021: if ( get_opt("dp",&val) && val ) retdp = 1;
3022: } else if ( ac == 1 ) {
3023: f = (LIST)ARG0(arg);
3024: parse_gr_option(f,current_option,&v,&nhomo,&m,&ord);
1.2 noro 3025: homo = ZTOS((Q)nhomo);
1.1 noro 3026: if ( get_opt("dp",&val) && val ) retdp = 1;
3027: } else
3028: error("nd_gr : invalid argument");
3029: nd_gr(f,v,m,homo,retdp,0,ord,rp);
3030: }
3031:
1.25 noro 3032: void nd_sba(LIST f,LIST v,int m,int homo,int retdp,int f4,struct order_spec *ord,LIST *rp);
1.24 noro 3033:
3034: void Pnd_sba(NODE arg,LIST *rp)
3035: {
3036: LIST f,v;
3037: int m,homo,retdp,ac;
3038: Obj val;
3039: Z mq,z;
3040: Num nhomo;
3041: NODE node;
1.28 ! noro 3042: struct order_spec *ord,*current_spec;
1.24 noro 3043:
1.28 ! noro 3044: current_spec = dp_current_spec;
1.24 noro 3045: do_weyl = 0;
3046: retdp = 0;
3047: if ( (ac=argc(arg)) == 4 ) {
3048: asir_assert(ARG0(arg),O_LIST,"nd_sba");
3049: asir_assert(ARG1(arg),O_LIST,"nd_sba");
3050: asir_assert(ARG2(arg),O_N,"nd_sba");
3051: f = (LIST)ARG0(arg); v = (LIST)ARG1(arg);
3052: f = remove_zero_from_list(f);
3053: if ( !BDY(f) ) {
3054: *rp = f; return;
3055: }
3056: mq = (Z)ARG2(arg);
3057: STOZ(0x40000000,z);
3058: if ( cmpz(mq,z) >= 0 ) {
3059: node = mknode(1,mq);
3060: Psetmod_ff(node,&val);
3061: m = -2;
3062: } else
3063: m = ZTOS(mq);
3064: create_order_spec(0,ARG3(arg),&ord);
3065: homo = 0;
3066: if ( get_opt("homo",&val) && val ) homo = 1;
3067: if ( get_opt("dp",&val) && val ) retdp = 1;
3068: } else if ( ac == 1 ) {
3069: f = (LIST)ARG0(arg);
3070: parse_gr_option(f,current_option,&v,&nhomo,&m,&ord);
3071: homo = ZTOS((Q)nhomo);
3072: if ( get_opt("dp",&val) && val ) retdp = 1;
3073: } else
3074: error("nd_gr : invalid argument");
1.25 noro 3075: nd_sba(f,v,m,homo,retdp,0,ord,rp);
1.28 ! noro 3076: initd(current_spec);
1.25 noro 3077: }
3078:
1.27 noro 3079: void Pnd_weyl_sba(NODE arg,LIST *rp)
3080: {
3081: LIST f,v;
3082: int m,homo,retdp,ac;
3083: Obj val;
3084: Z mq,z;
3085: Num nhomo;
3086: NODE node;
3087: struct order_spec *ord;
3088:
3089: do_weyl = 1;
3090: retdp = 0;
3091: if ( (ac=argc(arg)) == 4 ) {
3092: asir_assert(ARG0(arg),O_LIST,"nd_sba");
3093: asir_assert(ARG1(arg),O_LIST,"nd_sba");
3094: asir_assert(ARG2(arg),O_N,"nd_sba");
3095: f = (LIST)ARG0(arg); v = (LIST)ARG1(arg);
3096: f = remove_zero_from_list(f);
3097: if ( !BDY(f) ) {
3098: *rp = f; do_weyl = 0; return;
3099: }
3100: mq = (Z)ARG2(arg);
3101: STOZ(0x40000000,z);
3102: if ( cmpz(mq,z) >= 0 ) {
3103: node = mknode(1,mq);
3104: Psetmod_ff(node,&val);
3105: m = -2;
3106: } else
3107: m = ZTOS(mq);
3108: create_order_spec(0,ARG3(arg),&ord);
3109: homo = 0;
3110: if ( get_opt("homo",&val) && val ) homo = 1;
3111: if ( get_opt("dp",&val) && val ) retdp = 1;
3112: } else if ( ac == 1 ) {
3113: f = (LIST)ARG0(arg);
3114: parse_gr_option(f,current_option,&v,&nhomo,&m,&ord);
3115: homo = ZTOS((Q)nhomo);
3116: if ( get_opt("dp",&val) && val ) retdp = 1;
3117: } else
3118: error("nd_gr : invalid argument");
3119: nd_sba(f,v,m,homo,retdp,0,ord,rp);
3120: do_weyl = 0;
3121: }
3122:
1.25 noro 3123: void Pnd_sba_f4(NODE arg,LIST *rp)
3124: {
3125: LIST f,v;
3126: int m,homo,retdp,ac;
3127: Obj val;
3128: Z mq,z;
3129: Num nhomo;
3130: NODE node;
3131: struct order_spec *ord;
3132:
3133: do_weyl = 0;
3134: retdp = 0;
3135: if ( (ac=argc(arg)) == 4 ) {
3136: asir_assert(ARG0(arg),O_LIST,"nd_sba");
3137: asir_assert(ARG1(arg),O_LIST,"nd_sba");
3138: asir_assert(ARG2(arg),O_N,"nd_sba");
3139: f = (LIST)ARG0(arg); v = (LIST)ARG1(arg);
3140: f = remove_zero_from_list(f);
3141: if ( !BDY(f) ) {
3142: *rp = f; return;
3143: }
3144: mq = (Z)ARG2(arg);
3145: STOZ(0x40000000,z);
3146: if ( cmpz(mq,z) >= 0 ) {
3147: node = mknode(1,mq);
3148: Psetmod_ff(node,&val);
3149: m = -2;
3150: } else
3151: m = ZTOS(mq);
3152: create_order_spec(0,ARG3(arg),&ord);
3153: homo = 0;
3154: if ( get_opt("homo",&val) && val ) homo = 1;
3155: if ( get_opt("dp",&val) && val ) retdp = 1;
3156: } else if ( ac == 1 ) {
3157: f = (LIST)ARG0(arg);
3158: parse_gr_option(f,current_option,&v,&nhomo,&m,&ord);
3159: homo = ZTOS((Q)nhomo);
3160: if ( get_opt("dp",&val) && val ) retdp = 1;
3161: } else
3162: error("nd_gr : invalid argument");
3163: nd_sba(f,v,m,homo,retdp,1,ord,rp);
1.24 noro 3164: }
3165:
1.1 noro 3166: void Pnd_gr_postproc(NODE arg,LIST *rp)
3167: {
3168: LIST f,v;
3169: int m,do_check;
3170: Z mq,z;
3171: Obj val;
3172: NODE node;
3173: struct order_spec *ord;
3174:
3175: do_weyl = 0;
3176: asir_assert(ARG0(arg),O_LIST,"nd_gr");
3177: asir_assert(ARG1(arg),O_LIST,"nd_gr");
3178: asir_assert(ARG2(arg),O_N,"nd_gr");
3179: f = (LIST)ARG0(arg); v = (LIST)ARG1(arg);
3180: f = remove_zero_from_list(f);
3181: if ( !BDY(f) ) {
3182: *rp = f; return;
3183: }
3184: mq = (Z)ARG2(arg);
1.2 noro 3185: STOZ(0x40000000,z);
1.1 noro 3186: if ( cmpz(mq,z) >= 0 ) {
3187: node = mknode(1,mq);
3188: Psetmod_ff(node,&val);
3189: m = -2;
3190: } else
1.2 noro 3191: m = ZTOS(mq);
1.1 noro 3192: create_order_spec(0,ARG3(arg),&ord);
3193: do_check = ARG4(arg) ? 1 : 0;
3194: nd_gr_postproc(f,v,m,ord,do_check,rp);
3195: }
3196:
3197: void Pnd_gr_recompute_trace(NODE arg,LIST *rp)
3198: {
3199: LIST f,v,tlist;
3200: int m;
3201: struct order_spec *ord;
3202:
3203: do_weyl = 0;
3204: asir_assert(ARG0(arg),O_LIST,"nd_gr_recompute_trace");
3205: asir_assert(ARG1(arg),O_LIST,"nd_gr_recompute_trace");
3206: asir_assert(ARG2(arg),O_N,"nd_gr_recompute_trace");
3207: f = (LIST)ARG0(arg); v = (LIST)ARG1(arg);
1.2 noro 3208: m = ZTOS((Q)ARG2(arg));
1.1 noro 3209: create_order_spec(0,ARG3(arg),&ord);
3210: tlist = (LIST)ARG4(arg);
3211: nd_gr_recompute_trace(f,v,m,ord,tlist,rp);
3212: }
3213:
3214: Obj nd_btog_one(LIST f,LIST v,int m,struct order_spec *ord,LIST tlist,int pos);
3215: Obj nd_btog(LIST f,LIST v,int m,struct order_spec *ord,LIST tlist);
3216:
3217: void Pnd_btog(NODE arg,Obj *rp)
3218: {
3219: LIST f,v,tlist;
3220: Z mq,z;
3221: int m,ac,pos;
3222: struct order_spec *ord;
3223: NODE node;
3224: pointer val;
3225:
3226: do_weyl = 0;
3227: asir_assert(ARG0(arg),O_LIST,"nd_btog");
3228: asir_assert(ARG1(arg),O_LIST,"nd_btog");
3229: asir_assert(ARG2(arg),O_N,"nd_btog");
3230: f = (LIST)ARG0(arg); v = (LIST)ARG1(arg);
3231: mq = (Z)ARG2(arg);
1.2 noro 3232: STOZ(0x40000000,z);
1.1 noro 3233: if ( cmpz(mq,z) >= 0 ) {
3234: node = mknode(1,mq);
3235: Psetmod_ff(node,(Obj *)&val);
3236: m = -2;
3237: } else
1.2 noro 3238: m = ZTOS(mq);
1.1 noro 3239: create_order_spec(0,ARG3(arg),&ord);
3240: tlist = (LIST)ARG4(arg);
3241: if ( (ac = argc(arg)) == 6 ) {
3242: asir_assert(ARG5(arg),O_N,"nd_btog");
1.2 noro 3243: pos = ZTOS((Q)ARG5(arg));
1.1 noro 3244: *rp = nd_btog_one(f,v,m,ord,tlist,pos);
3245: } else if ( ac == 5 )
3246: *rp = nd_btog(f,v,m,ord,tlist);
3247: else
3248: error("nd_btog : argument mismatch");
3249: }
3250:
3251: void Pnd_weyl_gr_postproc(NODE arg,LIST *rp)
3252: {
3253: LIST f,v;
3254: int m,do_check;
3255: struct order_spec *ord;
3256:
3257: do_weyl = 1;
3258: asir_assert(ARG0(arg),O_LIST,"nd_gr");
3259: asir_assert(ARG1(arg),O_LIST,"nd_gr");
3260: asir_assert(ARG2(arg),O_N,"nd_gr");
3261: f = (LIST)ARG0(arg); v = (LIST)ARG1(arg);
3262: f = remove_zero_from_list(f);
3263: if ( !BDY(f) ) {
3264: *rp = f; do_weyl = 0; return;
3265: }
1.2 noro 3266: m = ZTOS((Q)ARG2(arg));
1.1 noro 3267: create_order_spec(0,ARG3(arg),&ord);
3268: do_check = ARG4(arg) ? 1 : 0;
3269: nd_gr_postproc(f,v,m,ord,do_check,rp);
3270: do_weyl = 0;
3271: }
3272:
3273: void Pnd_gr_trace(NODE arg,LIST *rp)
3274: {
3275: LIST f,v;
3276: int m,homo,ac;
1.9 noro 3277: Obj val;
3278: int retdp;
1.1 noro 3279: Num nhomo;
3280: struct order_spec *ord;
3281:
3282: do_weyl = 0;
3283: if ( (ac = argc(arg)) == 5 ) {
3284: asir_assert(ARG0(arg),O_LIST,"nd_gr_trace");
3285: asir_assert(ARG1(arg),O_LIST,"nd_gr_trace");
3286: asir_assert(ARG2(arg),O_N,"nd_gr_trace");
3287: asir_assert(ARG3(arg),O_N,"nd_gr_trace");
3288: f = (LIST)ARG0(arg); v = (LIST)ARG1(arg);
3289: f = remove_zero_from_list(f);
3290: if ( !BDY(f) ) {
3291: *rp = f; return;
3292: }
1.2 noro 3293: homo = ZTOS((Q)ARG2(arg));
3294: m = ZTOS((Q)ARG3(arg));
1.1 noro 3295: create_order_spec(0,ARG4(arg),&ord);
3296: } else if ( ac == 1 ) {
3297: f = (LIST)ARG0(arg);
3298: parse_gr_option(f,current_option,&v,&nhomo,&m,&ord);
1.2 noro 3299: homo = ZTOS((Q)nhomo);
1.1 noro 3300: } else
3301: error("nd_gr_trace : invalid argument");
1.9 noro 3302: retdp = 0;
3303: if ( get_opt("dp",&val) && val ) retdp = 1;
3304: nd_gr_trace(f,v,m,homo,retdp,0,ord,rp);
1.1 noro 3305: }
3306:
3307: void Pnd_f4_trace(NODE arg,LIST *rp)
3308: {
3309: LIST f,v;
3310: int m,homo,ac;
1.9 noro 3311: int retdp;
3312: Obj val;
1.1 noro 3313: Num nhomo;
3314: struct order_spec *ord;
3315:
3316: do_weyl = 0;
3317: if ( (ac = argc(arg))==5 ) {
3318: asir_assert(ARG0(arg),O_LIST,"nd_f4_trace");
3319: asir_assert(ARG1(arg),O_LIST,"nd_f4_trace");
3320: asir_assert(ARG2(arg),O_N,"nd_f4_trace");
3321: asir_assert(ARG3(arg),O_N,"nd_f4_trace");
3322: f = (LIST)ARG0(arg); v = (LIST)ARG1(arg);
3323: f = remove_zero_from_list(f);
3324: if ( !BDY(f) ) {
3325: *rp = f; return;
3326: }
1.2 noro 3327: homo = ZTOS((Q)ARG2(arg));
3328: m = ZTOS((Q)ARG3(arg));
1.1 noro 3329: create_order_spec(0,ARG4(arg),&ord);
3330: } else if ( ac == 1 ) {
3331: f = (LIST)ARG0(arg);
3332: parse_gr_option(f,current_option,&v,&nhomo,&m,&ord);
1.2 noro 3333: homo = ZTOS((Q)nhomo);
1.1 noro 3334: } else
3335: error("nd_gr_trace : invalid argument");
1.9 noro 3336: retdp = 0;
3337: if ( get_opt("dp",&val) && val ) retdp = 1;
3338: nd_gr_trace(f,v,m,homo,retdp,1,ord,rp);
1.1 noro 3339: }
3340:
3341: void Pnd_weyl_gr(NODE arg,LIST *rp)
3342: {
3343: LIST f,v;
3344: int m,homo,retdp,ac;
3345: Obj val;
3346: Num nhomo;
3347: struct order_spec *ord;
3348:
3349: do_weyl = 1;
3350: retdp = 0;
3351: if ( (ac = argc(arg)) == 4 ) {
3352: asir_assert(ARG0(arg),O_LIST,"nd_weyl_gr");
3353: asir_assert(ARG1(arg),O_LIST,"nd_weyl_gr");
3354: asir_assert(ARG2(arg),O_N,"nd_weyl_gr");
3355: f = (LIST)ARG0(arg); v = (LIST)ARG1(arg);
3356: f = remove_zero_from_list(f);
3357: if ( !BDY(f) ) {
3358: *rp = f; do_weyl = 0; return;
3359: }
1.2 noro 3360: m = ZTOS((Q)ARG2(arg));
1.1 noro 3361: create_order_spec(0,ARG3(arg),&ord);
3362: homo = 0;
3363: if ( get_opt("homo",&val) && val ) homo = 1;
3364: if ( get_opt("dp",&val) && val ) retdp = 1;
3365: } else if ( ac == 1 ) {
3366: f = (LIST)ARG0(arg);
3367: parse_gr_option(f,current_option,&v,&nhomo,&m,&ord);
1.2 noro 3368: homo = ZTOS((Q)nhomo);
1.1 noro 3369: if ( get_opt("dp",&val) && val ) retdp = 1;
3370: } else
3371: error("nd_weyl_gr : invalid argument");
3372: nd_gr(f,v,m,homo,retdp,0,ord,rp);
3373: do_weyl = 0;
3374: }
3375:
3376: void Pnd_weyl_gr_trace(NODE arg,LIST *rp)
3377: {
3378: LIST f,v;
1.9 noro 3379: int m,homo,ac,retdp;
3380: Obj val;
1.1 noro 3381: Num nhomo;
3382: struct order_spec *ord;
3383:
3384: do_weyl = 1;
3385: if ( (ac = argc(arg)) == 5 ) {
3386: asir_assert(ARG0(arg),O_LIST,"nd_weyl_gr_trace");
3387: asir_assert(ARG1(arg),O_LIST,"nd_weyl_gr_trace");
3388: asir_assert(ARG2(arg),O_N,"nd_weyl_gr_trace");
3389: asir_assert(ARG3(arg),O_N,"nd_weyl_gr_trace");
3390: f = (LIST)ARG0(arg); v = (LIST)ARG1(arg);
3391: f = remove_zero_from_list(f);
3392: if ( !BDY(f) ) {
3393: *rp = f; do_weyl = 0; return;
3394: }
1.2 noro 3395: homo = ZTOS((Q)ARG2(arg));
3396: m = ZTOS((Q)ARG3(arg));
1.1 noro 3397: create_order_spec(0,ARG4(arg),&ord);
3398: } else if ( ac == 1 ) {
3399: f = (LIST)ARG0(arg);
3400: parse_gr_option(f,current_option,&v,&nhomo,&m,&ord);
1.2 noro 3401: homo = ZTOS((Q)nhomo);
1.1 noro 3402: } else
3403: error("nd_weyl_gr_trace : invalid argument");
1.9 noro 3404: retdp = 0;
3405: if ( get_opt("dp",&val) && val ) retdp = 1;
3406: nd_gr_trace(f,v,m,homo,retdp,0,ord,rp);
1.1 noro 3407: do_weyl = 0;
3408: }
3409:
3410: void Pnd_nf(NODE arg,Obj *rp)
3411: {
3412: Obj f;
3413: LIST g,v;
3414: struct order_spec *ord;
3415:
3416: do_weyl = 0;
3417: asir_assert(ARG1(arg),O_LIST,"nd_nf");
3418: asir_assert(ARG2(arg),O_LIST,"nd_nf");
3419: asir_assert(ARG4(arg),O_N,"nd_nf");
3420: f = (Obj)ARG0(arg);
3421: g = (LIST)ARG1(arg); g = remove_zero_from_list(g);
3422: if ( !BDY(g) ) {
3423: *rp = f; return;
3424: }
3425: v = (LIST)ARG2(arg);
3426: create_order_spec(0,ARG3(arg),&ord);
1.2 noro 3427: nd_nf_p(f,g,v,ZTOS((Q)ARG4(arg)),ord,rp);
1.1 noro 3428: }
3429:
3430: void Pnd_weyl_nf(NODE arg,Obj *rp)
3431: {
3432: Obj f;
3433: LIST g,v;
3434: struct order_spec *ord;
3435:
3436: do_weyl = 1;
3437: asir_assert(ARG1(arg),O_LIST,"nd_weyl_nf");
3438: asir_assert(ARG2(arg),O_LIST,"nd_weyl_nf");
3439: asir_assert(ARG4(arg),O_N,"nd_weyl_nf");
3440: f = (Obj)ARG0(arg);
3441: g = (LIST)ARG1(arg); g = remove_zero_from_list(g);
3442: if ( !BDY(g) ) {
3443: *rp = f; return;
3444: }
3445: v = (LIST)ARG2(arg);
3446: create_order_spec(0,ARG3(arg),&ord);
1.2 noro 3447: nd_nf_p(f,g,v,ZTOS((Q)ARG4(arg)),ord,rp);
1.1 noro 3448: }
3449:
3450: /* for Weyl algebra */
3451:
3452: void Pdp_weyl_gr_main(NODE arg,LIST *rp)
3453: {
3454: LIST f,v;
3455: Num homo;
3456: Z m,z;
3457: int modular,ac;
3458: struct order_spec *ord;
3459:
3460:
3461: asir_assert(ARG0(arg),O_LIST,"dp_weyl_gr_main");
3462: f = (LIST)ARG0(arg);
3463: f = remove_zero_from_list(f);
3464: if ( !BDY(f) ) {
3465: *rp = f; return;
3466: }
3467: if ( (ac = argc(arg)) == 5 ) {
3468: asir_assert(ARG1(arg),O_LIST,"dp_weyl_gr_main");
3469: asir_assert(ARG2(arg),O_N,"dp_weyl_gr_main");
3470: asir_assert(ARG3(arg),O_N,"dp_weyl_gr_main");
3471: v = (LIST)ARG1(arg);
3472: homo = (Num)ARG2(arg);
3473: m = (Z)ARG3(arg);
1.2 noro 3474: STOZ(0x80000000,z);
1.1 noro 3475: if ( !m )
3476: modular = 0;
3477: else if ( cmpz(m,z) >= 0 )
3478: error("dp_weyl_gr_main : too large modulus");
3479: else
1.2 noro 3480: modular = ZTOS(m);
1.1 noro 3481: create_order_spec(0,ARG4(arg),&ord);
3482: } else if ( current_option )
3483: parse_gr_option(f,current_option,&v,&homo,&modular,&ord);
3484: else if ( ac == 1 )
3485: parse_gr_option(f,0,&v,&homo,&modular,&ord);
3486: else
3487: error("dp_weyl_gr_main : invalid argument");
3488: do_weyl = 1;
3489: dp_gr_main(f,v,homo,modular,0,ord,rp);
3490: do_weyl = 0;
3491: }
3492:
3493: void Pdp_weyl_gr_f_main(NODE arg,LIST *rp)
3494: {
3495: LIST f,v;
3496: Num homo;
3497: struct order_spec *ord;
3498:
3499: asir_assert(ARG0(arg),O_LIST,"dp_weyl_gr_main");
3500: asir_assert(ARG1(arg),O_LIST,"dp_weyl_gr_main");
3501: asir_assert(ARG2(arg),O_N,"dp_weyl_gr_main");
3502: asir_assert(ARG3(arg),O_N,"dp_weyl_gr_main");
3503: f = (LIST)ARG0(arg); v = (LIST)ARG1(arg);
3504: f = remove_zero_from_list(f);
3505: if ( !BDY(f) ) {
3506: *rp = f; return;
3507: }
3508: homo = (Num)ARG2(arg);
3509: create_order_spec(0,ARG3(arg),&ord);
3510: do_weyl = 1;
3511: dp_gr_main(f,v,homo,0,1,ord,rp);
3512: do_weyl = 0;
3513: }
3514:
3515: void Pdp_weyl_f4_main(NODE arg,LIST *rp)
3516: {
3517: LIST f,v;
3518: struct order_spec *ord;
3519:
3520: asir_assert(ARG0(arg),O_LIST,"dp_weyl_f4_main");
3521: asir_assert(ARG1(arg),O_LIST,"dp_weyl_f4_main");
3522: f = (LIST)ARG0(arg); v = (LIST)ARG1(arg);
3523: f = remove_zero_from_list(f);
3524: if ( !BDY(f) ) {
3525: *rp = f; return;
3526: }
3527: create_order_spec(0,ARG2(arg),&ord);
3528: do_weyl = 1;
3529: dp_f4_main(f,v,ord,rp);
3530: do_weyl = 0;
3531: }
3532:
3533: void Pdp_weyl_f4_mod_main(NODE arg,LIST *rp)
3534: {
3535: LIST f,v;
3536: int m;
3537: struct order_spec *ord;
3538:
3539: asir_assert(ARG0(arg),O_LIST,"dp_weyl_f4_main");
3540: asir_assert(ARG1(arg),O_LIST,"dp_weyl_f4_main");
3541: asir_assert(ARG2(arg),O_N,"dp_f4_main");
1.2 noro 3542: f = (LIST)ARG0(arg); v = (LIST)ARG1(arg); m = ZTOS((Q)ARG2(arg));
1.1 noro 3543: f = remove_zero_from_list(f);
3544: if ( !BDY(f) ) {
3545: *rp = f; return;
3546: }
3547: if ( !m )
3548: error("dp_weyl_f4_mod_main : invalid argument");
3549: create_order_spec(0,ARG3(arg),&ord);
3550: do_weyl = 1;
3551: dp_f4_mod_main(f,v,m,ord,rp);
3552: do_weyl = 0;
3553: }
3554:
3555: void Pdp_weyl_gr_mod_main(NODE arg,LIST *rp)
3556: {
3557: LIST f,v;
3558: Num homo;
3559: int m;
3560: struct order_spec *ord;
3561:
3562: asir_assert(ARG0(arg),O_LIST,"dp_weyl_gr_mod_main");
3563: asir_assert(ARG1(arg),O_LIST,"dp_weyl_gr_mod_main");
3564: asir_assert(ARG2(arg),O_N,"dp_weyl_gr_mod_main");
3565: asir_assert(ARG3(arg),O_N,"dp_weyl_gr_mod_main");
3566: f = (LIST)ARG0(arg); v = (LIST)ARG1(arg);
3567: f = remove_zero_from_list(f);
3568: if ( !BDY(f) ) {
3569: *rp = f; return;
3570: }
1.2 noro 3571: homo = (Num)ARG2(arg); m = ZTOS((Q)ARG3(arg));
1.1 noro 3572: if ( !m )
3573: error("dp_weyl_gr_mod_main : invalid argument");
3574: create_order_spec(0,ARG4(arg),&ord);
3575: do_weyl = 1;
3576: dp_gr_mod_main(f,v,homo,m,ord,rp);
3577: do_weyl = 0;
3578: }
3579:
3580: VECT current_dl_weight_vector_obj;
3581: int *current_dl_weight_vector;
3582: int dp_negative_weight;
3583:
3584: void Pdp_set_weight(NODE arg,VECT *rp)
3585: {
3586: VECT v;
3587: int i,n;
3588: NODE node;
3589:
3590: if ( !arg )
3591: *rp = current_dl_weight_vector_obj;
3592: else if ( !ARG0(arg) ) {
3593: current_dl_weight_vector_obj = 0;
3594: current_dl_weight_vector = 0;
3595: dp_negative_weight = 0;
3596: *rp = 0;
3597: } else {
3598: if ( OID(ARG0(arg)) != O_VECT && OID(ARG0(arg)) != O_LIST )
3599: error("dp_set_weight : invalid argument");
3600: if ( OID(ARG0(arg)) == O_VECT )
3601: v = (VECT)ARG0(arg);
3602: else {
3603: node = (NODE)BDY((LIST)ARG0(arg));
3604: n = length(node);
3605: MKVECT(v,n);
3606: for ( i = 0; i < n; i++, node = NEXT(node) )
3607: BDY(v)[i] = BDY(node);
3608: }
3609: current_dl_weight_vector_obj = v;
3610: n = v->len;
3611: current_dl_weight_vector = (int *)CALLOC(n,sizeof(int));
3612: for ( i = 0; i < n; i++ )
1.2 noro 3613: current_dl_weight_vector[i] = ZTOS((Q)v->body[i]);
1.1 noro 3614: for ( i = 0; i < n; i++ )
3615: if ( current_dl_weight_vector[i] < 0 ) break;
3616: if ( i < n )
3617: dp_negative_weight = 1;
3618: else
3619: dp_negative_weight = 0;
3620: *rp = v;
3621: }
3622: }
3623:
3624: VECT current_module_weight_vector_obj;
3625: int *current_module_weight_vector;
3626:
3627: void Pdp_set_module_weight(NODE arg,VECT *rp)
3628: {
3629: VECT v;
3630: int i,n;
3631: NODE node;
3632:
3633: if ( !arg )
3634: *rp = current_module_weight_vector_obj;
3635: else if ( !ARG0(arg) ) {
3636: current_module_weight_vector_obj = 0;
3637: current_module_weight_vector = 0;
3638: *rp = 0;
3639: } else {
3640: if ( OID(ARG0(arg)) != O_VECT && OID(ARG0(arg)) != O_LIST )
3641: error("dp_module_set_weight : invalid argument");
3642: if ( OID(ARG0(arg)) == O_VECT )
3643: v = (VECT)ARG0(arg);
3644: else {
3645: node = (NODE)BDY((LIST)ARG0(arg));
3646: n = length(node);
3647: MKVECT(v,n);
3648: for ( i = 0; i < n; i++, node = NEXT(node) )
3649: BDY(v)[i] = BDY(node);
3650: }
3651: current_module_weight_vector_obj = v;
3652: n = v->len;
3653: current_module_weight_vector = (int *)CALLOC(n,sizeof(int));
3654: for ( i = 0; i < n; i++ )
1.2 noro 3655: current_module_weight_vector[i] = ZTOS((Q)v->body[i]);
1.1 noro 3656: *rp = v;
3657: }
3658: }
3659:
3660: extern Obj current_top_weight;
3661: extern Obj nd_top_weight;
3662:
3663: void Pdp_set_top_weight(NODE arg,Obj *rp)
3664: {
3665: VECT v;
3666: MAT m;
3667: Obj obj;
3668: int i,j,n,id,row,col;
3669: Q *mi;
3670: NODE node;
3671:
3672: if ( !arg )
3673: *rp = current_top_weight;
3674: else if ( !ARG0(arg) ) {
3675: reset_top_weight();
3676: *rp = 0;
3677: } else {
3678: id = OID(ARG0(arg));
3679: if ( id != O_VECT && id != O_MAT && id != O_LIST )
3680: error("dp_set_top_weight : invalid argument");
3681: if ( id == O_LIST ) {
3682: node = (NODE)BDY((LIST)ARG0(arg));
3683: n = length(node);
3684: MKVECT(v,n);
3685: for ( i = 0; i < n; i++, node = NEXT(node) )
3686: BDY(v)[i] = BDY(node);
3687: obj = (Obj)v;
3688: } else
3689: obj = ARG0(arg);
3690: if ( OID(obj) == O_VECT ) {
3691: v = (VECT)obj;
3692: for ( i = 0; i < v->len; i++ )
3693: if ( !INT((Q)BDY(v)[i]) || sgnz((Z)BDY(v)[i]) < 0 )
3694: error("dp_set_top_weight : each element must be a non-negative integer");
3695: } else {
3696: m = (MAT)obj; row = m->row; col = m->col;
3697: for ( i = 0; i < row; i++ )
3698: for ( j = 0, mi = (Q *)BDY(m)[i]; j < col; j++ )
3699: if ( !INT((Q)mi[j]) || sgnz((Z)mi[j]) < 0 )
3700: error("dp_set_top_weight : each element must be a non-negative integer");
3701: }
3702: current_top_weight = obj;
3703: nd_top_weight = obj;
3704: *rp = current_top_weight;
3705: }
3706: }
3707:
3708: LIST get_denomlist();
3709:
3710: void Pdp_get_denomlist(LIST *rp)
3711: {
3712: *rp = get_denomlist();
3713: }
3714:
3715: static VECT current_weyl_weight_vector_obj;
3716: int *current_weyl_weight_vector;
3717:
3718: void Pdp_weyl_set_weight(NODE arg,VECT *rp)
3719: {
3720: VECT v;
3721: NODE node;
3722: int i,n;
3723:
3724: if ( !arg )
3725: *rp = current_weyl_weight_vector_obj;
3726: else if ( !ARG0(arg) ) {
3727: current_weyl_weight_vector_obj = 0;
3728: current_weyl_weight_vector = 0;
3729: *rp = 0;
3730: } else {
3731: if ( OID(ARG0(arg)) != O_VECT && OID(ARG0(arg)) != O_LIST )
3732: error("dp_weyl_set_weight : invalid argument");
3733: if ( OID(ARG0(arg)) == O_VECT )
3734: v = (VECT)ARG0(arg);
3735: else {
3736: node = (NODE)BDY((LIST)ARG0(arg));
3737: n = length(node);
3738: MKVECT(v,n);
3739: for ( i = 0; i < n; i++, node = NEXT(node) )
3740: BDY(v)[i] = BDY(node);
3741: }
3742: current_weyl_weight_vector_obj = v;
3743: n = v->len;
3744: current_weyl_weight_vector = (int *)CALLOC(n,sizeof(int));
3745: for ( i = 0; i < n; i++ )
1.2 noro 3746: current_weyl_weight_vector[i] = ZTOS((Q)v->body[i]);
1.1 noro 3747: *rp = v;
3748: }
3749: }
3750:
3751: NODE mono_raddec(NODE ideal);
3752:
3753: void Pdp_mono_raddec(NODE arg,LIST *rp)
3754: {
3755: NODE ideal,rd,t,t1,r,r1,u;
3756: VL vl0,vl;
3757: int nv,i,bpi;
3758: int *s;
3759: DP dp;
3760: P *v;
3761: LIST l;
3762:
3763: ideal = BDY((LIST)ARG0(arg));
3764: if ( !ideal ) *rp = (LIST)ARG0(arg);
3765: else {
3766: t = BDY((LIST)ARG1(arg));
3767: nv = length(t);
3768: v = (P *)MALLOC(nv*sizeof(P));
3769: for ( vl0 = 0, i = 0; t; t = NEXT(t), i++ ) {
3770: NEXTVL(vl0,vl); VR(vl) = VR((P)BDY(t));
3771: MKV(VR(vl),v[i]);
3772: }
3773: if ( vl0 ) NEXT(vl) = 0;
3774: for ( t = 0, r = ideal; r; r = NEXT(r) ) {
3775: ptod(CO,vl0,BDY(r),&dp); MKNODE(t1,dp,t); t = t1;
3776: }
3777: rd = mono_raddec(t);
3778: r = 0;
3779: bpi = (sizeof(int)/sizeof(char))*8;
3780: for ( u = rd; u; u = NEXT(u) ) {
3781: s = (int *)BDY(u);
3782: for ( i = nv-1, t = 0; i >= 0; i-- )
3783: if ( s[i/bpi]&(1<<(i%bpi)) ) {
3784: MKNODE(t1,v[i],t); t = t1;
3785: }
3786: MKLIST(l,t); MKNODE(r1,l,r); r = r1;
3787: }
3788: MKLIST(*rp,r);
3789: }
3790: }
3791:
3792: void Pdp_mono_reduce(NODE arg,LIST *rp)
3793: {
3794: NODE t,t0,t1,r0,r;
3795: int i,n;
3796: DP m;
3797: DP *a;
3798:
3799: t0 = BDY((LIST)ARG0(arg));
3800: t1 = BDY((LIST)ARG1(arg));
3801: n = length(t0);
3802: a = (DP *)MALLOC(n*sizeof(DP));
3803: for ( i = 0; i < n; i++, t0 = NEXT(t0) ) a[i] = (DP)BDY(t0);
3804: for ( t = t1; t; t = NEXT(t) ) {
3805: m = (DP)BDY(t);
3806: for ( i = 0; i < n; i++ )
3807: if ( a[i] && dp_redble(a[i],m) ) a[i] = 0;
3808: }
3809: for ( i = n-1, r0 = 0; i >= 0; i-- )
3810: if ( a[i] ) { NEXTNODE(r0,r); BDY(r) = a[i]; }
3811: if ( r0 ) NEXT(r) = 0;
3812: MKLIST(*rp,r0);
3813: }
3814:
3815: #define BLEN (8*sizeof(unsigned long))
3816:
3817: void showmat2(unsigned long **a,int row,int col)
3818: {
3819: int i,j;
3820:
3821: for ( i = 0; i < row; i++, putchar('\n') )
3822: for ( j = 0; j < col; j++ )
3823: if ( a[i][j/BLEN] & (1L<<(j%BLEN)) ) putchar('1');
3824: else putchar('0');
3825: }
3826:
3827: int rref2(unsigned long **a,int row,int col)
3828: {
3829: int i,j,k,l,s,wcol,wj;
3830: unsigned long bj;
3831: unsigned long *ai,*ak,*as,*t;
3832: int *pivot;
3833:
3834: wcol = (col+BLEN-1)/BLEN;
3835: pivot = (int *)MALLOC_ATOMIC(row*sizeof(int));
3836: i = 0;
3837: for ( j = 0; j < col; j++ ) {
3838: wj = j/BLEN; bj = 1L<<(j%BLEN);
3839: for ( k = i; k < row; k++ )
3840: if ( a[k][wj] & bj ) break;
3841: if ( k == row ) continue;
3842: pivot[i] = j;
3843: if ( k != i ) {
3844: t = a[i]; a[i] = a[k]; a[k] = t;
3845: }
3846: ai = a[i];
3847: for ( k = i+1; k < row; k++ ) {
3848: ak = a[k];
3849: if ( ak[wj] & bj ) {
3850: for ( l = wj; l < wcol; l++ )
3851: ak[l] ^= ai[l];
3852: }
3853: }
3854: i++;
3855: }
3856: for ( k = i-1; k >= 0; k-- ) {
3857: j = pivot[k]; wj = j/BLEN; bj = 1L<<(j%BLEN);
3858: ak = a[k];
3859: for ( s = 0; s < k; s++ ) {
3860: as = a[s];
3861: if ( as[wj] & bj ) {
3862: for ( l = wj; l < wcol; l++ )
3863: as[l] ^= ak[l];
3864: }
3865: }
3866: }
3867: return i;
3868: }
3869:
3870: void Pdp_rref2(NODE arg,VECT *rp)
3871: {
3872: VECT f,term,ret;
3873: int row,col,wcol,size,nv,i,j,rank,td;
3874: unsigned long **mat;
3875: unsigned long *v;
3876: DL d;
3877: DL *t;
3878: DP dp;
3879: MP m,m0;
3880:
3881: f = (VECT)ARG0(arg);
3882: row = f->len;
3883: term = (VECT)ARG1(arg);
3884: col = term->len;
3885: mat = (unsigned long **)MALLOC(row*sizeof(unsigned long *));
3886: size = sizeof(unsigned long)*((col+BLEN-1)/BLEN);
3887: nv = ((DP)term->body[0])->nv;
3888: t = (DL *)MALLOC(col*sizeof(DL));
3889: for ( i = 0; i < col; i++ ) t[i] = BDY((DP)BDY(term)[i])->dl;
3890: for ( i = 0; i < row; i++ ) {
3891: v = mat[i] = (unsigned long *)MALLOC_ATOMIC_IGNORE_OFF_PAGE(size);
3892: bzero(v,size);
3893: for ( j = 0, m = BDY((DP)BDY(f)[i]); m; m = NEXT(m) ) {
3894: d = m->dl;
3895: for ( ; !dl_equal(nv,d,t[j]); j++ );
3896: v[j/BLEN] |= 1L <<(j%BLEN);
3897: }
3898: }
3899: rank = rref2(mat,row,col);
3900: MKVECT(ret,rank);
3901: *rp = ret;
3902: for ( i = 0; i < rank; i++ ) {
3903: v = mat[i];
3904: m0 = 0;
3905: td = 0;
3906: for ( j = 0; j < col; j++ ) {
3907: if ( v[j/BLEN] & (1L<<(j%BLEN)) ) {
3908: NEXTMP(m0,m);
3909: m->dl = t[j];
3910: m->c = (Obj)ONE;
3911: td = MAX(td,m->dl->td);
3912: }
3913: }
3914: NEXT(m) = 0;
3915: MKDP(nv,m0,dp);
3916: dp->sugar = td;
3917: BDY(ret)[i] = (pointer)dp;
3918: }
3919: }
3920:
3921: #define HDL(f) (BDY(f)->dl)
3922:
3923: NODE sumi_criB(int nv,NODE d,DP *f,int m)
3924: {
3925: LIST p;
3926: NODE r0,r;
3927: int p0,p1;
3928: DL p2,lcm;
3929:
3930: NEWDL(lcm,nv);
3931: r0 = 0;
3932: for ( ; d; d = NEXT(d) ) {
3933: p = (LIST)BDY(d);
1.2 noro 3934: p0 = ZTOS((Q)ARG0(BDY(p)));
3935: p1 = ZTOS((Q)ARG1(BDY(p)));
1.1 noro 3936: p2 = HDL((DP)ARG2(BDY(p)));
3937: if(!_dl_redble(HDL((DP)f[m]),p2,nv) ||
3938: dl_equal(nv,lcm_of_DL(nv,HDL(f[p0]),HDL(f[m]),lcm),p2) ||
3939: dl_equal(nv,lcm_of_DL(nv,HDL(f[p1]),HDL(f[m]),lcm),p2) ) {
3940: NEXTNODE(r0,r);
3941: BDY(r) = p;
3942: }
3943: }
3944: if ( r0 ) NEXT(r) = 0;
3945: return r0;
3946: }
3947:
3948: NODE sumi_criFMD(int nv,DP *f,int m)
3949: {
3950: DL *a;
3951: DL l1,dl1,dl2;
3952: int i,j,k,k2;
3953: NODE r,r1,nd;
3954: MP mp;
3955: DP u;
3956: Z iq,mq;
3957: LIST list;
3958:
3959: /* a[i] = lcm(LT(f[i]),LT(f[m])) */
3960: a = (DL *)ALLOCA(m*sizeof(DL));
3961: for ( i = 0; i < m; i++ ) {
3962: a[i] = lcm_of_DL(nv,HDL(f[i]),HDL(f[m]),0);
3963: }
3964: r = 0;
3965: for( i = 0; i < m; i++) {
3966: l1 = a[i];
3967: if ( !l1 ) continue;
3968: /* Tkm = Tim (k<i) */
3969: for( k = 0; k < i; k++)
3970: if( dl_equal(nv,l1,a[k]) ) break;
3971: if( k == i ){
3972: /* Tk|Tim && Tkm != Tim (k<m) */
3973: for ( k2 = 0; k2 < m; k2++ )
3974: if ( _dl_redble(HDL(f[k2]),l1,nv) &&
3975: !dl_equal(nv,l1,a[k2]) ) break;
3976: if ( k2 == m ) {
3977: dl1 = HDL(f[i]); dl2 = HDL(f[m]);
3978: for ( k2 = 0; k2 < nv; k2++ )
3979: if ( dl1->d[k2] && dl2->d[k2] ) break;
3980: if ( k2 < nv ) {
3981: NEWMP(mp); mp->dl = l1; C(mp) = (Obj)ONE;
3982: NEXT(mp) = 0; MKDP(nv,mp,u); u->sugar = l1->td;
1.2 noro 3983: STOZ(i,iq); STOZ(m,mq);
1.1 noro 3984: nd = mknode(3,iq,mq,u);
3985: MKLIST(list,nd);
3986: MKNODE(r1,list,r);
3987: r = r1;
3988: }
3989: }
3990: }
3991: }
3992: return r;
3993: }
3994:
3995: LIST sumi_updatepairs(LIST d,DP *f,int m)
3996: {
3997: NODE old,new,t;
3998: LIST l;
3999: int nv;
4000:
4001: nv = f[0]->nv;
4002: old = sumi_criB(nv,BDY(d),f,m);
4003: new = sumi_criFMD(nv,f,m);
4004: if ( !new ) new = old;
4005: else {
4006: for ( t = new ; NEXT(t); t = NEXT(t) );
4007: NEXT(t) = old;
4008: }
4009: MKLIST(l,new);
4010: return l;
4011: }
4012:
4013: VECT ltov(LIST l)
4014: {
4015: NODE n;
4016: int i,len;
4017: VECT v;
4018:
4019: n = BDY(l);
4020: len = length(n);
4021: MKVECT(v,len);
4022: for ( i = 0; i < len; i++, n = NEXT(n) )
4023: BDY(v)[i] = BDY(n);
4024: return v;
4025: }
4026:
4027: DL subdl(int nv,DL d1,DL d2)
4028: {
4029: int i;
4030: DL d;
4031:
4032: NEWDL(d,nv);
4033: d->td = d1->td-d2->td;
4034: for ( i = 0; i < nv; i++ )
4035: d->d[i] = d1->d[i]-d2->d[i];
4036: return d;
4037: }
4038:
4039: DP dltodp(int nv,DL d)
4040: {
4041: MP mp;
4042: DP dp;
4043:
4044: NEWMP(mp); mp->dl = d; C(mp) = (Obj)ONE;
4045: NEXT(mp) = 0; MKDP(nv,mp,dp); dp->sugar = d->td;
4046: return dp;
4047: }
4048:
4049: LIST sumi_simplify(int nv,DL t,DP p,NODE f2,int simp)
4050: {
4051: DL d,h,hw;
4052: DP u,w,dp;
4053: int n,i,last;
4054: LIST *v;
4055: LIST list;
4056: NODE s,r;
4057:
4058: d = t; u = p;
4059: /* only the last history is used */
4060: if ( f2 && simp && t->td != 0 ) {
4061: adddl(nv,t,HDL(p),&h);
4062: n = length(f2);
4063: last = 1;
4064: if ( simp > 1 ) last = n;
4065: v = (LIST *)ALLOCA(n*sizeof(LIST));
4066: for ( r = f2, i = 0; r; r = NEXT(r), i++ ) v[n-i-1] = BDY(r);
4067: for ( i = 0; i < last; i++ ) {
4068: for ( s = BDY((LIST)v[i]); s; s = NEXT(s) ) {
4069: w = (DP)BDY(s); hw = HDL(w);
4070: if ( _dl_redble(hw,h,nv) ) {
4071: u = w;
4072: d = subdl(nv,h,hw);
4073: goto fin;
4074: }
4075: }
4076: }
4077: }
4078: fin:
4079: dp = dltodp(nv,d);
4080: r = mknode(2,dp,u);
4081: MKLIST(list,r);
4082: return list;
4083: }
4084:
4085: LIST sumi_symbolic(NODE l,int q,NODE f2,DP *g,int simp)
4086: {
4087: int nv;
4088: NODE t,r;
4089: NODE f0,f,fd0,fd,done0,done,red0,red;
4090: DL h,d;
4091: DP mul;
4092: int m;
4093: LIST tp,l0,l1,l2,l3,list;
4094: VECT v0,v1,v2,v3;
4095:
4096: nv = ((DP)BDY(l))->nv;
4097: t = 0;
4098:
4099: f0 = 0; fd0 = 0; done0 = 0; red0 = 0;
4100:
4101: for ( ; l; l = NEXT(l) ) {
4102: t = symb_merge(t,dp_dllist((DP)BDY(l)),nv);
4103: NEXTNODE(fd0,fd); BDY(fd) = BDY(l);
4104: }
4105:
4106: while ( t ) {
4107: h = (DL)BDY(t);
4108: NEXTNODE(done0,done); BDY(done) = dltodp(nv,h);
4109: t = NEXT(t);
4110: for(m = 0; m < q; m++)
4111: if ( _dl_redble(HDL(g[m]),h,nv) ) break;
4112: if ( m == q ) {
4113: } else {
4114: d = subdl(nv,h,HDL(g[m]));
4115: tp = sumi_simplify(nv,d,g[m],f2,simp);
4116:
4117: muldm(CO,ARG1(BDY(tp)),BDY((DP)ARG0(BDY(tp))),&mul);
4118: t = symb_merge(t,NEXT(dp_dllist(mul)),nv);
4119:
4120: NEXTNODE(f0,f); BDY(f) = tp;
4121: NEXTNODE(fd0,fd); BDY(fd) = mul;
4122: NEXTNODE(red0,red); BDY(red) = mul;
4123: }
4124: }
4125: if ( fd0 ) NEXT(fd) = 0; MKLIST(l0,fd0);
4126: v0 = ltov(l0);
4127: if ( done0 ) NEXT(done) = 0; MKLIST(l1,done0);
4128: v1 = ltov(l1);
4129: if ( f0 ) NEXT(f) = 0; MKLIST(l2,f0);
4130: v2 = ltov(l2);
4131: if ( red0 ) NEXT(red) = 0; MKLIST(l3,red0);
4132: v3 = ltov(l3);
4133: r = mknode(4,v0,v1,v2,v3);
4134: MKLIST(list,r);
4135: return list;
4136: }
4137:
4138: void Psumi_symbolic(NODE arg,LIST *rp)
4139: {
4140: NODE l,f2;
4141: DP *g;
4142: int q,simp;
4143:
4144: l = BDY((LIST)ARG0(arg));
1.2 noro 4145: q = ZTOS((Q)ARG1(arg));
1.1 noro 4146: f2 = BDY((LIST)ARG2(arg));
4147: g = (DP *)BDY((VECT)ARG3(arg));
1.2 noro 4148: simp = ZTOS((Q)ARG4(arg));
1.1 noro 4149: *rp = sumi_symbolic(l,q,f2,g,simp);
4150: }
4151:
4152: void Psumi_updatepairs(NODE arg,LIST *rp)
4153: {
4154: LIST d,l;
4155: DP *f;
4156: int m;
4157:
4158: d = (LIST)ARG0(arg);
4159: f = (DP *)BDY((VECT)ARG1(arg));
1.2 noro 4160: m = ZTOS((Q)ARG2(arg));
1.1 noro 4161: *rp = sumi_updatepairs(d,f,m);
4162: }
4163:
4164: LIST remove_zero_from_list(LIST l)
4165: {
4166: NODE n,r0,r;
4167: LIST rl;
4168:
4169: asir_assert(l,O_LIST,"remove_zero_from_list");
4170: n = BDY(l);
4171: for ( r0 = 0; n; n = NEXT(n) )
4172: if ( BDY(n) ) {
4173: NEXTNODE(r0,r);
4174: BDY(r) = BDY(n);
4175: }
4176: if ( r0 )
4177: NEXT(r) = 0;
4178: MKLIST(rl,r0);
4179: return rl;
4180: }
4181:
4182: int get_field_type(P p)
4183: {
4184: int type,t;
4185: DCP dc;
4186:
4187: if ( !p )
4188: return 0;
4189: else if ( NUM(p) )
4190: return NID((Num)p);
4191: else {
4192: type = 0;
4193: for ( dc = DC(p); dc; dc = NEXT(dc) ) {
4194: t = get_field_type(COEF(dc));
4195: if ( !t )
4196: continue;
4197: if ( t < 0 )
4198: return t;
4199: if ( !type )
4200: type = t;
4201: else if ( t != type )
4202: return -1;
4203: }
4204: return type;
4205: }
4206: }
4207:
4208: void Pdpv_ord(NODE arg,Obj *rp)
4209: {
4210: int ac,id;
4211: LIST shift;
4212:
4213: ac = argc(arg);
4214: if ( ac ) {
1.2 noro 4215: id = ZTOS((Q)ARG0(arg));
1.1 noro 4216: if ( ac > 1 && ARG1(arg) && OID((Obj)ARG1(arg))==O_LIST )
4217: shift = (LIST)ARG1(arg);
4218: else
4219: shift = 0;
4220: create_modorder_spec(id,shift,&dp_current_modspec);
4221: }
4222: *rp = dp_current_modspec->obj;
4223: }
4224:
1.9 noro 4225: extern int dpm_ordtype;
1.15 noro 4226: extern DMMstack dmm_stack;
1.9 noro 4227:
1.11 noro 4228: void set_schreyer_order(LIST n);
1.1 noro 4229:
1.10 noro 4230: void Pdpm_set_schreyer(NODE arg,LIST *rp)
1.1 noro 4231: {
1.9 noro 4232: if ( argc(arg) ) {
1.17 noro 4233: set_schreyer_order(ARG0(arg)?(LIST)ARG0(arg):0);
1.1 noro 4234: }
1.17 noro 4235: if ( dmm_stack )
4236: *rp = dmm_stack->obj;
4237: else
4238: *rp = 0;
1.1 noro 4239: }
4240:
1.18 noro 4241: DMMstack_array Schreyer_Frame;
1.23 noro 4242: DMMstack_array dpm_schreyer_frame(NODE n,int lex);
1.18 noro 4243: void set_schreyer_level(DMMstack_array array,int level);
4244:
4245: void Pdpm_set_schreyer_level(NODE arg,Q *rp)
4246: {
4247: set_schreyer_level(Schreyer_Frame,ZTOS((Q)ARG0(arg)));
4248: *rp = (Q)ARG0(arg);
4249: }
4250:
4251: void Pdpm_schreyer_frame(NODE arg,LIST *rp)
4252: {
4253: DMMstack_array a;
4254: DMMstack *body;
1.20 noro 4255: DMM *in,*sum;
4256: DPM f,s;
4257: NODE b,b1,nd;
1.18 noro 4258: LIST l;
1.20 noro 4259: VECT v;
4260: Z lev,deg,ind;
1.23 noro 4261: int len,i,nv,rank,j,lex;
4262: NODE tt,p;
4263: char *key;
4264: Obj value;
1.18 noro 4265:
1.23 noro 4266: lex = 0;
4267: if ( current_option ) {
4268: for ( tt = current_option; tt; tt = NEXT(tt) ) {
4269: p = BDY((LIST)BDY(tt));
4270: key = BDY((STRING)BDY(p));
4271: value = (Obj)BDY(NEXT(p));
4272: if ( !strcmp(key,"lex") )
4273: lex = value!=0?1:0;
4274: else {
4275: error("dpm_schreyer_frame: unknown option.");
4276: }
4277: }
4278: }
4279: Schreyer_Frame = a = dpm_schreyer_frame(BDY((LIST)ARG0(arg)),lex);
1.18 noro 4280: len = a->len;
4281: body = a->body;
1.20 noro 4282: /* XXX */
4283: nv = ((DPM)BDY(BDY((LIST)body[0]->obj)))->nv;
1.18 noro 4284: b = 0;
4285: for ( i = 0; i < len; i++ ) {
1.20 noro 4286: rank = body[i]->rank;
4287: in = body[i]->in;
4288: sum = body[i]->sum;
4289: MKVECT(v,rank+1);
4290: STOZ(i+1,lev);
4291: for ( j = 1; j <= rank; j++ ) {
4292: MKDPM(nv,in[j],f); f->sugar = in[j]->dl->td;
4293: MKDPM(nv,sum[j],s);s->sugar = sum[j]->dl->td;
4294: STOZ(s->sugar,deg);
4295: STOZ(j,ind);
4296: nd = mknode(5,f,s,ind,lev,deg);
4297: MKLIST(l,nd);
4298: BDY(v)[j] = (pointer)l;
4299: }
4300: MKNODE(b1,(pointer)v,b);
1.18 noro 4301: b = b1;
4302: }
4303: MKLIST(l,b);
4304: *rp = l;
4305: }
4306:
4307:
1.1 noro 4308: void Pdpm_hm(NODE arg,DPM *rp)
4309: {
4310: DPM p;
4311:
4312: p = (DPM)ARG0(arg); asir_assert(p,O_DPM,"dpm_hm");
4313: dpm_hm(p,rp);
4314: }
4315:
4316: void Pdpm_ht(NODE arg,DPM *rp)
4317: {
4318: DPM p;
4319:
1.9 noro 4320: p = (DPM)ARG0(arg); asir_assert(p,O_DPM,"dpm_ht");
1.1 noro 4321: dpm_ht(p,rp);
4322: }
4323:
1.10 noro 4324: void dpm_rest(DPM p,DPM *r);
4325:
4326: void Pdpm_rest(NODE arg,DPM *rp)
4327: {
4328: DPM p;
4329:
4330: p = (DPM)ARG0(arg); asir_assert(p,O_DPM,"dpm_ht");
4331: dpm_rest(p,rp);
4332: }
4333:
4334:
4335: void Pdpm_hp(NODE arg,Z *rp)
4336: {
4337: DPM p;
4338: int pos;
4339:
4340: p = (DPM)ARG0(arg); asir_assert(p,O_DPM,"dpm_ht");
4341: pos = BDY(p)->pos;
4342: STOZ(pos,*rp);
4343: }
4344:
1.9 noro 4345: void dpm_shift(DPM p,int s,DPM *rp);
4346:
4347: void Pdpm_shift(NODE arg,DPM *rp)
4348: {
4349: DPM p;
4350: int s;
4351:
4352: p = (DPM)ARG0(arg); asir_assert(p,O_DPM,"dpm_shift");
4353: s = ZTOS((Z)ARG1(arg));
4354: dpm_shift(p,s,rp);
4355: }
4356:
4357: void dpm_sort(DPM p,DPM *rp);
4358:
4359: void Pdpm_sort(NODE arg,DPM *rp)
4360: {
4361: DPM p;
4362: int s;
4363:
1.10 noro 4364: p = (DPM)ARG0(arg);
4365: if ( !p ) *rp = 0;
1.21 noro 4366: else dpm_sort(p,rp);
1.9 noro 4367: }
4368:
4369: void dpm_split(DPM p,int s,DPM *up,DPM *lo);
1.21 noro 4370: void dpm_extract(DPM p,int s,DP *r);
1.9 noro 4371:
4372: void Pdpm_split(NODE arg,LIST *rp)
4373: {
4374: DPM p,up,lo;
4375: int s;
4376: NODE nd;
4377:
1.10 noro 4378: p = (DPM)ARG0(arg);
1.9 noro 4379: s = ZTOS((Z)ARG1(arg));
4380: dpm_split(p,s,&up,&lo);
4381: nd = mknode(2,up,lo);
4382: MKLIST(*rp,nd);
4383: }
4384:
1.21 noro 4385: void Pdpm_extract(NODE arg,DP *rp)
4386: {
4387: DPM p;
4388: int s;
4389:
4390: p = (DPM)ARG0(arg);
4391: s = ZTOS((Z)ARG1(arg));
4392: dpm_extract(p,s,rp);
4393: }
4394:
1.9 noro 4395:
1.13 noro 4396: void Pdpm_hc(NODE arg,DP *rp)
1.1 noro 4397: {
1.13 noro 4398: DPM p;
4399: DP d;
4400: MP m;
4401:
1.1 noro 4402: asir_assert(ARG0(arg),O_DPM,"dpm_hc");
4403: if ( !ARG0(arg) )
4404: *rp = 0;
1.13 noro 4405: else {
4406: p = (DPM)ARG0(arg);
4407: NEWMP(m);
4408: m->dl = BDY(p)->dl;
4409: m->c = BDY(p)->c;
4410: NEXT(m) = 0;
4411: MKDP(NV(p),m,d); d->sugar = p->sugar;
4412: *rp = d;
4413: }
1.1 noro 4414: }
4415:
4416: void Pdpv_ht(NODE arg,LIST *rp)
4417: {
4418: NODE n;
4419: DP ht;
4420: int pos;
4421: DPV p;
4422: Z q;
4423:
4424: asir_assert(ARG0(arg),O_DPV,"dpv_ht");
4425: p = (DPV)ARG0(arg);
4426: pos = dpv_hp(p);
4427: if ( pos < 0 )
4428: ht = 0;
4429: else
4430: dp_ht(BDY(p)[pos],&ht);
1.2 noro 4431: STOZ(pos,q);
1.1 noro 4432: n = mknode(2,q,ht);
4433: MKLIST(*rp,n);
4434: }
4435:
4436: void Pdpv_hm(NODE arg,LIST *rp)
4437: {
4438: NODE n;
4439: DP ht;
4440: int pos;
4441: DPV p;
4442: Z q;
4443:
4444: asir_assert(ARG0(arg),O_DPV,"dpv_hm");
4445: p = (DPV)ARG0(arg);
4446: pos = dpv_hp(p);
4447: if ( pos < 0 )
4448: ht = 0;
4449: else
4450: dp_hm(BDY(p)[pos],&ht);
1.2 noro 4451: STOZ(pos,q);
1.1 noro 4452: n = mknode(2,q,ht);
4453: MKLIST(*rp,n);
4454: }
4455:
4456: void Pdpv_hc(NODE arg,LIST *rp)
4457: {
4458: NODE n;
4459: P hc;
4460: int pos;
4461: DPV p;
4462: Z q;
4463:
4464: asir_assert(ARG0(arg),O_DPV,"dpv_hc");
4465: p = (DPV)ARG0(arg);
4466: pos = dpv_hp(p);
4467: if ( pos < 0 )
4468: hc = 0;
4469: else
4470: hc = (P)BDY(BDY(p)[pos])->c;
1.2 noro 4471: STOZ(pos,q);
1.1 noro 4472: n = mknode(2,q,hc);
4473: MKLIST(*rp,n);
4474: }
4475:
4476: int dpv_hp(DPV p)
4477: {
4478: int len,i,maxp,maxw,w,slen;
4479: int *shift;
4480: DP *e;
4481:
4482: len = p->len;
4483: e = p->body;
4484: slen = dp_current_modspec->len;
4485: shift = dp_current_modspec->degree_shift;
4486: switch ( dp_current_modspec->id ) {
4487: case ORD_REVGRADLEX:
4488: for ( maxp = -1, i = 0; i < len; i++ )
4489: if ( !e[i] ) continue;
4490: else if ( maxp < 0 ) {
4491: maxw = BDY(e[i])->dl->td+(i<slen?shift[i]:0); maxp = i;
4492: } else {
4493: w = BDY(e[i])->dl->td+(i<slen?shift[i]:0);
4494: if ( w >= maxw ) {
4495: maxw = w; maxp = i;
4496: }
4497: }
4498: return maxp;
4499: case ORD_GRADLEX:
4500: for ( maxp = -1, i = 0; i < len; i++ )
4501: if ( !e[i] ) continue;
4502: else if ( maxp < 0 ) {
4503: maxw = BDY(e[i])->dl->td+(i<slen?shift[i]:0); maxp = i;
4504: } else {
4505: w = BDY(e[i])->dl->td+(i<slen?shift[i]:0);
4506: if ( w > maxw ) {
4507: maxw = w; maxp = i;
4508: }
4509: }
4510: return maxp;
4511: break;
4512: case ORD_LEX:
4513: for ( i = 0; i < len; i++ )
4514: if ( e[i] ) return i;
4515: return -1;
4516: break;
1.9 noro 4517: default:
4518: error("dpv_hp : unsupported term ordering");
4519: return -1;
4520: break;
1.1 noro 4521: }
4522: }
4523:
4524: int get_opt(char *key0,Obj *r) {
4525: NODE tt,p;
4526: char *key;
4527:
4528: if ( current_option ) {
4529: for ( tt = current_option; tt; tt = NEXT(tt) ) {
4530: p = BDY((LIST)BDY(tt));
4531: key = BDY((STRING)BDY(p));
4532: /* value = (Obj)BDY(NEXT(p)); */
4533: if ( !strcmp(key,key0) ) {
4534: *r = (Obj)BDY(NEXT(p));
4535: return 1;
4536: }
4537: }
4538: }
4539: return 0;
4540: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>