59 for (
unsigned i=0; i<absf.
size(); i++){
60 if (absf.
segs[i](.5)<0) absf.
segs[i]*=-1;
91 for (
unsigned i=0; i<
max.size(); i++){
131 for (
unsigned i=0; i<
sign.size(); i++){
145 if (f.
at0()<-tol*tol && f.
at1()<-tol*tol){
147 }
else if (f.
at0()>tol*tol && f.
at1()>tol*tol){
149 sqrtf[0] =
Linear(std::sqrt(f[0][0]), std::sqrt(f[0][1]));
151 for(
unsigned i = 1; int(i) <=
order && i<r.
size(); i++) {
152 Linear ci(r[i][0]/(2*sqrtf[0][0]), r[i][1]/(2*sqrtf[0][1]));
161 sqrtf =
Linear(std::sqrt(fabs(f.
at0())), std::sqrt(fabs(f.
at1())));
164 double err = (f -
multiply(sqrtf, sqrtf)).tailError(0);
194 for (
unsigned i=0; i<ff.
size(); i++){
224 for (
unsigned i=0; i<f.
size(); i++){
238 double alpha = (f.
at0()+f.
at1())/2.;
242 for (
int i=1; i<=2*
order; i++) err*=d/i;
246 for (
int k=1; k<=2*
order; k+=2){
276 for (
auto & seg : f.
segs){
287 double a=range.
min(), b=range.
max();
289 b=std::max(fabs(a),fabs(b));
298 int i0=(int)
floor(std::log(tol)/std::log(
R));
302 int i0=(int)
floor(std::log(a)/std::log(
R));
304 reciprocal_fn.
cuts.push_back(a);
308 reciprocal_fn.
push(reciprocal1_R/a,
R*a);
311 if (range.
min()<0 || range.
max()<0){
314 reciprocal_fn_neg.
cuts.push_back(-reciprocal_fn.
cuts.back());
315 for (
unsigned i=0; i<reciprocal_fn.
size(); i++){
316 int idx=reciprocal_fn.
segs.size()-1-i;
318 reciprocal_fn_neg.
push_cut(-reciprocal_fn.
cuts.at(idx));
321 reciprocal_fn_neg.
concat(reciprocal_fn);
323 reciprocal_fn=reciprocal_fn_neg;
326 return(reciprocal_fn);
350 assert ( values.size() == times.size() );
356 bump_in -= bump_in.
at0();
357 bump_in /= bump_in.
at1();
362 for (
unsigned i = 0; i<values.size()-1; i++){
363 result.push(bump_out*values[i]+bump_in*values[i+1],times[i+1]);
Range of real numbers that is never empty.
Function that interpolates linearly between two values.
Function defined as discrete pieces.
void push(const T &s, double to)
Convenience/implementation hiding function to add segment/cut pairs.
void push_seg(const T &s)
std::vector< double > cuts
void concat(const Piecewise< T > &other)
void setDomain(Interval dom)
Polynomial in symmetric power basis.
bool isZero(double eps=EPSILON) const
double tailError(unsigned tail) const
bound the error from term truncation
void truncate(unsigned k)
Lifts one dimensional objects into 2D.
auto floor(Geom::Rect const &rect)
Various utility functions.
SBasisN< n > cos(LinearN< n > bo, int k)
Piecewise< SBasis > signSb(SBasis const &f)
Return the sign of the two functions pointwise.
Bezier reverse(const Bezier &a)
Piecewise< SBasis > reciprocalOnDomain(Interval range, double tol=1e-3)
MultiDegree< n > max(MultiDegree< n > const &p, MultiDegree< n > const &q)
Returns the maximal degree appearing in the two arguments for each variables.
Bezier multiply(Bezier const &f, Bezier const &g)
SBasisN< n > reciprocal(LinearN< n > const &a, int k)
static float sign(double number)
Returns +1 for positive numbers, -1 for negative numbers, and 0 otherwise.
SBasisN< n > sqrt(SBasisN< n > const &a, int k)
Piecewise< SBasis > interpolate(std::vector< double > times, std::vector< double > values, unsigned smoothness=1)
Returns a Piecewise SBasis with prescribed values at prescribed times.
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 integral(Bezier const &a)
static Piecewise< SBasis > sqrt_internal(SBasis const &f, double tol, int order)
Piecewise< SBasis > min(SBasis const &f, SBasis const &g)
Return the more negative of the two functions pointwise.
OptInterval bounds_fast(Bezier const &b)
SBasisN< n > sin(LinearN< n > bo, int k)
Point abs(Point const &b)
void truncateResult(Piecewise< SBasis > &f, int order)
some std functions to work with (pw)s-basis