Logo Search packages:      
Sourcecode: inkscape version File versions

std::vector< std::vector< double > > Geom::multi_roots ( SBasis const &  f,
std::vector< double > const &  levels,
double  htol,
double  vtol,
double  a,
double  b 

Solve f(t)=c for several c at once.

f sbasis function
levels vector of 'y' values
a,b left and right bounds
a vector of vectors, one for each y giving roots
Effectively computes: results = roots(f(y_i)) for all y_i

algo: -compute f at both ends of the given segment [a,b]. -compute bounds m<df(t)<M for df on the segment. let c and C be the levels below and above f(a): going from f(a) down to c with slope m takes at least time (f(a)-c)/m going from f(a) up to C with slope M takes at least time (C-f(a))/M From this we conclude there are no roots before a'=a+min((f(a)-c)/m,(C-f(a))/M). Do the same for b: compute some b' such that there are no roots in (b',b]. -if [a',b'] is not empty, repeat the process with [a',(a'+b')/2] and [(a'+b')/2,b']. unfortunately, extra care is needed about rounding errors, and also to avoid the repetition of roots, making things tricky and unpleasant...

TODO: Make sure the code is "rounding-errors proof" and take care about repetition of roots!

Definition at line 315 of file sbasis-roots.cpp.


    std::vector<std::vector<double> > roots(levels.size(), std::vector<double>());

    SBasis df=derivative(f);


Generated by  Doxygen 1.6.0   Back to index