X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fintegral.cpp;h=016be2ca726f0f14a714e9c754d2a022dad26c55;hp=2a332083eeb7e97e26bc25451289bcf045dc901b;hb=052e9928511dd77d1d5d489b2a61b75579cc44e3;hpb=7d870583a6bf21a2ffb7b6f051b702064623892e diff --git a/ginac/integral.cpp b/ginac/integral.cpp index 2a332083..016be2ca 100644 --- a/ginac/integral.cpp +++ b/ginac/integral.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's symbolic integral. */ /* - * GiNaC Copyright (C) 1999-2008 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2015 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -48,7 +48,7 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(integral, basic, ////////// integral::integral() - : inherited(&integral::tinfo_static), + : x((new symbol())->setflag(status_flags::dynallocated)) {} @@ -59,7 +59,7 @@ integral::integral() // public integral::integral(const ex & x_, const ex & a_, const ex & b_, const ex & f_) - : inherited(&integral::tinfo_static), x(x_), a(a_), b(b_), f(f_) + : x(x_), a(a_), b(b_), f(f_) { if (!is_a(x)) { throw(std::invalid_argument("first argument of integral must be of type symbol")); @@ -70,8 +70,9 @@ integral::integral(const ex & x_, const ex & a_, const ex & b_, const ex & f_) // archiving ////////// -integral::integral(const archive_node & n, lst & sym_lst) : inherited(n, sym_lst) +void integral::read_archive(const archive_node& n, lst& sym_lst) { + inherited::read_archive(n, sym_lst); n.find_ex("x", x, sym_lst); n.find_ex("a", a, sym_lst); n.find_ex("b", b, sym_lst); @@ -87,8 +88,6 @@ void integral::archive(archive_node & n) const n.add_ex("f", f); } -DEFAULT_UNARCHIVE(integral) - ////////// // functions overriding virtual functions from base classes ////////// @@ -160,8 +159,8 @@ ex integral::eval(int level) const if (ea==eb) return _ex0; - if (are_ex_trivially_equal(eintvar,x) && are_ex_trivially_equal(ea,a) - && are_ex_trivially_equal(eb,b) && are_ex_trivially_equal(ef,f)) + if (are_ex_trivially_equal(eintvar,x) && are_ex_trivially_equal(ea,a) && + are_ex_trivially_equal(eb,b) && are_ex_trivially_equal(ef,f)) return this->hold(); return (new integral(eintvar, ea, eb, ef)) ->setflag(status_flags::dynallocated | status_flags::evaluated); @@ -186,16 +185,14 @@ ex integral::evalf(int level) const } // 12.34 is just an arbitrary number used to check whether a number - // results after subsituting a number for the integration variable. - if (is_exactly_a(ea) && is_exactly_a(eb) - && is_exactly_a(ef.subs(x==12.34).evalf())) { - try { + // results after substituting a number for the integration variable. + if (is_exactly_a(ea) && is_exactly_a(eb) && + is_exactly_a(ef.subs(x==12.34).evalf())) { return adaptivesimpson(x, ea, eb, ef); - } catch (runtime_error &rte) {} } - if (are_ex_trivially_equal(a, ea) && are_ex_trivially_equal(b, eb) - && are_ex_trivially_equal(f, ef)) + if (are_ex_trivially_equal(a, ea) && are_ex_trivially_equal(b, eb) && + are_ex_trivially_equal(f, ef)) return *this; else return (new integral(x, ea, eb, ef)) @@ -410,8 +407,8 @@ ex integral::expand(unsigned options) const return (prefactor*integral(x, newa, newb, rest)).expand(options); } - if (are_ex_trivially_equal(a, newa) && are_ex_trivially_equal(b, newb) - && are_ex_trivially_equal(f, newf)) { + if (are_ex_trivially_equal(a, newa) && are_ex_trivially_equal(b, newb) && + are_ex_trivially_equal(f, newf)) { if (options==0) this->setflag(status_flags::expanded); return *this; @@ -436,7 +433,7 @@ unsigned integral::return_type() const return f.return_type(); } -tinfo_t integral::return_type_tinfo() const +return_type_t integral::return_type_tinfo() const { return f.return_type_tinfo(); } @@ -447,8 +444,8 @@ ex integral::conjugate() const ex conjb = b.conjugate(); ex conjf = f.conjugate().subs(x.conjugate()==x); - if (are_ex_trivially_equal(a, conja) && are_ex_trivially_equal(b, conjb) - && are_ex_trivially_equal(f, conjf)) + if (are_ex_trivially_equal(a, conja) && are_ex_trivially_equal(b, conjb) && + are_ex_trivially_equal(f, conjf)) return *this; return (new integral(x, conja, conjb, conjf)) @@ -474,4 +471,5 @@ ex integral::eval_integ() const return *this; } +GINAC_BIND_UNARCHIVER(integral); } // namespace GiNaC