version 1.9, 2013/12/19 06:04:09 |
version 1.13, 2017/09/04 01:57:53 |
|
|
* 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_contrib2/asir2000/plot/calc.c,v 1.8 2011/08/10 04:51:58 saito Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/plot/calc.c,v 1.12 2017/08/31 04:21:48 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
|
|
#endif |
#endif |
|
|
void calc(double **tab,struct canvas *can,int nox){ |
void calc(double **tab,struct canvas *can,int nox){ |
//memory_plot,MODE_IFPLOTD,MODE_INEQND,MODE_INEQNANDD,MODE_INEQNORD |
//memory_plot,IFPLOTD,INEQND,INEQNANDD,INEQNORD |
//MODE_INEQNXORD,conplotmainD |
//INEQNXORD,conplotmainD |
double x,y,xstep,ystep; |
double x,y,xstep,ystep; |
int ix,iy; |
int ix,iy; |
Real r,rx,ry; |
Real r,rx,ry; |
Obj fr,g,t,s; |
Obj fr,g,t,s; |
|
|
if(!nox)initmarker(can,"Evaluating..."); |
if(!nox)initmarker(can,"Evaluating..."); |
MKReal(1.0,r); mulr(CO,(Obj)can->formula,(Obj)r,&fr); |
todouble((Obj)can->formula,&fr); |
xstep=(can->xmax-can->xmin)/can->width; |
xstep=(can->xmax-can->xmin)/can->width; |
ystep=(can->ymax-can->ymin)/can->height; |
ystep=(can->ymax-can->ymin)/can->height; |
MKReal(1.0,rx); MKReal(1.0,ry); // dummy real |
MKReal(1.0,rx); MKReal(1.0,ry); // dummy real |
Line 93 void calc(double **tab,struct canvas *can,int nox){ |
|
Line 93 void calc(double **tab,struct canvas *can,int nox){ |
|
} |
} |
|
|
void calcq(double **tab,struct canvas *can,int nox){ |
void calcq(double **tab,struct canvas *can,int nox){ |
//MODE_IFPLOTQ,MODE_INEQNQ,MODE_INEQNANDQ,MODE_INEQNORQ,MODE_INEQNXORQ |
//IFPLOTQ,INEQNQ,INEQNANDQ,INEQNORQ,INEQNXORQ |
//plotoverD |
//plotoverD |
Q dx,dy,xstep,ystep,q1,w,h,c; |
Q dx,dy,xstep,ystep,q1,w,h,c; |
P g,g1,f1,f2,x,y; |
P g,g1,f1,f2,x,y; |
Line 101 void calcq(double **tab,struct canvas *can,int nox){ |
|
Line 101 void calcq(double **tab,struct canvas *can,int nox){ |
|
Obj fr,gm,t,s; |
Obj fr,gm,t,s; |
Real r,rx,ry; |
Real r,rx,ry; |
|
|
MKReal(1.0,r); mulr(CO,(Obj)can->formula,(Obj)r,&fr); |
todouble((Obj)can->formula,&fr); |
MKReal(1.0,rx); MKReal(1.0,ry); // dummy real |
MKReal(1.0,rx); MKReal(1.0,ry); // dummy real |
BDY(rx)=can->xmin; |
BDY(rx)=can->xmin; |
substr(CO,0,fr,can->vx,can->xmin?(Obj)rx:0,&t); devalr(CO,t,&gm); |
substr(CO,0,fr,can->vx,can->xmin?(Obj)rx:0,&t); devalr(CO,t,&gm); |
Line 131 void calcq(double **tab,struct canvas *can,int nox){ |
|
Line 131 void calcq(double **tab,struct canvas *can,int nox){ |
|
} |
} |
|
|
void calcb(double **tab,struct canvas *can,int nox){ |
void calcb(double **tab,struct canvas *can,int nox){ |
//MODE_IFPLOTB,MODE_INEQNB,MODE_INEQNANDB,MODE_INEQNORB,MODE_INEQNXORB |
//IFPLOTB,INEQNB,INEQNANDB,INEQNORB,INEQNXORB |
Q dx,dy,xstep,ystep,q1,w,h,c; |
Q dx,dy,xstep,ystep,q1,w,h,c; |
P g,g1,f1,f2,x,y,t,s; |
P g,g1,f1,f2,x,y,t,s; |
int ix,iy,*a,*pa; |
int ix,iy,*a,*pa; |
Line 139 void calcb(double **tab,struct canvas *can,int nox){ |
|
Line 139 void calcb(double **tab,struct canvas *can,int nox){ |
|
Obj fr,gm,tm,sm; |
Obj fr,gm,tm,sm; |
Real r,rx,ry; |
Real r,rx,ry; |
|
|
MKReal(1.0,r); mulr(CO,(Obj)can->formula,(Obj)r,&fr); |
todouble((Obj)can->formula,&fr); |
MKReal(1.0,rx); MKReal(1.0,ry); // dummy real |
MKReal(1.0,rx); MKReal(1.0,ry); // dummy real |
BDY(rx)=can->xmin; |
BDY(rx)=can->xmin; |
substr(CO,0,fr,can->vx,can->xmin?(Obj)rx:0,&tm); devalr(CO,tm,&gm); |
substr(CO,0,fr,can->vx,can->xmin?(Obj)rx:0,&tm); devalr(CO,tm,&gm); |
Line 373 void usubstqp(P p,Q r,Q *v){ |
|
Line 373 void usubstqp(P p,Q r,Q *v){ |
|
} |
} |
} |
} |
|
|
|
Num tobf(Num,int); |
|
|
|
void plotcalcbf(struct canvas *can){ |
|
Obj fr,s,t; |
|
Num xmin,xmax,ymin,ymax,xstep; |
|
Num u,v,ha,dx,dy,x; |
|
Num *tab; |
|
Real r; |
|
Q w,h1; |
|
int ix; |
|
POINT *pa; |
|
double rr; |
|
Q prec; |
|
NODE arg; |
|
|
|
STOQ(can->prec,prec); arg = mknode(1,prec); Psetprec(arg,&t); |
|
evalr(CO,(Obj)can->formula,can->prec,&fr); |
|
MKReal(can->xmin,r); xmin = 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->ymax,r); ymax = tobf((Num)r,can->prec); |
|
STOQ(can->width,w); |
|
subbf(xmax,xmin,&dx); divbf(dx,(Num)w,&xstep); |
|
tab=(Num *)MALLOC(can->width*sizeof(Num)); |
|
for(ix=0,x=xmin;ix<can->width;ix++){ |
|
substr(CO,0,fr,can->vx,(Obj)x,(Obj *)&s); |
|
evalr(CO,(Obj)s,can->prec,&t); |
|
if(t&&(OID(t)!=O_N)) |
|
error("plotcalcbf : invalid evaluation"); |
|
tab[ix]=(Num)t; |
|
addbf(x,xstep,&u); x = u; |
|
} |
|
if(!cmpbf(ymax,ymin)){ |
|
for(ymax=ymin=tab[0],ix=1;ix<can->width;ix++){ |
|
if(cmpbf(tab[ix],ymax)>0)ymax=tab[ix]; |
|
if(cmpbf(tab[ix],ymin)<0)ymin=tab[ix]; |
|
} |
|
can->ymax=ToReal(ymax);can->ymin=ToReal(ymin); |
|
} |
|
subbf(ymax,ymin,&dy); |
|
can->pa=(struct pa *)MALLOC(sizeof(struct pa)); |
|
can->pa[0].length=can->width; |
|
can->pa[0].pos=pa=(POINT *)MALLOC(can->width*sizeof(POINT)); |
|
STOQ(can->height-1,h1); |
|
for(ix=0;ix<can->width;ix++){ |
|
XC(pa[ix])=ix; |
|
subbf(ymax,tab[ix],&u); divbf(u,dy,&v); mulbf(v,(Num)h1,&u); |
|
rr = ToReal(u); |
|
if(rr>MAXSHORT)YC(pa[ix])=MAXSHORT; |
|
else if(rr<-MAXSHORT)YC(pa[ix])=-MAXSHORT; |
|
else YC(pa[ix])=(long)rr; |
|
} |
|
} |
|
|
void plotcalc(struct canvas *can){ |
void plotcalc(struct canvas *can){ |
//plot,memory_plot,plotover,plot_resize |
//plot,memory_plot,plotover,plot_resize |
double x,xmin,xstep,ymax,ymin,dy,*tab,usubstrp(); |
double x,xmin,xstep,ymax,ymin,dy,*tab,usubstrp(); |
Line 381 void plotcalc(struct canvas *can){ |
|
Line 435 void plotcalc(struct canvas *can){ |
|
Obj fr,t,s; |
Obj fr,t,s; |
POINT *pa; |
POINT *pa; |
|
|
MKReal(1.0,r); mulr(CO,(Obj)can->formula,(Obj)r,&fr); |
if ( can->prec ) { |
|
plotcalcbf(can); |
|
return; |
|
} |
|
todouble((Obj)can->formula,&fr); |
w=can->width;h=can->height; |
w=can->width;h=can->height; |
xmin=can->xmin;xstep=(can->xmax-can->xmin)/w; |
xmin=can->xmin;xstep=(can->xmax-can->xmin)/w; |
tab=(double *)ALLOCA(w*sizeof(double)); |
tab=(double *)ALLOCA(w*sizeof(double)); |
Line 418 void plotcalc(struct canvas *can){ |
|
Line 476 void plotcalc(struct canvas *can){ |
|
} |
} |
} |
} |
|
|
void polarplotcalc(struct canvas *can){ |
void polarcalc(struct canvas *can){ |
//polarplotNG |
double xmax,xmin,ymax,ymin,dx,dy,pmin,pstep,tr,p,*tabx,*taby; |
double xmax,xmin,ymax,ymin,dx,dy,pmin,pstep,tr,p, *tabx,*taby; |
|
double usubstrp(); |
double usubstrp(); |
int i,nstep,w,h; |
int i,nstep,w,h; |
POINT *pa; |
POINT *pa; |
Real r; |
Real r; |
Obj fr,t,s; |
Obj fr,t,s; |
|
|
MKReal(1.0,r); mulr(CO,(Obj)can->formula,(Obj)r,&fr); |
todouble((Obj)can->formula,&fr); |
w=can->width; h=can->height; nstep=can->nzstep; |
w=can->width; h=can->height; nstep=can->nzstep; |
pmin=can->zmin; pstep=(can->zmax-can->zmin)/nstep; |
pmin=can->zmin; pstep=(can->zmax-can->zmin)/nstep; |
tabx=(double *)ALLOCA(nstep*sizeof(double)); |
tabx=(double *)ALLOCA(nstep*sizeof(double)); |
taby=(double *)ALLOCA(nstep*sizeof(double)); |
taby=(double *)ALLOCA(nstep*sizeof(double)); |
MKReal(1,r); // dummy real number |
MKReal(1,r); // dummy real number |
|
|
for(i=0,p=pmin;i<nstep;i++,p+= pstep){ |
for(i=0,p=pmin;i<nstep;i++,p+= pstep){ |
// full substitution |
// full substitution |
BDY(r)=p; |
BDY(r)=p; |
substr(CO,0,fr,can->vx,p?(Obj)r:0,&s); |
substr(CO,0,fr,can->vx,p?(Obj)r:0,&s); |
devalr(CO,(Obj)s,&t); |
devalr(CO,(Obj)s,&t); |
if(t&&(OID(t)!=O_N||NID((Num)t)!=N_R)) |
if(t&&(OID(t)!=O_N||NID((Num)t)!=N_R)) |
error("polarplotcalc : invalid evaluation"); |
error("polarcalc : invalid evaluation"); |
tr=ToReal((Num)t); |
tr=ToReal((Num)t); |
tabx[i]=tr*cos(p); |
tabx[i]=tr*cos(p); |
taby[i]=tr*sin(p); |
taby[i]=tr*sin(p); |
Line 465 void polarplotcalc(struct canvas *can){ |
|
Line 523 void polarplotcalc(struct canvas *can){ |
|
} |
} |
} |
} |
|
|
|
void polarcalcNG(struct canvas *can){ |
|
//polarplotNG |
|
double xmax,xmin,ymax,ymin,dx,dy,pmin,pstep,tr,p, *tabx,*taby; |
|
double usubstrp(); |
|
int i,ix,iy,nstep,w,h; |
|
POINT *pa; |
|
Real r; |
|
Obj fr,t,s; |
|
|
|
todouble((Obj)can->formula,&fr); |
|
w=can->width; h=can->height; nstep=can->nzstep; |
|
pmin=can->zmin; pstep=(can->zmax-can->zmin)/nstep; |
|
tabx=(double *)ALLOCA(nstep*sizeof(double)); |
|
taby=(double *)ALLOCA(nstep*sizeof(double)); |
|
MKReal(1,r); // dummy real number |
|
|
|
for(i=0,p=pmin;i<nstep;i++,p+= pstep){ |
|
// full substitution |
|
BDY(r)=p; |
|
substr(CO,0,fr,can->vx,p?(Obj)r:0,&s); |
|
devalr(CO,(Obj)s,&t); |
|
if(t&&(OID(t)!=O_N||NID((Num)t)!=N_R)) |
|
error("polarcalc : invalid evaluation"); |
|
tr=ToReal((Num)t); |
|
tabx[i]=tr*cos(p); |
|
taby[i]=tr*sin(p); |
|
if(i==0){ |
|
xmax=xmin=tabx[0]; |
|
ymax=ymin=taby[0]; |
|
} else { |
|
if(tabx[i]>xmax)xmax=tabx[i]; |
|
if(tabx[i]<xmin)xmin=tabx[i]; |
|
if(taby[i]>ymax)ymax=taby[i]; |
|
if(taby[i]<ymin)ymin=taby[i]; |
|
} |
|
} |
|
can->xmax=xmax;can->xmin=xmin; |
|
can->ymax=ymax;can->ymin=ymin; |
|
dx=xmax-xmin; |
|
dy=ymax-ymin; |
|
can->pa=(struct pa *)MALLOC(sizeof(struct pa)); |
|
can->pa[0].length=nstep; |
|
can->pa[0].pos=pa=(POINT *)MALLOC(w*sizeof(POINT)); |
|
for(i=0;i<nstep;i++){ |
|
XC(pa[i])=(w-1)*(tabx[i]-xmin)/dx; |
|
YC(pa[i])=(h-1)*(ymax-taby[i])/dy; |
|
} |
|
} |
|
|
/* |
/* |
void ineqncalc(double **tab,struct canvas *can,int nox){ |
void ineqncalc(double **tab,struct canvas *can,int nox){ |
double x,y,xmin,ymin,xstep,ystep; |
double x,y,xmin,ymin,xstep,ystep; |
Line 474 void ineqncalc(double **tab,struct canvas *can,int nox |
|
Line 581 void ineqncalc(double **tab,struct canvas *can,int nox |
|
V vx,vy; |
V vx,vy; |
|
|
if(!nox) initmarker(can,"Evaluating..."); |
if(!nox) initmarker(can,"Evaluating..."); |
MKReal(1.0,r); mulr(CO,(Obj)can->formula,(Obj)r,&fr); |
todouble((Obj)can->formula,&fr); |
vx=can->vx;vy=can->vy; |
vx=can->vx;vy=can->vy; |
w=can->width;h=can->height; |
w=can->width;h=can->height; |
xmin=can->xmin;xstep=(can->xmax-can->xmin)/w; |
xmin=can->xmin;xstep=(can->xmax-can->xmin)/w; |
Line 497 void ineqncalc(double **tab,struct canvas *can,int nox |
|
Line 604 void ineqncalc(double **tab,struct canvas *can,int nox |
|
|
|
#if defined(INTERVAL) |
#if defined(INTERVAL) |
void itvcalc(double **mask, struct canvas *can, int nox){ |
void itvcalc(double **mask, struct canvas *can, int nox){ |
//MODE_ITVIFPLOT |
//ITVIFPLOT |
double x,y,xstep,ystep,dx,dy,wx,wy; |
double x,y,xstep,ystep,dx,dy,wx,wy; |
int idv,ix,iy,idx,idy; |
int idv,ix,iy,idx,idy; |
Itv ity,itx,ddx,ddy; |
Itv ity,itx,ddx,ddy; |
Line 506 void itvcalc(double **mask, struct canvas *can, int no |
|
Line 613 void itvcalc(double **mask, struct canvas *can, int no |
|
Obj fr,g,t,s; |
Obj fr,g,t,s; |
|
|
idv=can->division; |
idv=can->division; |
MKReal(1.0,r); mulr(CO,(Obj)can->formula,(Obj)r,&fr); |
todouble((Obj)can->formula,&fr); |
vx=can->vx; vy=can->vy; |
vx=can->vx; vy=can->vy; |
xstep=(can->xmax-can->xmin)/can->width; |
xstep=(can->xmax-can->xmin)/can->width; |
ystep=(can->ymax-can->ymin)/can->height; |
ystep=(can->ymax-can->ymin)/can->height; |