X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fnumeric.cpp;h=880e0a7ebbde60bcbf0ec559527cc69769f7dd02;hp=a89045bd3d310deeb61aff0a18a8a9d54cf3dee4;hb=13d96fc13f6db5b6650d9e6ad688e13051a7685e;hpb=e78622a06f749a124b007aa7b969de02fcc9c3d2 diff --git a/ginac/numeric.cpp b/ginac/numeric.cpp index a89045bd..880e0a7e 100644 --- a/ginac/numeric.cpp +++ b/ginac/numeric.cpp @@ -336,7 +336,7 @@ void numeric::archive(archive_node &n) const DEFAULT_UNARCHIVE(numeric) ////////// -// functions overriding virtual functions from bases classes +// functions overriding virtual functions from base classes ////////// /** Helper function to print a real number in a nicer way than is CLN's @@ -359,7 +359,6 @@ static void print_real_number(std::ostream &os, const cln::cl_R &num) ourflags.default_float_format = cln::float_format(cln::the(num)); cln::print_real(os, ourflags, num); } - return; } /** This method adds to the output so it blends more consistently together @@ -370,39 +369,39 @@ void numeric::print(const print_context & c, unsigned level) const { debugmsg("numeric print", LOGLEVEL_PRINT); - if (is_of_type(c, print_tree)) { + if (is_a(c)) { c.s << std::string(level, ' ') << cln::the(value) << " (" << class_name() << ")" << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec << std::endl; - } else if (is_of_type(c, print_csrc)) { + } else if (is_a(c)) { std::ios::fmtflags oldflags = c.s.flags(); c.s.setf(std::ios::scientific); if (this->is_rational() && !this->is_integer()) { if (compare(_num0()) > 0) { c.s << "("; - if (is_of_type(c, print_csrc_cl_N)) + if (is_a(c)) c.s << "cln::cl_F(\"" << numer().evalf() << "\")"; else c.s << numer().to_double(); } else { c.s << "-("; - if (is_of_type(c, print_csrc_cl_N)) + if (is_a(c)) c.s << "cln::cl_F(\"" << -numer().evalf() << "\")"; else c.s << -numer().to_double(); } c.s << "/"; - if (is_of_type(c, print_csrc_cl_N)) + if (is_a(c)) c.s << "cln::cl_F(\"" << denom().evalf() << "\")"; else c.s << denom().to_double(); c.s << ")"; } else { - if (is_of_type(c, print_csrc_cl_N)) + if (is_a(c)) c.s << "cln::cl_F(\"" << evalf() << "\")"; else c.s << to_double(); @@ -410,10 +409,10 @@ void numeric::print(const print_context & c, unsigned level) const c.s.flags(oldflags); } else { - const std::string par_open = is_of_type(c, print_latex) ? "{(" : "("; - const std::string par_close = is_of_type(c, print_latex) ? ")}" : ")"; - const std::string imag_sym = is_of_type(c, print_latex) ? "i" : "I"; - const std::string mul_sym = is_of_type(c, print_latex) ? " " : "*"; + const std::string par_open = is_a(c) ? "{(" : "("; + const std::string par_close = is_a(c) ? ")}" : ")"; + const std::string imag_sym = is_a(c) ? "i" : "I"; + const std::string mul_sym = is_a(c) ? " " : "*"; const cln::cl_R r = cln::realpart(cln::the(value)); const cln::cl_R i = cln::imagpart(cln::the(value)); if (cln::zerop(i)) { @@ -531,7 +530,7 @@ bool numeric::has(const ex &other) const { if (!is_exactly_of_type(*other.bp, numeric)) return false; - const numeric &o = static_cast(const_cast(*other.bp)); + const numeric &o = static_cast(*other.bp); if (this->is_equal(o) || this->is_equal(-o)) return true; if (o.imag().is_zero()) // e.g. scan for 3 in -3*I @@ -576,7 +575,7 @@ ex numeric::evalf(int level) const int numeric::compare_same_type(const basic &other) const { GINAC_ASSERT(is_exactly_of_type(other, numeric)); - const numeric &o = static_cast(const_cast(other)); + const numeric &o = static_cast(other); return this->compare(o); } @@ -585,9 +584,9 @@ int numeric::compare_same_type(const basic &other) const bool numeric::is_equal_same_type(const basic &other) const { GINAC_ASSERT(is_exactly_of_type(other,numeric)); - const numeric *o = static_cast(&other); + const numeric &o = static_cast(other); - return this->is_equal(*o); + return this->is_equal(o); } @@ -1574,7 +1573,7 @@ const numeric bernoulli(const numeric &nn) static std::vector< cln::cl_RA > results; static int highest_result = 0; // algorithm not applicable to B(0), so just store it - if (results.size()==0) + if (results.empty()) results.push_back(cln::cl_RA(1)); int n = nn.to_long();