43 print_func<print_python>(&integral::do_print).
44 print_func<print_latex>(&integral::do_print_latex))
61 integral::integral(
const ex & x_,
const ex & a_,
const ex & b_,
const ex & f_)
62 :
x(x_), a(a_), b(b_), f(f_)
64 if (!is_a<symbol>(
x)) {
65 throw(std::invalid_argument(
"first argument of integral must be of type symbol"));
75 inherited::read_archive(
n, sym_lst);
76 n.find_ex(
"x",
x, sym_lst);
77 n.find_ex(
"a",
a, sym_lst);
78 n.find_ex(
"b",
b, sym_lst);
79 n.find_ex(
"f",
f, sym_lst);
84 inherited::archive(
n);
110 string varname = ex_to<symbol>(
x).get_name();
118 if (varname.size() > 1)
119 c.s <<
"\\," << varname <<
"\\:";
121 c.s << varname <<
"\\,";
166 if (is_exactly_a<numeric>(ea) && is_exactly_a<numeric>(eb) &&
167 is_exactly_a<numeric>(ef.
subs(
x==12.34).
evalf())) {
175 return dynallocate<integral>(
x, ea, eb, ef);
184 if (is_a<numeric>(result))
186 throw logic_error(
"integrand does not evaluate to numeric");
210 typedef map<error_and_integral, ex, error_and_integral_is_less>
lookup_map;
222 ex a = is_exactly_a<numeric>(a_in) ? a_in : a_in.
evalf();
223 ex b = is_exactly_a<numeric>(b_in) ? b_in : b_in.
evalf();
224 if(!is_exactly_a<numeric>(a) || !is_exactly_a<numeric>(b))
225 throw std::runtime_error(
"For numerical integration the boundaries of the integral should evalf into numbers.");
226 if(!is_exactly_a<numeric>(error))
227 throw std::runtime_error(
"For numerical integration the error should be a number.");
231 static symbol ivar(
"ivar");
234 if (emi!=lookup.end())
253 svec[i] = hvec[i]*(favec[i]+4*fcvec[i]+fbvec[i])/3;
255 errorvec[i] = error*
abs(svec[i]);
260 ex s1 = hvec[i]*(favec[i]+4*fd+fcvec[i])/6;
261 ex s2 = hvec[i]*(fcvec[i]+4*fe+fbvec[i])/6;
268 ex nu6 = max(errorvec[i],
abs(s1+s2)*error);
272 if (
abs(ex_to<numeric>(s1+s2-nu7)) <= nu6)
276 throw runtime_error(
"max integration level reached");
292 errorvec[i]=errorvec[i-1];
304 return ((
b-
a)*
f).degree(s);
309 return ((
b-
a)*
f).ldegree(s);
336 throw (std::out_of_range(
"integral::op() out of range"));
353 throw (std::out_of_range(
"integral::let_op() out of range"));
366 if (is_a<add>(newf)) {
368 v.reserve(newf.
nops());
369 for (
size_t i=0; i<newf.
nops(); ++i)
374 if (is_a<mul>(newf)) {
377 for (
size_t i=0; i<newf.
nops(); ++i)
381 prefactor *= newf.
op(i);
389 this->
setflag(status_flags::expanded);
393 const integral & newint = dynallocate<integral>(
x, newa, newb, newf);
402 throw(logic_error(
"differentiation with respect to dummy variable"));
426 return dynallocate<integral>(
x, conja, conjb, conjf);
436 if (is_a<power>(
f) &&
f.
op(0)==
x) {
Interface to GiNaC's symbolic exponentiation (basis^exponent).
int ldegree(const ex &s) const override
Return degree of lowest power in object s.
Interface to GiNaC's symbolic objects.
static int max_integration_level
print_func< print_dflt >(&diracone::do_print). print_func< print_latex >(&diracone
int compare(const ex &other) const
ex subs(const exmap &m, unsigned options=0) const
void do_print_latex(const print_latex &c, unsigned level) const
ex conjugate() const override
const basic & hold() const
Stop further evaluation.
const basic & setflag(unsigned f) const
Set some status_flags.
ex expand(unsigned options=0) const
integral(const ex &x_, const ex &a_, const ex &b_, const ex &f_)
bool has(const ex &pattern, unsigned options=0) const
size_t nops() const override
Number of operands/members.
ex eval_ncmul(const exvector &v) const
Archiving of GiNaC expressions.
Interface to GiNaC's sums of expressions.
This class is the ABC (abstract base class) of GiNaC's class hierarchy.
bool are_ex_trivially_equal(const ex &e1, const ex &e2)
Compare two objects of class quickly without doing a deep tree traversal.
int degree(const ex &s) const override
Return degree of highest power in object s.
Interface to GiNaC's products of expressions.
Interface to GiNaC's wildcard objects.
ex eval_ncmul(const exvector &v) const override
ex derivative(const symbol &s) const override
Default implementation of ex::diff().
Interface to several small and furry utilities needed within GiNaC but not of any interest to the use...
ex subsvalue(const ex &var, const ex &value, const ex &fun)
ex eval_integ() const override
Evaluate integrals, if result is known.
unsigned precedence() const override
Return relative operator precedence (for parenthezing output).
bool haswild(const ex &x)
Check whether x has a wildcard anywhere as a subexpression.
Context for latex-parsable output.
void do_print(const print_context &c, unsigned level) const
static ex relative_integration_error
GiNaC's class registrar (for class basic and all classes derived from it).
#define GINAC_ASSERT(X)
Assertion macro for checking invariances.
B & dynallocate(Args &&... args)
Constructs a new (class basic or derived) B object on the heap.
const numeric log(const numeric &x)
Natural logarithm.
To distinguish between different kinds of non-commutative objects.
ex diff(const symbol &s, unsigned nth=1) const
Compute partial derivative of an expression.
const numeric abs(const numeric &x)
Absolute value.
std::vector< ex > exvector
Interface to GiNaC's overloaded operators.
#define GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(classname, supername, options)
Macro for inclusion in the implementation of each registered class.
return_type_t return_type_tinfo() const override
return_type_t return_type_tinfo() const
Interface to GiNaC's symbolic integral.
Base class for print_contexts.
ex adaptivesimpson(const ex &x, const ex &a_in, const ex &b_in, const ex &f, const ex &error)
Numeric integration routine based upon the "Adaptive Quadrature" one in "Numerical Analysis" by Burde...
void read_archive(const archive_node &n, lst &syms) override
Read (a.k.a.
void ensure_if_modifiable() const
Ensure the object may be modified without hurting others, throws if this is not the case...
error_and_integral(const ex &err, const ex &integ)
void print(const print_context &c, unsigned level=0) const
Print expression to stream.
This class stores all properties needed to record/retrieve the state of one object of class basic (or...
ex op(size_t i) const override
Return operand/member at position i.
Lightweight wrapper for GiNaC's symbolic objects.
ex evalf() const override
Evaluate object numerically.
bool operator()(const error_and_integral &e1, const error_and_integral &e2) const
This class holds a two-component object, a basis and and exponent representing exponentiation.
unsigned return_type() const override
Interface to GiNaC's initially known functions.
map< error_and_integral, ex, error_and_integral_is_less > lookup_map
virtual int compare_same_type(const basic &other) const
Returns order relation between two objects of same type.
unsigned return_type() const
Wrapper template for making GiNaC classes out of STL containers.
.expand(0) has already done its job (other expand() options ignore this flag)
Interface to relations between expressions.
Makes the interface to the underlying bignum package available.
ex & let_op(size_t i) override
Return modifiable operand/member at position i.
void archive(archive_node &n) const override
Save (a.k.a.
.eval() has already done its job
unsigned flags
of type status_flags
ex eval() const override
Perform automatic non-interruptive term rewriting rules.
GINAC_BIND_UNARCHIVER(add)
ex expand(unsigned options=0) const override
Expand expression, i.e.