version 1.29, 2014/06/27 07:58:29 |
version 1.33, 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/plotf.c,v 1.28 2014/05/16 08:49:53 ohara Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/plot/plotf.c,v 1.32 2017/09/01 01:48:40 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
Line 207 void ifplot_main(NODE arg,int is_memory,char *fn,Obj * |
|
Line 207 void ifplot_main(NODE arg,int is_memory,char *fn,Obj * |
|
VL vl,vl0; |
VL vl,vl0; |
V v[2],av[2]; |
V v[2],av[2]; |
int stream,ri,i,sign; |
int stream,ri,i,sign; |
P poly,var; |
Obj poly; |
|
P var; |
NODE n,n0; |
NODE n,n0; |
STRING fname,wname; |
STRING fname,wname; |
Obj t; |
Obj t; |
|
int found_f; |
|
|
STOQ(-2,m2);STOQ(2,p2);MKNODE(n,p2,0);MKNODE(defrange,m2,n); |
STOQ(-2,m2);STOQ(2,p2);MKNODE(n,p2,0);MKNODE(defrange,m2,n); |
poly=0;vl=0;geom=0;wname=0;stream=-1;ri=0;xrange=0;yrange=0;zrange=0; |
poly=0;vl=0;geom=0;wname=0;stream=-1;ri=0;xrange=0;yrange=0;zrange=0; |
v[0]=v[1]=0; |
v[0]=v[1]=0; |
|
found_f = 0; |
for(;arg;arg=NEXT(arg)) |
for(;arg;arg=NEXT(arg)) |
if(!BDY(arg))stream=0; |
if(!BDY(arg)){ |
else |
if ( !found_f ) { |
|
poly = 0; |
|
found_f = 1; |
|
} else stream=0; |
|
} else |
switch(OID(BDY(arg))){ |
switch(OID(BDY(arg))){ |
case O_P: |
case O_P: |
poly=(P)BDY(arg); |
poly=(Obj)BDY(arg); |
get_vars_recursive((Obj)poly,&vl); |
get_vars_recursive((Obj)poly,&vl); |
for(vl0=vl,i=0;vl0;vl0=NEXT(vl0)){ |
for(vl0=vl,i=0;vl0;vl0=NEXT(vl0)){ |
if(vl0->v->attr==(pointer)V_IND){ |
if(vl0->v->attr==(pointer)V_IND){ |
Line 228 void ifplot_main(NODE arg,int is_memory,char *fn,Obj * |
|
Line 235 void ifplot_main(NODE arg,int is_memory,char *fn,Obj * |
|
else v[i++]=vl0->v; |
else v[i++]=vl0->v; |
} |
} |
} |
} |
|
found_f = 1; |
break; |
break; |
case O_LIST: |
case O_LIST: |
list=(LIST)BDY(arg); |
list=(LIST)BDY(arg); |
Line 237 void ifplot_main(NODE arg,int is_memory,char *fn,Obj * |
|
Line 245 void ifplot_main(NODE arg,int is_memory,char *fn,Obj * |
|
else geom=list; |
else geom=list; |
break; |
break; |
case O_N: |
case O_N: |
stream=QTOS((Q)BDY(arg));break; |
if ( !found_f ) { |
|
poly = (Obj)BDY(arg); |
|
found_f = 1; |
|
} else stream=QTOS((Q)BDY(arg)); |
|
break; |
case O_STR: |
case O_STR: |
wname=(STRING)BDY(arg);break; |
wname=(STRING)BDY(arg);break; |
default: |
default: |
error("ifplot : invalid argument");break; |
error("ifplot : invalid argument");break; |
} |
} |
if(!poly) error("ifplot : invalid argument"); |
if(!found_f) error("ifplot : invalid argument"); |
switch(ri){ |
switch(ri){ |
case 0: |
case 0: |
if(!v[1]) error("ifplot : please specify all variables"); |
if(!v[1]) error("ifplot : please specify all variables"); |
Line 253 void ifplot_main(NODE arg,int is_memory,char *fn,Obj * |
|
Line 265 void ifplot_main(NODE arg,int is_memory,char *fn,Obj * |
|
case 1: |
case 1: |
if(!v[1]) error("ifplot : please specify all variables"); |
if(!v[1]) error("ifplot : please specify all variables"); |
av[0]=VR((P)BDY(BDY(range[0]))); |
av[0]=VR((P)BDY(BDY(range[0]))); |
if(v[0]==av[0]){ |
if(!poly || NUM(poly) || v[0]==av[0]){ |
xrange=range[0]; |
xrange=range[0]; |
MKV(v[1],var);MKNODE(n,var,defrange);MKLIST(yrange,n); |
MKV(v[1],var);MKNODE(n,var,defrange);MKLIST(yrange,n); |
} else if(v[1]==av[0]){ |
} else if(v[1]==av[0]){ |
Line 264 void ifplot_main(NODE arg,int is_memory,char *fn,Obj * |
|
Line 276 void ifplot_main(NODE arg,int is_memory,char *fn,Obj * |
|
case 2: |
case 2: |
av[0]=VR((P)BDY(BDY(range[0]))); |
av[0]=VR((P)BDY(BDY(range[0]))); |
av[1]=VR((P)BDY(BDY(range[1]))); |
av[1]=VR((P)BDY(BDY(range[1]))); |
if(((v[0]==av[0])&&(!v[1]||v[1]==av[1]))|| |
if(!poly || NUM(poly) || (((v[0]==av[0])&&(!v[1]||v[1]==av[1]))|| |
((v[0]==av[1])&&(!v[1]||v[1]==av[0]))){ |
((v[0]==av[1])&&(!v[1]||v[1]==av[0])))){ |
xrange=range[0];yrange=range[1]; |
xrange=range[0];yrange=range[1]; |
} else error("ifplot : invalid argument"); |
} else error("ifplot : invalid argument"); |
break; |
break; |
Line 430 void conplot_main(NODE arg,int is_memory,Obj *rp){ |
|
Line 442 void conplot_main(NODE arg,int is_memory,Obj *rp){ |
|
void Pplot(NODE arg,Obj *rp){plot_main(arg,0,PLOT,rp);} |
void Pplot(NODE arg,Obj *rp){plot_main(arg,0,PLOT,rp);} |
void Pmemory_plot(NODE arg,Obj *rp){plot_main(arg,1,PLOT,rp);} |
void Pmemory_plot(NODE arg,Obj *rp){plot_main(arg,1,PLOT,rp);} |
|
|
|
int plot_by_bigfloat; |
|
|
void plot_main(NODE arg,int is_memory,char *fn,Obj *rp){ |
void plot_main(NODE arg,int is_memory,char *fn,Obj *rp){ |
Q m2,p2,w300,s_id; |
Q m2,p2,w300,s_id; |
NODE defrange; |
NODE defrange; |
LIST xrange,range[1],list,geom; |
LIST xrange,range[1],list,geom; |
VL vl,vl0; |
VL vl,vl0; |
V v[1],av[1]; |
V v[1],av[1]; |
int stream,ri,i; |
int stream,ri,i,found_f; |
P poly; |
Obj func; |
P var; |
P var; |
NODE n,n0; |
NODE n,n0; |
STRING fname,wname; |
STRING fname,wname; |
Obj t; |
Obj t; |
|
Q prec; |
|
|
STOQ(-2,m2);STOQ(2,p2); |
STOQ(-2,m2);STOQ(2,p2); |
MKNODE(n,p2,0);MKNODE(defrange,m2,n); |
MKNODE(n,p2,0);MKNODE(defrange,m2,n); |
poly=0;vl=0;geom=0;wname=0;stream=-1;ri=0; |
func=0;vl=0;geom=0;wname=0;stream=-1;ri=0; |
v[0]=0; |
v[0]=0; |
for(;arg;arg=NEXT(arg) ) |
found_f = 0; |
|
for(;arg;arg=NEXT(arg) ) { |
if(!BDY(arg) ) |
if(!BDY(arg) ) |
stream=0; |
if ( !found_f ) { |
|
makevar("x",&var); |
|
v[0] = VR(var); |
|
found_f = 1; |
|
} else |
|
stream=0; |
else |
else |
switch ( OID(BDY(arg)) ){ |
switch ( OID(BDY(arg)) ){ |
case O_P: case O_R: |
case O_P: case O_R: |
poly=(P)BDY(arg); |
func = (Obj)BDY(arg); |
get_vars_recursive((Obj)poly,&vl); |
get_vars_recursive(func,&vl); |
for(vl0=vl, i=0;vl0;vl0=NEXT(vl0) ){ |
for(vl0=vl, i=0;vl0;vl0=NEXT(vl0) ){ |
if(vl0->v->attr==(pointer)V_IND ){ |
if(vl0->v->attr==(pointer)V_IND ){ |
if(i >= 1 ) error("ifplot : invalid argument"); |
if(i >= 1 ) error("plot : function must be univariate"); |
else v[i++]=vl0->v; |
else v[i++]=vl0->v; |
} |
} |
} |
} |
if(i != 1 ) error("ifplot : invalid argument"); |
found_f = 1; |
break; |
break; |
case O_LIST: |
case O_LIST: |
list=(LIST)BDY(arg); |
list=(LIST)BDY(arg); |
if(OID(BDY(BDY(list)))==O_P ){ |
if(OID(BDY(BDY(list)))==O_P ){ |
if(ri > 0 ) error("plot : invalid argument"); |
if(ri > 0 ) error("plot : too many intervals"); |
else range[ri++]=list; |
else range[ri++]=list; |
} else geom=list; |
} else geom=list; |
break; |
break; |
case O_N: |
case O_N: |
stream=QTOS((Q)BDY(arg));break; |
if ( !found_f ) { |
|
func = (Obj)BDY(arg); |
|
makevar("x",&var); |
|
v[0] = VR(var); |
|
found_f = 1; |
|
} else |
|
stream=QTOS((Q)BDY(arg)); |
|
break; |
case O_STR: |
case O_STR: |
wname=(STRING)BDY(arg);break; |
wname=(STRING)BDY(arg);break; |
default: |
default: |
error("plot : invalid argument");break; |
error("plot : invalid argument");break; |
} |
} |
if(!poly ) |
} |
|
if(!found_f ) |
error("plot : invalid argument"); |
error("plot : invalid argument"); |
switch ( ri ){ |
switch ( ri ){ |
case 0: |
case 0: |
Line 485 void plot_main(NODE arg,int is_memory,char *fn,Obj *rp |
|
Line 514 void plot_main(NODE arg,int is_memory,char *fn,Obj *rp |
|
break; |
break; |
case 1: |
case 1: |
av[0]=VR((P)BDY(BDY(range[0]))); |
av[0]=VR((P)BDY(BDY(range[0]))); |
if(v[0]==av[0] ) |
if(!func || NUM(func) || v[0]==av[0] ) |
xrange=range[0]; |
xrange=range[0]; |
else |
else |
error("plot : invalid argument"); |
error("plot : invalid argument"); |
Line 508 void plot_main(NODE arg,int is_memory,char *fn,Obj *rp |
|
Line 537 void plot_main(NODE arg,int is_memory,char *fn,Obj *rp |
|
STOQ(300,w300); |
STOQ(300,w300); |
MKNODE(n0,w300,0);MKNODE(n,w300,n0);MKLIST(geom,n); |
MKNODE(n0,w300,0);MKNODE(n,w300,n0);MKLIST(geom,n); |
} |
} |
|
if(plot_by_bigfloat) |
|
STOQ(plot_by_bigfloat,prec); |
|
else |
|
prec = 0; |
if(is_memory ){ |
if(is_memory ){ |
MKSTR(fname,MEMORY_PLOT); |
MKSTR(fname,MEMORY_PLOT); |
arg=mknode(7,s_id,fname,poly,xrange,NULLP,NULLP,geom); |
arg=mknode(8,s_id,fname,func,xrange,NULLP,NULLP,geom,prec); |
Pox_rpc(arg,&t); |
Pox_rpc(arg,&t); |
arg=mknode(1,s_id); |
arg=mknode(1,s_id); |
Pox_pop_cmo(arg,rp); |
Pox_pop_cmo(arg,rp); |
} else { |
} else { |
MKSTR(fname,fn); |
MKSTR(fname,fn); |
arg=mknode(8,s_id,fname,poly,xrange,NULLP,NULLP,geom,wname); |
arg=mknode(9,s_id,fname,func,xrange,NULLP,NULLP,geom,wname,prec); |
Pox_rpc(arg,&t); |
Pox_rpc(arg,&t); |
*rp=(Obj)s_id; |
*rp=(Obj)s_id; |
} |
} |
Line 541 void Ppolarplot(NODE arg,Obj *rp){ |
|
Line 574 void Ppolarplot(NODE arg,Obj *rp){ |
|
for(;arg;arg=NEXT(arg)){ |
for(;arg;arg=NEXT(arg)){ |
if(!BDY(arg)) stream=0; |
if(!BDY(arg)) stream=0; |
else switch(OID(BDY(arg))){ |
else switch(OID(BDY(arg))){ |
case O_P: case O_R://formular |
case O_P: case O_R://formula |
poly=(P)BDY(arg); |
poly=(P)BDY(arg); |
get_vars_recursive((Obj)poly,&vl); |
get_vars_recursive((Obj)poly,&vl); |
for(vl0=vl,i=0;vl0;vl0=NEXT(vl0)) |
for(vl0=vl,i=0;vl0;vl0=NEXT(vl0)) |
Line 820 void PpolarplotD(NODE arg,Obj *rp){ |
|
Line 853 void PpolarplotD(NODE arg,Obj *rp){ |
|
} |
} |
//formular check |
//formular check |
if(!poly){ |
if(!poly){ |
sprintf(ebuf,"%s : invalid ploy argument",POLARPLOT); |
sprintf(ebuf,"%s : invalid plot argument",POLARPLOT); |
error(ebuf); |
error(ebuf); |
} |
} |
//vars check |
//vars check |
Line 828 void PpolarplotD(NODE arg,Obj *rp){ |
|
Line 861 void PpolarplotD(NODE arg,Obj *rp){ |
|
for(vl0=vl,vNo=0;vl0;vNo++,vl0=NEXT(vl0)){ |
for(vl0=vl,vNo=0;vl0;vNo++,vl0=NEXT(vl0)){ |
if(vl0->v->attr==(pointer)V_IND){ |
if(vl0->v->attr==(pointer)V_IND){ |
if(vNo>=2){ |
if(vNo>=2){ |
sprintf(ebuf,"%s : invalid ploy argument",POLARPLOT); |
sprintf(ebuf,"%s : invalid plot argument",POLARPLOT); |
error(ebuf); |
error(ebuf); |
} else v[vNo]=vl0->v; |
} else v[vNo]=vl0->v; |
} |
} |
Line 900 void ifplot_mainNG(NODE arg,char *fn,Obj *rp){ |
|
Line 933 void ifplot_mainNG(NODE arg,char *fn,Obj *rp){ |
|
poly=(P)BDY(arg); |
poly=(P)BDY(arg); |
pfine=FALSE; |
pfine=FALSE; |
} else { |
} else { |
sprintf(ebuf,"%s : to many ploy arguments",fn); |
sprintf(ebuf,"%s : to many plot arguments",fn); |
error(ebuf); |
error(ebuf); |
} |
} |
break; |
break; |
Line 937 void ifplot_mainNG(NODE arg,char *fn,Obj *rp){ |
|
Line 970 void ifplot_mainNG(NODE arg,char *fn,Obj *rp){ |
|
} |
} |
// formular check |
// formular check |
if(!poly){ |
if(!poly){ |
sprintf(ebuf,"%s : invalid ploy argument",fn); |
sprintf(ebuf,"%s : invalid plot argument",fn); |
error(ebuf); |
error(ebuf); |
} |
} |
// vars check |
// vars check |
Line 945 void ifplot_mainNG(NODE arg,char *fn,Obj *rp){ |
|
Line 978 void ifplot_mainNG(NODE arg,char *fn,Obj *rp){ |
|
for(vl0=vl,vNo=0;vl0;vl0=NEXT(vl0)){ |
for(vl0=vl,vNo=0;vl0;vl0=NEXT(vl0)){ |
if(vl0->v->attr==(pointer)V_IND){ |
if(vl0->v->attr==(pointer)V_IND){ |
if(vNo>=2){ |
if(vNo>=2){ |
sprintf(ebuf,"%s : invalid ploy argument",fn); |
sprintf(ebuf,"%s : invalid plot argument",fn); |
error(ebuf); |
error(ebuf); |
} else v[vNo++]=vl0->v; |
} else v[vNo++]=vl0->v; |
} |
} |
Line 1041 void plotover_mainNG(NODE arg,char *fn,Obj *rp){ |
|
Line 1074 void plotover_mainNG(NODE arg,char *fn,Obj *rp){ |
|
poly=(P)BDY(arg); |
poly=(P)BDY(arg); |
pfine=FALSE; |
pfine=FALSE; |
} else { |
} else { |
sprintf(ebuf,"%s : to many ploy arguments",fn); |
sprintf(ebuf,"%s : to many plot arguments",fn); |
error(ebuf); |
error(ebuf); |
} |
} |
break; |
break; |