11 GINAC_IMPLEMENT_PRINT_CONTEXT(CppFormat, print_csrc_cl_N)
30 void CppFormat::print_integer(
const CppFormat & c,
const cln::cl_I & x) {
31 const int max_cln_int = 536870911;
32 if (x >= cln::cl_I(-max_cln_int) && x <= cln::cl_I(max_cln_int)) {
33 if(c.
suffix==
"MP") c.s <<
"mpREAL(";
34 c.s << cln::cl_I_to_int(x);
35 if(c.
suffix==
"MP") c.s <<
")";
36 else c.s <<
".0" << c.
suffix;
38 print_real(c, cln::cl_float(x));
42 void CppFormat::print_real(
const CppFormat & c,
const cln::cl_R & x) {
43 if (cln::instanceof(x, cln::cl_I_ring)) {
44 print_integer(c, cln::the<cln::cl_I>(x));
45 }
else if (cln::instanceof(x, cln::cl_RA_ring)) {
46 const cln::cl_I numer = cln::numerator(cln::the<cln::cl_RA>(x));
47 const cln::cl_I denom = cln::denominator(cln::the<cln::cl_RA>(x));
50 print_integer(c, numer);
52 print_integer(c, denom);
56 print_integer(c, -numer);
58 print_integer(c, denom);
62 if(c.suffix==
"MP") c.s <<
"mpREAL(" << c.MQuote;
63 cln::cl_print_flags ourflags;
64 ourflags.default_float_format = cln::float_format(cln::the<cln::cl_F>(x));
65 cln::print_real(c.s, ourflags, x);
66 if(c.suffix==
"MP") c.s << c.MQuote <<
")";
71 void CppFormat::print_numeric(
const numeric & p,
const CppFormat & c,
unsigned level) {
73 print_real(c, cln::the<cln::cl_R>(p.to_cl_N()));
76 c.s <<
"complex<double>(";
77 print_real(c, cln::realpart(p.to_cl_N()));
79 print_real(c, cln::imagpart(p.to_cl_N()));
81 }
else if(c.suffix==
"L") {
82 c.s <<
"complex<long double>(";
83 print_real(c, cln::realpart(p.to_cl_N()));
85 print_real(c, cln::imagpart(p.to_cl_N()));
87 }
else if(c.suffix==
"Q") {
89 print_real(c, cln::realpart(p.to_cl_N()));
91 print_real(c, cln::imagpart(p.to_cl_N()));
93 }
else if(c.suffix==
"MP") {
94 c.s <<
"complex<mpREAL>(";
95 print_real(c, cln::realpart(p.to_cl_N()));
97 print_real(c, cln::imagpart(p.to_cl_N()));
100 throw Error(
"CppFormat: suffix is Wrong.");
namespace for Numerical integration with Sector Decomposition method