interval pow(const interval& I, unsigned int n) { if (n == 0) { return interval(1.0); } if (n == 1) { return I; } if ((n % 2) == 0) { // n is even? if (I.left() >= 0) { // I is positive? double l = round_down(std::pow(I.left(),n)); double r = round_up(std::pow(I.right(),n)); return interval(l,r); } else { if (I.right() <= 0) { // I is negative? double l = round_down(std::pow(I.right(),n)); double r = round_up(std::pow(I.left(),n)); return interval(l,r); } else { // I straddles 0 double rl = round_up(std::pow(I.right(),n)); double rr = round_up(std::pow(I.left(),n)); return interval(0,max(rl,rr)); } } } // n is odd double l = round_down(std::pow(I.left(),n)); double r = round_up(std::pow(I.right(),n)); return interval(l,r); }
// Split a 2D box into four subboxes by splitting each dimension // into two equal subparts void split_box(const interval &x, const interval &y, interval &xl, interval &xr, interval &yl, interval &yr) { double xm = x.mid(); double ym = y.mid(); xl = interval(x.left(), xm); xr = interval(xm, x.right()); yl = interval(y.left(), ym); yr = interval(ym, y.right()); }
interval operator-(const interval& I1, const interval& I2) { round_downward(); double l = I1.left() - I2.right(); round_upward(); double r = I1.right() - I2.left(); round_nearest(); return interval(l,r); }
interval operator*(const interval& I1, const interval& I2) { round_downward(); double l = min(min(I1.left()*I2.left(),I1.left()*I2.right()), min(I1.right()*I2.left(),I1.right()*I2.right())); round_upward(); double r = max(max(I1.left()*I2.left(),I1.left()*I2.right()), max(I1.right()*I2.left(),I1.right()*I2.right())); round_nearest(); return interval(l,r); }
void MPI_Send_Interval(const interval & x, const interval & y, double threshold, double min_ub) { double envoie_inter_thres_min[6] = {x.left(),x.right(),y.left(),y.right(),threshold,min_ub}; MPI_Send(&choice_fun,50,MPI_CHAR,cpt,0,MPI_COMM_WORLD); MPI_Send(&envoie_inter_thres_min,6,MPI_DOUBLE,cpt,0,MPI_COMM_WORLD); }