Annotation of OpenXM_contrib2/asir2000/engine/init.c, Revision 1.8
1.2 noro 1: /*
2: * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED
3: * All rights reserved.
4: *
5: * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited,
6: * non-exclusive and royalty-free license to use, copy, modify and
7: * redistribute, solely for non-commercial and non-profit purposes, the
8: * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and
9: * conditions of this Agreement. For the avoidance of doubt, you acquire
10: * only a limited right to use the SOFTWARE hereunder, and FLL or any
11: * third party developer retains all rights, including but not limited to
12: * copyrights, in and to the SOFTWARE.
13: *
14: * (1) FLL does not grant you a license in any way for commercial
15: * purposes. You may use the SOFTWARE only for non-commercial and
16: * non-profit purposes only, such as academic, research and internal
17: * business use.
18: * (2) The SOFTWARE is protected by the Copyright Law of Japan and
19: * international copyright treaties. If you make copies of the SOFTWARE,
20: * with or without modification, as permitted hereunder, you shall affix
21: * to all such copies of the SOFTWARE the above copyright notice.
22: * (3) An explicit reference to this SOFTWARE and its copyright owner
23: * shall be made on your publication or presentation in any form of the
24: * results obtained by use of the SOFTWARE.
25: * (4) In the event that you modify the SOFTWARE, you shall notify FLL by
1.3 noro 26: * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
1.2 noro 27: * for such modification or the source code of the modified part of the
28: * SOFTWARE.
29: *
30: * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL
31: * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND
32: * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS
33: * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES'
34: * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY
35: * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY.
36: * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT,
37: * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY
38: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
39: * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES
40: * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES
41: * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY
42: * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
43: * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART
44: * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
45: * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
46: * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
47: *
1.8 ! noro 48: * $OpenXM: OpenXM_contrib2/asir2000/engine/init.c,v 1.7 2000/12/22 10:03:28 saito Exp $
1.2 noro 49: */
1.1 noro 50: #include "ca.h"
51: #include "version.h"
52:
53: struct oN oUNIN,oTWON,oTHREEN,oFOURN,oFIVEN,oSIXN,oSEVENN,oEIGHTN;
54: struct oQ oUNIQ,oTWOQ,oTHREEQ,oFOURQ,oFIVEQ,oSIXQ,oSEVENQ,oEIGHTQ;
55:
56: struct oUP2 oONEUP2;
57:
58: N ONEN = &oUNIN;
59: Q ONE = &oUNIQ;
60: Q TWO = &oTWOQ;
61: Q THREE = &oTHREEQ;
62: Q FOUR = &oFOURQ;
63: Q FIVE = &oFIVEQ;
64: Q SIX = &oSIXQ;
65: Q SEVEN = &oSEVENQ;
66: Q EIGHT = &oEIGHTQ;
67:
68: LM THREE_LM,FOUR_LM,EIGHT_LM;
69:
70: struct oR oUNIR;
71: struct oMQ oUNIMQ;
72: struct oLM oUNILM;
73: struct oC oIU;
74: struct oUSINT oVOID;
75:
76: MQ ONEM = &oUNIMQ;
77: LM ONELM = &oUNILM;
78: UP2 ONEUP2 = &oONEUP2;
79: C IU = &oIU;
80: USINT VOIDobj = &oVOID;
81:
82: int bigfloat;
83: int nez = 1;
84: int current_mod = 0;
85:
86: #if PARI
87: int paristack = 1<<16;
88:
1.7 saito 89: #if defined(INTERVAL)
90: int zerorewrite = 0;
91: void (*addnumt[])() = { addq, addreal, addalg, addbf, additvp, additvd, 0, additvf, addcplx, addmi, addlm, addgf2n, addgfpn };
92: void (*subnumt[])() = { subq, subreal, subalg, subbf, subitvp, subitvd, 0, subitvf, subcplx, submi, sublm, subgf2n, subgfpn };
93: void (*mulnumt[])() = { mulq, mulreal, mulalg, mulbf, mulitvp, mulitvd, 0, mulitvf, mulcplx, mulmi, mullm, mulgf2n, mulgfpn };
94: void (*divnumt[])() = { divq, divreal, divalg, divbf, divitvp, divitvd, 0, divitvf, divcplx, divmi, divlm, divgf2n, divgfpn };
95: void (*pwrnumt[])() = { pwrq, pwrreal, pwralg, pwrbf, pwritvp, pwritvd, 0, pwritvf, pwrcplx, pwrmi, pwrlm, pwrgf2n, pwrgfpn };
96: void (*chsgnnumt[])() = { chsgnq, chsgnreal, chsgnalg, chsgnbf, chsgnitvp, chsgnitvd, 0, chsgnitvf, chsgncplx, chsgnmi, chsgnlm, chsgngf2n, chsgngfpn };
97: int (*cmpnumt[])() = { cmpq, cmpreal, cmpalg, cmpbf, cmpitvp, cmpitvd, 0, cmpitvf, cmpcplx, cmpmi, cmplm, cmpgf2n, cmpgfpn };
98: #else
1.1 noro 99: void (*addnumt[])() = { addq, addreal, addalg, addbf, addcplx, addmi, addlm, addgf2n, addgfpn };
100: void (*subnumt[])() = { subq, subreal, subalg, subbf, subcplx, submi, sublm, subgf2n, subgfpn };
101: void (*mulnumt[])() = { mulq, mulreal, mulalg, mulbf, mulcplx, mulmi, mullm, mulgf2n, mulgfpn };
102: void (*divnumt[])() = { divq, divreal, divalg, divbf, divcplx, divmi, divlm, divgf2n, divgfpn };
103: void (*pwrnumt[])() = { pwrq, pwrreal, pwralg, pwrbf, pwrcplx, pwrmi, pwrlm, pwrgf2n, pwrgfpn };
104: void (*chsgnnumt[])() = { chsgnq, chsgnreal, chsgnalg, chsgnbf, chsgncplx, chsgnmi, chsgnlm, chsgngf2n, chsgngfpn };
105: int (*cmpnumt[])() = { cmpq, cmpreal, cmpalg, cmpbf, cmpcplx, cmpmi, cmplm, cmpgf2n, cmpgfpn };
1.7 saito 106: #endif
107: #else
108: #if defined(INTERVAL)
109: void (*addnumt[])() = { addq, addreal, addalg, 0, additvp, additvd, 0, additvf, addcplx, addmi, addlm, addgf2n, addgfpn };
110: void (*subnumt[])() = { subq, subreal, subalg, 0, subitvp, subitvd, 0, subitvf, subcplx, submi, sublm, subgf2n, subgfpn };
111: void (*mulnumt[])() = { mulq, mulreal, mulalg, 0, mulitvp, mulitvd, 0, mulitvf, mulcplx, mulmi, mullm, mulgf2n, mulgfpn };
112: void (*divnumt[])() = { divq, divreal, divalg, 0, divitvp, divitvd, 0, divitvf, divcplx, divmi, divlm, divgf2n, divgfpn };
113: void (*pwrnumt[])() = { pwrq, pwrreal, pwralg, 0, pwritvp, pwritvd, 0, pwritvf, pwrcplx, pwrmi, pwrlm, pwrgf2n, pwrgfpn };
114: void (*chsgnnumt[])() = { chsgnq, chsgnreal, chsgnalg, 0, chsgnitvp, chsgnitvd, 0, chsgnitvf, chsgncplx, chsgnmi, chsgnlm, chsgngf2n, chsgngfpn };
115: int (*cmpnumt[])() = { cmpq, cmpreal, cmpalg, 0, cmpitvp, cmpitvd, 0, cmpitvf, cmpcplx, cmpmi, cmplm, cmpgf2n, cmpgfpn };
1.1 noro 116: #else
117: void (*addnumt[])() = { addq, addreal, addalg, 0, addcplx, addmi, addlm, addgf2n, addgfpn };
118: void (*subnumt[])() = { subq, subreal, subalg, 0, subcplx, submi, sublm, subgf2n, subgfpn };
119: void (*mulnumt[])() = { mulq, mulreal, mulalg, 0, mulcplx, mulmi, mullm, mulgf2n, mulgfpn };
120: void (*divnumt[])() = { divq, divreal, divalg, 0, divcplx, divmi, divlm, divgf2n,divgfpn };
121: void (*pwrnumt[])() = { pwrq, pwrreal, pwralg, 0, pwrcplx, pwrmi, pwrlm, pwrgf2n, pwrgfpn };
122: void (*chsgnnumt[])() = { chsgnq, chsgnreal, chsgnalg, 0, chsgncplx, chsgnmi, chsgnlm, chsgngf2n, chsgngfpn };
123: int (*cmpnumt[])() = { cmpq, cmpreal, cmpalg, 0, cmpcplx, cmpmi, cmplm, cmpgf2n, cmpgfpn };
1.7 saito 124: #endif
1.1 noro 125: #endif
126:
127: double get_current_time();
128:
129: void nglob_init() {
130: PL(&oUNIN) = 1; BD(&oUNIN)[0] = 1;
131: PL(&oTWON) = 1; BD(&oTWON)[0] = 2;
132: PL(&oTHREEN) = 1; BD(&oTHREEN)[0] = 3;
133: PL(&oFOURN) = 1; BD(&oFOURN)[0] = 4;
134: PL(&oFIVEN) = 1; BD(&oFIVEN)[0] = 5;
135: PL(&oSIXN) = 1; BD(&oSIXN)[0] = 6;
136: PL(&oSEVENN) = 1; BD(&oSEVENN)[0] = 7;
137: PL(&oEIGHTN) = 1; BD(&oEIGHTN)[0] = 8;
138:
139: oONEUP2.w = 1; oONEUP2.b[0] = 1;
140:
141: OID(&oUNIQ) = O_N; NID(&oUNIQ) = N_Q;
142: SGN(&oUNIQ) = 1; NM(&oUNIQ) = &oUNIN; DN(&oUNIQ) = 0;
143:
144: OID(&oTWOQ) = O_N; NID(&oTWOQ) = N_Q;
145: SGN(&oTWOQ) = 1; NM(&oTWOQ) = &oTWON; DN(&oTWOQ) = 0;
146:
147: OID(&oTHREEQ) = O_N; NID(&oTHREEQ) = N_Q;
148: SGN(&oTHREEQ) = 1; NM(&oTHREEQ) = &oTHREEN; DN(&oTHREEQ) = 0;
149:
150: OID(&oFOURQ) = O_N; NID(&oFOURQ) = N_Q;
151: SGN(&oFOURQ) = 1; NM(&oFOURQ) = &oFOURN; DN(&oFOURQ) = 0;
152:
153: OID(&oFIVEQ) = O_N; NID(&oFIVEQ) = N_Q;
154: SGN(&oFIVEQ) = 1; NM(&oFIVEQ) = &oFIVEN; DN(&oFIVEQ) = 0;
155:
156: OID(&oSIXQ) = O_N; NID(&oSIXQ) = N_Q;
157: SGN(&oSIXQ) = 1; NM(&oSIXQ) = &oSIXN; DN(&oSIXQ) = 0;
158:
159: OID(&oSEVENQ) = O_N; NID(&oSEVENQ) = N_Q;
160: SGN(&oSEVENQ) = 1; NM(&oSEVENQ) = &oSEVENN; DN(&oSEVENQ) = 0;
161:
162: OID(&oEIGHTQ) = O_N; NID(&oEIGHTQ) = N_Q;
163: SGN(&oEIGHTQ) = 1; NM(&oEIGHTQ) = &oEIGHTN; DN(&oEIGHTQ) = 0;
164:
165: OID(&oUNIR) = O_R; NM(&oUNIR) = (P)&oUNIQ; DN(&oUNIR) = (P)&oUNIQ; oUNIR.reduced = 1;
166: OID(&oUNIMQ) = O_N; NID(&oUNIMQ) = N_M; CONT(&oUNIMQ) = 1;
167: OID(&oUNILM) = O_N; NID(&oUNILM) = N_LM; BDY(&oUNILM) = ONEN;
168: OID(&oIU) = O_N; NID(&oIU) = N_C; oIU.r = 0; oIU.i = (Num)ONE;
169:
170: MKLM(&oTHREEN,THREE_LM);
171: MKLM(&oFOURN,FOUR_LM);
172: MKLM(&oEIGHTN,EIGHT_LM);
173:
174: OID(&oVOID) = O_VOID;
175:
176: /* moved to parse/main.c */
177: #if 0
178: #if PARI
179: risa_pari_init();
180: #endif
181: srandom((int)get_current_time());
182: #endif
183: init_up2_tab();
184: }
185:
186: extern double gctime;
187: double suspend_start;
188: double suspended_time=0;
189:
190: void get_eg(p)
191: struct oEGT *p;
192: {
193: p->exectime = get_clock() - gctime - suspended_time; p->gctime = gctime;
194: }
195:
196: void init_eg(eg)
197: struct oEGT *eg;
198: {
199: bzero((char *)eg,sizeof(struct oEGT));
200: }
201:
202: void add_eg(base,start,end)
203: struct oEGT *base,*start,*end;
204: {
205: base->exectime += end->exectime - start->exectime;
206: base->gctime += end->gctime - start->gctime;
207: }
208:
209: void print_eg(item,eg)
210: char *item;
211: struct oEGT *eg;
212: {
213: printf("%s=(%.4g,%.4g)",item,eg->exectime,eg->gctime);
214: }
215:
216: void print_split_eg(start,end)
217: struct oEGT *start,*end;
218: {
219: struct oEGT base;
220:
221: init_eg(&base); add_eg(&base,start,end);
222: printf("(%.4g,%.4g)",base.exectime,base.gctime);
223: }
224:
225: void print_split_e(start,end)
226: struct oEGT *start,*end;
227: {
228: struct oEGT base;
229:
230: init_eg(&base); add_eg(&base,start,end);
231: printf("(%.4g)",base.exectime);
232: }
233:
234: void suspend_timer() {
235: suspend_start = get_clock();
236: }
237:
238: void resume_timer() {
239: suspended_time += get_clock()-suspend_start;
240: }
241:
242: extern int lm_lazy, up_lazy;
1.6 noro 243: extern int GC_dont_gc;
244: extern int do_weyl;
1.8 ! noro 245: extern int dp_fcoeffs;
1.1 noro 246:
247: void reset_engine() {
1.8 ! noro 248: lm_lazy = 0;
! 249: up_lazy = 0;
1.6 noro 250: do_weyl = 0;
1.8 ! noro 251: dp_fcoeffs = 0;
1.1 noro 252: GC_dont_gc = 0;
253: }
254:
255: unsigned int get_asir_version() {
256: return ASIR_VERSION;
1.4 noro 257: }
258:
259: void create_error(ERR *err,unsigned int serial,char *msg)
260: {
261: int len;
262: USINT ui;
263: NODE n,n1;
264: LIST list;
265: char *msg1;
266: STRING errmsg;
267:
268: MKUSINT(ui,serial);
269: len = strlen(msg);
270: msg1 = (char *)MALLOC(len+1);
271: strcpy(msg1,msg);
272: MKSTR(errmsg,msg1);
273: MKNODE(n1,errmsg,0); MKNODE(n,ui,n1); MKLIST(list,n);
274: MKERR(*err,list);
1.1 noro 275: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>