1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
#pragma once
#include <cmath>
#include "interval_def.hh"
namespace itv {
/**
* @brief Computes the minimum of four doubles
*/
static double min4(double a, double b, double c, double d)
{
return std::min(std::min(a, b), std::min(c, d));
}
/**
* @brief Computes the maximum of four doubles
*/
static double max4(double a, double b, double c, double d)
{
return std::max(std::max(a, b), std::max(c, d));
}
/**
* @brief Computes the minimum of four ints
*/
static double min4(int a, int b, int c, int d)
{
return std::min(std::min(a, b), std::min(c, d));
}
/**
* @brief Computes the maximum of four ints
*/
static double max4(int a, int b, int c, int d)
{
return std::max(std::max(a, b), std::max(c, d));
}
/**
* @brief Computes the value with minimum absolute value among the bounds of an interval
*/
static double minValAbs(interval x)
{
if (std::abs(x.lo()) < std::abs(x.hi())) {
return x.lo();
}
return x.hi();
}
/**
* @brief Computes the value with maximum absolute value
*/
static double maxValAbs(interval x)
{
if (std::abs(x.lo()) < std::abs(x.hi())) {
return x.hi();
}
return x.lo();
}
/**
* @brief Computes the direction of the interior of the interval at the minimum absolute value of
* its bounds
*/
static int signMinValAbs(interval x)
{
if (std::abs(x.lo()) < std::abs(x.hi())) {
return 1;
}
return -1;
}
/**
* @brief Computes the direction of the interior of the interval at the maximum absolute value of
* its bounds
*/
static int signMaxValAbs(interval x)
{
if (std::abs(x.lo()) < std::abs(x.hi())) {
return -1;
}
return 1;
}
} // namespace itv
|