41 assert(pa.
size() == pb.size());
43 for (
unsigned i = 0; i < pa.
size(); i++)
52 assert(pa.
size() == pb.size());
53 for (
unsigned i = 0; i < pa.
size(); i++){
69 double sgn= (b(.5)<0.)?-1.:1;
73 if (fabs(b.
at0())>zero && fabs(b.
at1())>zero ){
82 for (
unsigned i=0; i<k; i++){
108 std::map<double,unsigned>
result;
111 for(
unsigned i=0; i<
roots.size(); i++){
112 for(
unsigned j=0; j<
roots[i].size();j++){
119 while (i<values.size()&&(g.
at0()>values[i])) i++;
124 while (i<values.size()&&(g.
at1()>values[i])) i++;
131 std::map<double,unsigned>::iterator
const &next,
132 std::vector<double>
const &levels,
134 double t0=(*cut).first;
135 unsigned idx0=(*cut).second;
136 double t1=(*next).first;
137 unsigned idx1=(*next).second;
140 if (std::max(idx0,idx1)==levels.size()){
142 }
else if (idx0 != idx1){
143 idx=std::min(idx0,idx1);
144 }
else if(g((t0+t1)/2) < levels[idx0]) {
146 }
else if(g((t0+t1)/2) > levels[idx0]) {
149 idx = (idx0==levels.size())? idx0-1:idx0;
163 bool flip = ( g01.
at0() > g01.
at1() );
168 g01 -= g_range->min();
169 g01 /= g_range->extent();
175 assert( std::abs( g01.
at0() - 0. ) < zero );
176 assert( std::abs( g01.
at1() - 1. ) < zero );
195 result.concat( result_next );
200 result.setDomain(*g_range);
206 std::vector<double>
result;
207 for (
unsigned i=0; i<f.
size(); i++){
208 std::vector<double> rts=
roots(f.
segs[i]);
210 for (
double rt : rts){
218 std::vector<std::vector<double> >
result(values.size());
219 for (
unsigned i=0; i<f.
size(); i++) {
220 std::vector<std::vector<double> > rts =
multi_roots(f.
segs[i], values);
221 for(
unsigned j=0; j<rts.size(); j++) {
222 for(
unsigned r=0; r<rts[j].size(); r++){
232 std::vector<Interval>
result;
233 for (
unsigned i=0; i<f.
size(); i++){
234 std::vector<Interval> resulti =
level_set( f[i], level, 0., 1., tol);
235 for (
unsigned j=0; j<resulti.size(); j++){
236 double a = f.
cuts[i] + resulti[j].min() * ( f.
cuts[i+1] - f.
cuts[i] );
237 double b = f.
cuts[i] + resulti[j].max() * ( f.
cuts[i+1] - f.
cuts[i] );
241 if ( j==0 && !
result.empty() &&
result.back().intersects(domj) ){
242 result.back().unionWith(domj);
Range of real numbers that is never empty.
Function that interpolates linearly between two values.
Range of real numbers that can be empty.
Function defined as discrete pieces.
void push_seg(const T &s)
std::vector< double > cuts
void concat(const Piecewise< T > &other)
void setDomain(Interval dom)
double mapToDomain(double t, unsigned i) const
Polynomial in symmetric power basis.
double tailError(unsigned tail) const
bound the error from term truncation
Various utility functions.
Bezier reverse(const Bezier &a)
SBasisN< n > divide(SBasisN< n > const &a, SBasisN< n > const &b, int k)
SBasisN< n > compose_inverse(SBasisN< n > const &f, SBasisN< n > const &g, unsigned order=2, double tol=1e-3)
int sgn(const T &x)
Sign function - indicates the sign of a numeric type.
int compose_findSegIdx(std::map< double, unsigned >::iterator const &cut, std::map< double, unsigned >::iterator const &next, std::vector< double > const &levels, SBasis const &g)
SBasisOf< T > shift(SBasisOf< T > const &a, int sh)
D2< T > compose(D2< T > const &a, T const &b)
std::vector< double > roots(SBasis const &s)
Bezier portion(const Bezier &a, double from, double to)
Piecewise< SBasis > pw_compose_inverse(SBasis const &f, SBasis const &g, unsigned order, double zero)
std::vector< std::vector< double > > multi_roots(SBasis const &f, std::vector< double > const &levels, double htol=1e-7, double vtol=1e-7, double a=0, double b=1)
std::map< double, unsigned > compose_pullback(std::vector< double > const &cuts, SBasis const &g)
std::vector< Interval > level_set(D2< SBasis > const &f, Rect region)
Piecewise function class.