126
129
inline bool isConstant() const {
127
130
if (empty()) return true;
128
for (unsigned i = 0; i < size(); i++) {
129
if(!(*this)[i].isConstant()) return false;
131
if(!(*this)[0].isConstant()) return false;
132
for (unsigned i = 1; i < size(); i++) {
133
if(!(*this)[i].isZero()) return false;
333
339
SBasis compose_inverse(SBasis const &f, SBasis const &g, unsigned order=2, double tol=1e-3);
335
341
/** Returns the sbasis on domain [0,1] that was t on [from, to]
336
\param a sbasis function
342
\param t sbasis function
337
343
\param from,to interval
341
347
inline SBasis portion(const SBasis &t, double from, double to) { return compose(t, Linear(from, to)); }
342
inline SBasis portion(const SBasis &t, Interval ivl) { return compose(t, Linear(ivl[0], ivl[1])); }
348
inline SBasis portion(const SBasis &t, Interval ivl) { return compose(t, Linear(ivl.min(), ivl.max())); }
364
370
SBasis cos(Linear bo, int k);
366
372
std::vector<double> roots(SBasis const & s);
373
std::vector<double> roots(SBasis const & s, Interval const inside);
367
374
std::vector<std::vector<double> > multi_roots(SBasis const &f,
368
375
std::vector<double> const &levels,
369
376
double htol=1e-7,
370
377
double vtol=1e-7,
381
//--------- Levelset like functions -----------------------------------------------------
383
/** Solve f(t) = v +/- tolerance. The collection of intervals where
384
* v - vtol <= f(t) <= v+vtol
385
* is returned (with a precision tol on the boundaries).
386
\param f sbasis function
387
\param level the value of v.
388
\param vtol: error tolerance on v.
389
\param a, b limit search on domain [a,b]
390
\param tol: tolerance on the result bounds.
391
\returns a vector of intervals.
393
std::vector<Interval> level_set (SBasis const &f,
400
/** Solve f(t)\in I=[u,v], which defines a collection of intervals (J_k). More precisely,
401
* a collection (J'_k) is returned with J'_k = J_k up to a given tolerance.
402
\param f sbasis function
403
\param level: the given interval of deisred values for f.
404
\param a, b limit search on domain [a,b]
405
\param tol: tolerance on the bounds of the result.
406
\returns a vector of intervals.
408
std::vector<Interval> level_set (SBasis const &f,
409
Interval const &level,
414
/** 'Solve' f(t) = v +/- tolerance for several values of v at once.
415
\param f sbasis function
416
\param levels vector of values, that should be sorted.
417
\param vtol: error tolerance on v.
418
\param a, b limit search on domain [a,b]
419
\param tol: the bounds of the returned intervals are exact up to that tolerance.
420
\returns a vector of vectors of intervals.
422
std::vector<std::vector<Interval> > level_sets (SBasis const &f,
423
std::vector<double> const &levels,
429
/** 'Solve' f(t)\in I=[u,v] for several intervals I at once.
430
\param f sbasis function
431
\param levels vector of 'y' intervals, that should be disjoints and sorted.
432
\param a, b limit search on domain [a,b]
433
\param tol: the bounds of the returned intervals are exact up to that tolerance.
434
\returns a vector of vectors of intervals.
436
std::vector<std::vector<Interval> > level_sets (SBasis const &f,
437
std::vector<Interval> const &levels,