Skip to content

Commit

Permalink
Puts the empty interval test first
Browse files Browse the repository at this point in the history
  • Loading branch information
Agathe Herrou committed Apr 4, 2024
1 parent 26b639d commit 1c593b3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions interval/intervalCos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ static double cosPi(double x)

interval interval_algebra::Cos(const interval& x)
{
int precision = exactPrecisionUnary(cos, 0, pow(2, x.lsb()));
if (precision == INT_MIN or taylor_lsb) precision = 2*x.lsb() - 1; // if x.lsb() is so small that the automatic computation doesn't work

if (x.isEmpty()) {
return empty();
}

int precision = exactPrecisionUnary(cos, 0, pow(2, x.lsb()));
if (precision == INT_MIN or taylor_lsb) precision = 2*x.lsb() - 1; // if x.lsb() is so small that the automatic computation doesn't work

if (x.size() >= 2*M_PI) {
return {-1, 1, precision};
}
Expand Down
4 changes: 2 additions & 2 deletions interval/intervalCosh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ namespace itv {

interval interval_algebra::Cosh(const interval& x)
{
double v = 0; // absolute lowest slope is at zero

if (x.isEmpty()) {
return empty();
}

double v = 0; // absolute lowest slope is at zero

if (x.hasZero()) {
int precision = exactPrecisionUnary(cosh, v, pow(2, x.lsb()));
if (precision == INT_MIN or taylor_lsb)
Expand Down

0 comments on commit 1c593b3

Please sign in to comment.