15 static void print_VEO(
const ex & ex1_in,
const ex & ex2_in,
const print_context & c) {
16 static ex log10 = log(numeric(
"10"));
17 if(is_zero(ex1_in) && is_zero(ex2_in)) {
19 }
else if(is_zero(ex1_in)) {
21 int n2 = floor(ex_to<numeric>(log(ex2)/log10).to_double());
22 double d2 = round(ex_to<numeric>(ex2/power(10,n2)).to_double());
23 if(d2==10) {d2=1; n2++;}
24 c.s <<
"0(" << d2 <<
")";
25 if(n2!=0) c.s <<
"E" << n2;
26 }
else if(is_zero(ex2_in)) {
28 bool neg = bool(ex1<0);
30 int n1 = floor(ex_to<numeric>(log(ex1)/log10).to_double());
33 oss <<
NN(ex1/power(10,n1));
34 string sd1 = oss.str();
35 if(sd1.length()<2+n12) {
38 oss <<
NN(ex1/power(10,n1)+power(10,-4-n12));
40 if(sd1.length()<2+n12)
throw Error(
"VEO: sd1.length()<2+n12");
42 int ci = stoi(sd1.substr(2+n12,1));
46 oss <<
NN(ex1/power(10,n1)+power(10,-n12));
50 sd1 = sd1.substr(0, 2+n12);
54 if(n1!=0) c.s <<
"E" << n1;
59 bool neg = bool(ex1<0);
62 int n1 = floor(ex_to<numeric>(log(ex1)/log10).to_double());
63 int n2 = floor(ex_to<numeric>(log(ex2)/log10).to_double());
64 int d2 = round(ex_to<numeric>(ex2/power(10,n2)).to_double());
65 if(d2==10) {d2=1; n2++;}
68 if(n2==n1+1 && (ex1>5*power(10,n1))) c.s <<
"1";
70 c.s <<
"(" << d2 <<
")";
71 if(n2!=0) c.s <<
"E" << n2;
79 oss <<
NN(ex1/power(10,n1));
80 string sd1 = oss.str();
81 if(sd1.length()<3+n12) {
84 oss <<
NN(ex1/power(10,n1)+power(10,-5-n12));
86 if(sd1.length()<3+n12)
throw Error(
"VEO2: sd1.length()<3+n12");
88 int ci = stoi(sd1.substr(2+n12,1));
92 oss <<
NN(ex1/power(10,n1)+power(10,-n12));
96 sd1 = sd1.substr(0, 2+n12);
97 if(sd1[sd1.length()-1]==
'.') sd1 = sd1.substr(0, sd1.length()-1);
99 c.s << sd1 <<
"(" << d2 <<
")";
100 if(n1!=0) c.s <<
"E" << n1;
107 static void print_VEO2(
const ex & ex1_in,
const ex & ex2_in,
const print_context & c) {
108 static ex log10 = log(numeric(
"10"));
109 if(is_zero(ex1_in) && is_zero(ex2_in)) {
111 }
else if(is_zero(ex1_in)) {
113 int n2 = floor(ex_to<numeric>(log(ex2)/log10).to_double())-1;
114 double d2 = round(ex_to<numeric>(ex2/power(10,n2)).to_double());
115 if(d2==100) {d2=10; n2++;}
116 c.s <<
"00(" << d2 <<
")";
117 if(n2!=0) c.s <<
"E" << n2;
118 }
else if(is_zero(ex2_in)) {
120 bool neg = bool(ex1<0);
122 int n1 = floor(ex_to<numeric>(log(ex1)/log10).to_double());
123 int n12 = VEO_Digits;
125 oss <<
NN(ex1/power(10,n1));
126 string sd1 = oss.str();
127 if(sd1.length()<2+n12) {
130 oss <<
NN(ex1/power(10,n1)+power(10,-4-n12));
132 if(sd1.length()<2+n12)
throw Error(
"VEO2: sd1.length()<2+n12");
134 int ci = stoi(sd1.substr(2+n12,1));
138 oss <<
NN(ex1/power(10,n1)+power(10,-n12));
142 sd1 = sd1.substr(0, 2+n12);
146 if(n1!=0) c.s <<
"E" << n1;
151 bool neg = bool(ex1<0);
154 int n1 = floor(ex_to<numeric>(log(ex1)/log10).to_double());
155 int n2 = floor(ex_to<numeric>(log(ex2)/log10).to_double());
156 int d2 = round(ex_to<numeric>(ex2/power(10,n2-1)).to_double());
157 if(d2==100) {d2=10; n2++;}
160 if(n2==n1+2 && (ex1>5*power(10,n1-1))) c.s <<
"01";
162 c.s <<
"(" << d2 <<
")";
163 if(n2!=0) c.s <<
"E" << n2;
165 int d1 = round(ex_to<numeric>(ex1/power(10,n2-1)).to_double());
166 if(d1<10) c.s <<
"0";
168 c.s <<
"(" << d2 <<
")";
169 if(n2!=0) c.s <<
"E" << n2;
177 oss <<
NN(ex1/power(10,n1));
178 string sd1 = oss.str();
179 if(sd1.length()<4+n12) {
182 oss <<
NN(ex1/power(10,n1)+power(10,-6-n12));
184 if(sd1.length()<4+n12)
throw Error(
"VEO2: sd1.length()<4+n12");
186 int ci = stoi(sd1.substr(3+n12,1));
190 oss <<
NN(ex1/power(10,n1)+power(10,-1-n12));
194 sd1 = sd1.substr(0, 3+n12);
195 if(sd1[sd1.length()-1]==
'.') sd1 = sd1.substr(0, sd1.length()-1);
197 if(sd1.length()==3 && sd1[1]==
'.') {
198 c.s <<
"0." << sd1[0] << sd1[2] <<
"(" << d2 <<
")";
199 if(n1!=-1) c.s <<
"E" << n1+1;
201 c.s << sd1 <<
"(" << d2 <<
")";
202 if(n1!=0) c.s <<
"E" << n1;
213 static ex conjVE(
const ex & x,
const ex & y) {
return VE(x,y).hold(); }
214 static ex zp1D(
const ex & x,
unsigned diff_param) {
return 0;}
215 static ex zd1D(
const ex & x,
const symbol & s) {
return 0;}
216 static ex zp2D(
const ex & x,
const ex & y,
unsigned diff_param) {
return 0;}
217 static ex zd2D(
const ex & x,
const ex & y,
const symbol & s) {
return 0;}
218 static ex dCT(
const ex & x,
const symbol & s) {
return x.diff(s);}
219 static ex pCT(
const ex & x,
unsigned diff_param) {
return 1;}
namespace for Numerical integration with Sector Decomposition method
REGISTER_FUNCTION(CV, do_not_evalf_params()) REGISTER_FUNCTION(PL
do_not_evalf_params().expl_derivative_func(zd1D).derivative_func(zp1D)) REGISTER_FUNCTION(FTX
ex NN(ex expr, int digits)
the nuerical evaluation
ex Rationalize(const ex &e, int dn)