=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/builtin/dp.c,v retrieving revision 1.3 retrieving revision 1.5 diff -u -p -r1.3 -r1.5 --- OpenXM_contrib2/asir2000/builtin/dp.c 2000/05/29 08:54:45 1.3 +++ OpenXM_contrib2/asir2000/builtin/dp.c 2000/08/21 08:31:19 1.5 @@ -1,4 +1,52 @@ -/* $OpenXM: OpenXM_contrib2/asir2000/builtin/dp.c,v 1.2 2000/04/13 06:01:01 noro Exp $ */ +/* + * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED + * All rights reserved. + * + * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited, + * non-exclusive and royalty-free license to use, copy, modify and + * redistribute, solely for non-commercial and non-profit purposes, the + * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and + * conditions of this Agreement. For the avoidance of doubt, you acquire + * only a limited right to use the SOFTWARE hereunder, and FLL or any + * third party developer retains all rights, including but not limited to + * copyrights, in and to the SOFTWARE. + * + * (1) FLL does not grant you a license in any way for commercial + * purposes. You may use the SOFTWARE only for non-commercial and + * non-profit purposes only, such as academic, research and internal + * business use. + * (2) The SOFTWARE is protected by the Copyright Law of Japan and + * international copyright treaties. If you make copies of the SOFTWARE, + * with or without modification, as permitted hereunder, you shall affix + * to all such copies of the SOFTWARE the above copyright notice. + * (3) An explicit reference to this SOFTWARE and its copyright owner + * shall be made on your publication or presentation in any form of the + * results obtained by use of the SOFTWARE. + * (4) In the event that you modify the SOFTWARE, you shall notify FLL by + * e-mail at risa-admin@flab.fujitsu.co.jp of the detailed specification + * for such modification or the source code of the modified part of the + * SOFTWARE. + * + * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL + * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND + * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES' + * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY + * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY. + * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT, + * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL + * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES + * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES + * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY + * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF + * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART + * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY + * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, + * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. + * + * $OpenXM: OpenXM_contrib2/asir2000/builtin/dp.c,v 1.4 2000/07/14 08:26:39 noro Exp $ +*/ #include "ca.h" #include "base.h" #include "parse.h" @@ -511,7 +559,7 @@ DP *ps; int full; DP *rp; { - DP u,p,d,s,t; + DP u,p,d,s,t,dmy1; P dmy; NODE l; MP m,mr; @@ -530,7 +578,7 @@ DP *rp; for ( d = 0; g; ) { for ( u = 0, i = 0; i < n; i++ ) { if ( dp_redble(g,p = ps[wb[i]]) ) { - dp_red(d,g,p,&t,&u,&dmy); + dp_red(d,g,p,&t,&u,&dmy,&dmy1); psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; sugar = MAX(sugar,psugar); if ( !u ) { @@ -569,7 +617,7 @@ int full; DP *rp; P *dnp; { - DP u,p,d,s,t; + DP u,p,d,s,t,dmy; NODE l; MP m,mr; int i,n; @@ -589,7 +637,7 @@ P *dnp; for ( d = 0; g; ) { for ( u = 0, i = 0; i < n; i++ ) { if ( dp_redble(g,p = ps[wb[i]]) ) { - dp_red(d,g,p,&t,&u,&tdn); + dp_red(d,g,p,&t,&u,&tdn,&dmy); psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; sugar = MAX(sugar,psugar); if ( !u ) { @@ -654,7 +702,7 @@ DP *ps; int full,multiple; DP *rp; { - DP u,p,d,s,t; + DP u,p,d,s,t,dmy1; P dmy; NODE l; MP m,mr; @@ -675,7 +723,7 @@ DP *rp; for ( d = 0; g; ) { for ( u = 0, i = 0; i < n; i++ ) { if ( dp_redble(g,p = ps[wb[i]]) ) { - dp_red(d,g,p,&t,&u,&dmy); + dp_red(d,g,p,&t,&u,&dmy,&dmy1); psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; sugar = MAX(sugar,psugar); if ( !u ) { @@ -723,7 +771,7 @@ void Pdp_nf_demand(arg,rp) NODE arg; DP *rp; { - DP g,u,p,d,s,t; + DP g,u,p,d,s,t,dmy1; P dmy; NODE b,l; DP *hps; @@ -759,7 +807,7 @@ DP *rp; fprintf(stderr,"loading %s\n",fname); fp = fopen(fname,"r"); skipvl(fp); loadobj(fp,(Obj *)&p); fclose(fp); - dp_red(d,g,p,&t,&u,&dmy); + dp_red(d,g,p,&t,&u,&dmy,&dmy1); psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; sugar = MAX(sugar,psugar); if ( !u ) { @@ -1233,22 +1281,23 @@ NODE arg; LIST *rp; { NODE n; - DP head,rest; + DP head,rest,dmy1; P dmy; asir_assert(ARG0(arg),O_DP,"dp_red"); asir_assert(ARG1(arg),O_DP,"dp_red"); asir_assert(ARG2(arg),O_DP,"dp_red"); - dp_red((DP)ARG0(arg),(DP)ARG1(arg),(DP)ARG2(arg),&head,&rest,&dmy); + dp_red((DP)ARG0(arg),(DP)ARG1(arg),(DP)ARG2(arg),&head,&rest,&dmy,&dmy1); NEWNODE(n); BDY(n) = (pointer)head; NEWNODE(NEXT(n)); BDY(NEXT(n)) = (pointer)rest; NEXT(NEXT(n)) = 0; MKLIST(*rp,n); } -void dp_red(p0,p1,p2,head,rest,dnp) +void dp_red(p0,p1,p2,head,rest,dnp,multp) DP p0,p1,p2; DP *head,*rest; P *dnp; +DP *multp; { int i,n; DL d1,d2,d; @@ -1276,6 +1325,7 @@ P *dnp; divsp(CO,(P)c1,g,&a); c1 = (Q)a; divsp(CO,(P)c2,g,&a); c2 = (Q)a; } NEWMP(m); m->dl = d; chsgnp((P)c1,&m->c); NEXT(m) = 0; MKDP(n,m,s); s->sugar = d->td; + *multp = s; muld(CO,s,p2,&t); muldc(CO,p1,(P)c2,&s); addd(CO,s,t,&r); muldc(CO,p0,(P)c2,&h); *head = h; *rest = r; *dnp = (P)c2; @@ -1292,6 +1342,9 @@ DP *rp; dp_sp(p1,p2,rp); } +extern int GenTrace; +extern NODE TraceList; + void dp_sp(p1,p2,rp) DP p1,p2; DP *rp; @@ -1300,7 +1353,7 @@ DP *rp; int *w; DL d1,d2,d; MP m; - DP t,s,u; + DP t,s1,s2,u; Q c,c1,c2; N gn,tn; @@ -1323,15 +1376,28 @@ DP *rp; } NEWMP(m); m->dl = d; m->c = (P)c2; NEXT(m) = 0; - MKDP(n,m,s); s->sugar = d->td; muld(CO,s,p1,&t); + MKDP(n,m,s1); s1->sugar = d->td; muld(CO,s1,p1,&t); NEWDL(d,n); d->td = td - d2->td; for ( i = 0; i < n; i++ ) d->d[i] = w[i] - d2->d[i]; NEWMP(m); m->dl = d; m->c = (P)c1; NEXT(m) = 0; - MKDP(n,m,s); s->sugar = d->td; muld(CO,s,p2,&u); + MKDP(n,m,s2); s2->sugar = d->td; muld(CO,s2,p2,&u); subd(CO,t,u,rp); + if ( GenTrace ) { + LIST hist; + NODE node; + + node = mknode(4,ONE,0,s1,ONE); + MKLIST(hist,node); + MKNODE(TraceList,hist,0); + + node = mknode(4,ONE,0,0,ONE); + chsgnd(s2,(DP *)&ARG2(node)); + MKLIST(hist,node); + MKNODE(node,hist,TraceList); TraceList = node; + } } void Pdp_sp_mod(arg,rp)