[BACK]Return to calc.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2018 / plot

Diff for /OpenXM_contrib2/asir2018/plot/calc.c between version 1.1 and 1.2

version 1.1, 2018/09/19 05:45:08 version 1.2, 2018/09/28 08:20:29
Line 45 
Line 45 
  * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,   * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
  * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.   * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
  *   *
  * $OpenXM$   * $OpenXM: OpenXM_contrib2/asir2018/plot/calc.c,v 1.1 2018/09/19 05:45:08 noro Exp $
 */  */
 #include "ca.h"  #include "ca.h"
 #include "parse.h"  #include "parse.h"
Line 110  void calcq(double **tab,struct canvas *can,int nox){
Line 110  void calcq(double **tab,struct canvas *can,int nox){
   substr(CO,0,gm,can->vy,can->ymin?(Obj)ry:0,&t); devalr(CO,t,&s);    substr(CO,0,gm,can->vy,can->ymin?(Obj)ry:0,&t); devalr(CO,t,&s);
   can->vmax=can->vmin=ToReal(s);    can->vmax=can->vmin=ToReal(s);
   
   subq(can->qxmax,can->qxmin,&dx); STOQ(can->width,w); divq(dx,(Q)w,&xstep);    subq(can->qxmax,can->qxmin,&dx); STOZ(can->width,w); divq(dx,(Q)w,&xstep);
   subq(can->qymax,can->qymin,&dy); STOQ(can->height,h); divq(dy,(Q)h,&ystep);    subq(can->qymax,can->qymin,&dy); STOZ(can->height,h); divq(dy,(Q)h,&ystep);
   MKV(can->vx,x); mulp(CO,(P)xstep,x,(P *)&t);    MKV(can->vx,x); mulp(CO,(P)xstep,x,(P *)&t);
   addp(CO,(P)can->qxmin,(P)t,(P *)&s); substp(CO,can->formula,can->vx,(P)s,&f1);    addp(CO,(P)can->qxmin,(P)t,(P *)&s); substp(CO,can->formula,can->vx,(P)s,&f1);
   MKV(can->vy,y); mulp(CO,(P)ystep,y,(P *)&t);    MKV(can->vy,y); mulp(CO,(P)ystep,y,(P *)&t);
Line 120  void calcq(double **tab,struct canvas *can,int nox){
Line 120  void calcq(double **tab,struct canvas *can,int nox){
   if(!nox) initmarker(can,"Evaluating...");    if(!nox) initmarker(can,"Evaluating...");
   for(iy=0;iy<can->height;iy++){    for(iy=0;iy<can->height;iy++){
     marker(can,DIR_Y,iy);      marker(can,DIR_Y,iy);
     STOQ(iy,q1); substp(CO,g,can->vy,(P)q1,(P *)&t); ptozp((P)t,1,&c,&g1);      STOZ(iy,q1); substp(CO,g,can->vy,(P)q1,(P *)&t); ptozp((P)t,1,&c,&g1);
     for(ix=0;ix<can->width;ix++){      for(ix=0;ix<can->width;ix++){
       STOQ(ix,q1);substp(CO,g1,can->vx,(P)q1,(P *)&t);        STOZ(ix,q1);substp(CO,g1,can->vx,(P)q1,(P *)&t);
       devalr(CO,t,&s);        devalr(CO,t,&s);
       tab[ix][iy]=ToReal(s);        tab[ix][iy]=ToReal(s);
       if(can->vmax<tab[ix][iy])can->vmax=tab[ix][iy];        if(can->vmax<tab[ix][iy])can->vmax=tab[ix][iy];
Line 150  void calcb(double **tab,struct canvas *can,int nox){
Line 150  void calcb(double **tab,struct canvas *can,int nox){
   can->vmax=can->vmin=ToReal(sm);    can->vmax=can->vmin=ToReal(sm);
   
   for(iy=0;iy<can->height;iy++)for(ix=0;ix<can->width;ix++)tab[ix][iy]=1.0;    for(iy=0;iy<can->height;iy++)for(ix=0;ix<can->width;ix++)tab[ix][iy]=1.0;
   subq(can->qxmax,can->qxmin,&dx); STOQ(can->width,w); divq(dx,(Q)w,&xstep);    subq(can->qxmax,can->qxmin,&dx); STOZ(can->width,w); divq(dx,(Q)w,&xstep);
   subq(can->qymax,can->qymin,&dy); STOQ(can->height,h); divq(dy,(Q)h,&ystep);    subq(can->qymax,can->qymin,&dy); STOZ(can->height,h); divq(dy,(Q)h,&ystep);
   MKV(can->vx,x); mulp(CO,(P)xstep,x,&t);    MKV(can->vx,x); mulp(CO,(P)xstep,x,&t);
   addp(CO,(P)can->qxmin,t,&s); substp(CO,can->formula,can->vx,s,&f1);    addp(CO,(P)can->qxmin,t,&s); substp(CO,can->formula,can->vx,s,&f1);
   MKV(can->vy,y); mulp(CO,(P)ystep,y,&t);    MKV(can->vy,y); mulp(CO,(P)ystep,y,&t);
Line 159  void calcb(double **tab,struct canvas *can,int nox){
Line 159  void calcb(double **tab,struct canvas *can,int nox){
   ptozp(f2,1,&c,&g);    ptozp(f2,1,&c,&g);
   a=(int *)ALLOCA((MAX(can->width,can->height)+1)*sizeof(int));    a=(int *)ALLOCA((MAX(can->width,can->height)+1)*sizeof(int));
   for(iy=0;iy<can->height;iy++)for(ix=0;ix<can->width;ix++)tab[ix][iy]=1.0;    for(iy=0;iy<can->height;iy++)for(ix=0;ix<can->width;ix++)tab[ix][iy]=1.0;
   subq(can->qxmax,can->qxmin,&dx); STOQ(can->width,w); divq(dx,(Q)w,&xstep);    subq(can->qxmax,can->qxmin,&dx); STOZ(can->width,w); divq(dx,(Q)w,&xstep);
   subq(can->qymax,can->qymin,&dy); STOQ(can->height,h); divq(dy,(Q)h,&ystep);    subq(can->qymax,can->qymin,&dy); STOZ(can->height,h); divq(dy,(Q)h,&ystep);
   MKV(can->vx,x); mulp(CO,(P)xstep,x,&t);    MKV(can->vx,x); mulp(CO,(P)xstep,x,&t);
   addp(CO,(P)can->qxmin,t,&s); substp(CO,can->formula,can->vx,s,&f1);    addp(CO,(P)can->qxmin,t,&s); substp(CO,can->formula,can->vx,s,&f1);
   MKV(can->vy,y); mulp(CO,(P)ystep,y,&t);    MKV(can->vy,y); mulp(CO,(P)ystep,y,&t);
Line 168  void calcb(double **tab,struct canvas *can,int nox){
Line 168  void calcb(double **tab,struct canvas *can,int nox){
   ptozp(f2,1,&c,&g);    ptozp(f2,1,&c,&g);
   a=(int *)ALLOCA((MAX(can->width,can->height)+1)*sizeof(int));    a=(int *)ALLOCA((MAX(can->width,can->height)+1)*sizeof(int));
   for(ix=0;ix<can->width;ix++){    for(ix=0;ix<can->width;ix++){
     STOQ(ix,q1); substp(CO,g,can->vx,(P)q1,&t); ptozp(t,1,&c,&g1);      STOZ(ix,q1); substp(CO,g,can->vx,(P)q1,&t); ptozp(t,1,&c,&g1);
     if(!g1)for(iy=0;iy<can->height;iy++)tab[ix][iy]=0.0;      if(!g1)for(iy=0;iy<can->height;iy++)tab[ix][iy]=0.0;
     else if(!NUM(g1)){      else if(!NUM(g1)){
       sturmseq(CO,g1,&ss);        sturmseq(CO,g1,&ss);
Line 176  void calcb(double **tab,struct canvas *can,int nox){
Line 176  void calcb(double **tab,struct canvas *can,int nox){
       for(iy=0,pa=a;iy<can->height;iy++,pa++){        for(iy=0,pa=a;iy<can->height;iy++,pa++){
         if(*pa<0||(*(pa+1)>=0&&(*pa>*(pa+1))))tab[ix][iy]=0.0;          if(*pa<0||(*(pa+1)>=0&&(*pa>*(pa+1))))tab[ix][iy]=0.0;
         else {          else {
           STOQ(iy,q1);substp(CO,g1,can->vy,(P)q1,&t);            STOZ(iy,q1);substp(CO,g1,can->vy,(P)q1,&t);
           devalr(CO,(Obj)t,(Obj *)&s);            devalr(CO,(Obj)t,(Obj *)&s);
           tab[ix][iy]=ToReal(s);            tab[ix][iy]=ToReal(s);
           if(can->vmax<tab[ix][iy])can->vmax=tab[ix][iy];            if(can->vmax<tab[ix][iy])can->vmax=tab[ix][iy];
Line 186  void calcb(double **tab,struct canvas *can,int nox){
Line 186  void calcb(double **tab,struct canvas *can,int nox){
     }      }
   }    }
   for(iy=0;iy<can->height;iy++){    for(iy=0;iy<can->height;iy++){
     STOQ(iy,q1); substp(CO,g,can->vy,(P)q1,&t); ptozp(t,1,&c,&g1);      STOZ(iy,q1); substp(CO,g,can->vy,(P)q1,&t); ptozp(t,1,&c,&g1);
     if(!g1) for(ix=0;ix<can->width;ix++)tab[ix][iy]=0.0;      if(!g1) for(ix=0;ix<can->width;ix++)tab[ix][iy]=0.0;
     else if(!NUM(g1)){      else if(!NUM(g1)){
       sturmseq(CO,g1,&ss);        sturmseq(CO,g1,&ss);
Line 195  void calcb(double **tab,struct canvas *can,int nox){
Line 195  void calcb(double **tab,struct canvas *can,int nox){
         if(tab[ix][iy]!=0.0){          if(tab[ix][iy]!=0.0){
           if(*pa<0||(*(pa+1)>=0&&(*pa>*(pa+1))))tab[ix][iy]=0.0;            if(*pa<0||(*(pa+1)>=0&&(*pa>*(pa+1))))tab[ix][iy]=0.0;
           else {            else {
             STOQ(ix,q1);substp(CO,g1,can->vx,(P)q1,&t);              STOZ(ix,q1);substp(CO,g1,can->vx,(P)q1,&t);
             devalr(CO,(Obj)t,(Obj *)&s);              devalr(CO,(Obj)t,(Obj *)&s);
             tab[ix][iy]=ToReal(s);              tab[ix][iy]=ToReal(s);
             if(can->vmax<tab[ix][iy])can->vmax=tab[ix][iy];              if(can->vmax<tab[ix][iy])can->vmax=tab[ix][iy];
Line 216  double usubstrp(P p,double r){
Line 216  double usubstrp(P p,double r){
   else if(NUM(p))t=BDY((Real)p);    else if(NUM(p))t=BDY((Real)p);
   else {    else {
     dc=DC(p); t=BDY((Real)COEF(dc));      dc=DC(p); t=BDY((Real)COEF(dc));
     for(d=QTOS(DEG(dc)),dc=NEXT(dc);dc;d=QTOS(DEG(dc)),dc=NEXT(dc)){      for(d=ZTOS(DEG(dc)),dc=NEXT(dc);dc;d=ZTOS(DEG(dc)),dc=NEXT(dc)){
       t=t*pwrreal0(r,(d-QTOS(DEG(dc))))+BDY((Real)COEF(dc));        t=t*pwrreal0(r,(d-ZTOS(DEG(dc))))+BDY((Real)COEF(dc));
     }      }
     if(d)t*=pwrreal0(r,d);      if(d)t*=pwrreal0(r,d);
   }    }
Line 233  void qcalc(char **tab,struct canvas *can){
Line 233  void qcalc(char **tab,struct canvas *can){
   int *a,*pa;    int *a,*pa;
   VECT ss;    VECT ss;
   
   subq(can->qxmax,can->qxmin,&dx); STOQ(can->width,w); divq(dx,(Q)w,&xstep);    subq(can->qxmax,can->qxmin,&dx); STOZ(can->width,w); divq(dx,(Q)w,&xstep);
   subq(can->qymax,can->qymin,&dy); STOQ(can->height,h); divq(dy,(Q)h,&ystep);    subq(can->qymax,can->qymin,&dy); STOZ(can->height,h); divq(dy,(Q)h,&ystep);
   MKV(can->vx,x); mulp(CO,(P)xstep,x,&t);    MKV(can->vx,x); mulp(CO,(P)xstep,x,&t);
   addp(CO,(P)can->qxmin,t,&s); substp(CO,can->formula,can->vx,s,&f1);    addp(CO,(P)can->qxmin,t,&s); substp(CO,can->formula,can->vx,s,&f1);
   MKV(can->vy,y); mulp(CO,(P)ystep,y,&t);    MKV(can->vy,y); mulp(CO,(P)ystep,y,&t);
Line 244  void qcalc(char **tab,struct canvas *can){
Line 244  void qcalc(char **tab,struct canvas *can){
   initmarker(can,"Horizontal scan...");    initmarker(can,"Horizontal scan...");
   for( ix=0; ix < can->width; ix++ ){    for( ix=0; ix < can->width; ix++ ){
     marker(can,DIR_X,ix);      marker(can,DIR_X,ix);
     STOQ(ix,q1); substp(CO,g,can->vx,(P)q1,&t); ptozp(t,1,&c,&g1);      STOZ(ix,q1); substp(CO,g,can->vx,(P)q1,&t); ptozp(t,1,&c,&g1);
     if( !g1 )      if( !g1 )
       for(iy=0; iy < can->height; iy++ )        for(iy=0; iy < can->height; iy++ )
         tab[ix][iy]=1;          tab[ix][iy]=1;
Line 258  void qcalc(char **tab,struct canvas *can){
Line 258  void qcalc(char **tab,struct canvas *can){
   initmarker(can,"Vertical scan...");    initmarker(can,"Vertical scan...");
   for( iy=0; iy < can->height; iy++ ){    for( iy=0; iy < can->height; iy++ ){
     marker(can,DIR_Y,iy);      marker(can,DIR_Y,iy);
     STOQ(iy,q1); substp(CO,g,can->vy,(P)q1,&t); ptozp(t,1,&c,&g1);      STOZ(iy,q1); substp(CO,g,can->vy,(P)q1,&t); ptozp(t,1,&c,&g1);
     if( !g1 )      if( !g1 )
       for(ix=0; ix < can->width; ix++ )        for(ix=0; ix < can->width; ix++ )
         tab[ix][iy]=1;          tab[ix][iy]=1;
Line 317  void seproot(VECT s,int min,int max,int *ar){
Line 317  void seproot(VECT s,int min,int max,int *ar){
   
   ss=(P *)s->body;f=ss[0];    ss=(P *)s->body;f=ss[0];
   for(i=min;i<=max;i++){    for(i=min;i<=max;i++){
     STOQ(i,q);usubstqp(f,(Q)q,&t);      STOZ(i,q);usubstqp(f,(Q)q,&t);
     if(!t)ar[i]=-1;      if(!t)ar[i]=-1;
     else {      else {
       ar[i]=numch(s,(Q)q,t);break;        ar[i]=numch(s,(Q)q,t);break;
Line 325  void seproot(VECT s,int min,int max,int *ar){
Line 325  void seproot(VECT s,int min,int max,int *ar){
   }    }
   if(i>max) return;    if(i>max) return;
   for(j=max;j>= min;j--){    for(j=max;j>= min;j--){
     STOQ(j,q); usubstqp(f,(Q)q,&t);      STOZ(j,q); usubstqp(f,(Q)q,&t);
     if(!t)ar[j]=-1;      if(!t)ar[j]=-1;
     else {      else {
       if(i!=j)ar[j]=numch(s,(Q)q,t);        if(i!=j)ar[j]=numch(s,(Q)q,t);
Line 394  void plotcalcbf(struct canvas *can){
Line 394  void plotcalcbf(struct canvas *can){
   Z prec,w,h1;    Z prec,w,h1;
   NODE arg;    NODE arg;
   
   STOQ(can->prec,prec); arg = mknode(1,prec); Psetprec(arg,&t);    STOZ(can->prec,prec); arg = mknode(1,prec); Psetprec(arg,&t);
   evalr(CO,(Obj)can->formula,can->prec,&fr);    evalr(CO,(Obj)can->formula,can->prec,&fr);
   MKReal(can->xmin,r); xmin = tobf((Num)r,can->prec);    MKReal(can->xmin,r); xmin = tobf((Num)r,can->prec);
   MKReal(can->xmax,r); xmax = tobf((Num)r,can->prec);    MKReal(can->xmax,r); xmax = tobf((Num)r,can->prec);
   MKReal(can->ymin,r); ymin = tobf((Num)r,can->prec);    MKReal(can->ymin,r); ymin = tobf((Num)r,can->prec);
   MKReal(can->ymax,r); ymax = tobf((Num)r,can->prec);    MKReal(can->ymax,r); ymax = tobf((Num)r,can->prec);
   STOQ(can->width,w);    STOZ(can->width,w);
   subbf(xmax,xmin,&dx); divbf(dx,(Num)w,&xstep);    subbf(xmax,xmin,&dx); divbf(dx,(Num)w,&xstep);
   tab=(Num *)MALLOC(can->width*sizeof(Num));    tab=(Num *)MALLOC(can->width*sizeof(Num));
   for(ix=0,x=xmin;ix<can->width;ix++){    for(ix=0,x=xmin;ix<can->width;ix++){
Line 422  void plotcalcbf(struct canvas *can){
Line 422  void plotcalcbf(struct canvas *can){
   can->pa=(struct pa *)MALLOC(sizeof(struct pa));    can->pa=(struct pa *)MALLOC(sizeof(struct pa));
   can->pa[0].length=can->width;    can->pa[0].length=can->width;
   can->pa[0].pos=pa=(POINT *)MALLOC(can->width*sizeof(POINT));    can->pa[0].pos=pa=(POINT *)MALLOC(can->width*sizeof(POINT));
   STOQ(can->height-1,h1);    STOZ(can->height-1,h1);
   for(ix=0;ix<can->width;ix++){    for(ix=0;ix<can->width;ix++){
     XC(pa[ix])=ix;      XC(pa[ix])=ix;
     subbf(ymax,tab[ix],&u); divbf(u,dy,&v); mulbf(v,(Num)h1,&u);      subbf(ymax,tab[ix],&u); divbf(u,dy,&v); mulbf(v,(Num)h1,&u);

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>