X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fintegral.cpp;h=07670f3c9eaefad92831409915bf249506fd1248;hp=3daad3efcf8d0419dbb792443df353e668555c13;hb=9993a7aac97abf383624fc5dae4beecb29531fbd;hpb=d74420ef3c7b1b729393e57a290439fb92928692 diff --git a/ginac/integral.cpp b/ginac/integral.cpp index 3daad3ef..07670f3c 100644 --- a/ginac/integral.cpp +++ b/ginac/integral.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's symbolic integral. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2010 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(TINFO_integral), + : 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(TINFO_integral), 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 ////////// @@ -223,7 +222,7 @@ struct error_and_integral struct error_and_integral_is_less { - bool operator()(const error_and_integral &e1,const error_and_integral &e2) + bool operator()(const error_and_integral &e1,const error_and_integral &e2) const { int c = e1.integral.compare(e2.integral); if(c < 0) @@ -279,7 +278,7 @@ ex adaptivesimpson(const ex & x, const ex & a_in, const ex & b_in, const ex & f, fbvec[i] = subsvalue(x, b, f); svec[i] = hvec[i]*(favec[i]+4*fcvec[i]+fbvec[i])/3; lvec[i] = 1; - errorvec[i] = error*svec[i]; + errorvec[i] = error*abs(svec[i]); while (i>0) { ex fd = subsvalue(x, avec[i]+hvec[i]/2, f); @@ -292,7 +291,7 @@ ex adaptivesimpson(const ex & x, const ex & a_in, const ex & b_in, const ex & f, ex nu4 = fbvec[i]; ex nu5 = hvec[i]; // hopefully prevents a crash if the function is zero sometimes. - ex nu6 = max(errorvec[i], (s1+s2)*error); + ex nu6 = max(errorvec[i], abs(s1+s2)*error); ex nu7 = svec[i]; int nu8 = lvec[i]; --i; @@ -436,7 +435,7 @@ unsigned integral::return_type() const return f.return_type(); } -unsigned integral::return_type_tinfo() const +return_type_t integral::return_type_tinfo() const { return f.return_type_tinfo(); } @@ -474,4 +473,5 @@ ex integral::eval_integ() const return *this; } +GINAC_BIND_UNARCHIVER(integral); } // namespace GiNaC