Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
fp_utils.h File Reference
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <vector>
#include "absl/log/check.h"
#include "absl/types/span.h"
#include <cfenv>

Go to the source code of this file.

Classes

class  operations_research::ScopedFloatingPointEnv
 

Namespaces

namespace  operations_research
 In SWIG mode, we don't want anything besides these top-level includes.
 

Macros

#define EXPECT_COMPARABLE(expected, obtained, epsilon)
 
#define EXPECT_NOTCOMPARABLE(expected, obtained, epsilon)
 

Functions

template<typename FloatType >
bool operations_research::IsPositiveOrNegativeInfinity (FloatType x)
 
template<typename FloatType >
bool operations_research::AreWithinAbsoluteOrRelativeTolerances (FloatType x, FloatType y, FloatType relative_tolerance, FloatType absolute_tolerance)
 
template<typename FloatType >
bool operations_research::AreWithinAbsoluteTolerance (FloatType x, FloatType y, FloatType absolute_tolerance)
 
template<typename FloatType >
bool operations_research::IsSmallerWithinTolerance (FloatType x, FloatType y, FloatType tolerance)
 
template<typename FloatType >
bool operations_research::IsIntegerWithinTolerance (FloatType x, FloatType tolerance)
 
void operations_research::GetBestScalingOfDoublesToInt64 (absl::Span< const double > input, int64_t max_absolute_sum, double *scaling_factor, double *max_relative_coeff_error)
 
double operations_research::GetBestScalingOfDoublesToInt64 (absl::Span< const double > input, absl::Span< const double > lb, absl::Span< const double > ub, int64_t max_absolute_sum)
 
void operations_research::ComputeScalingErrors (absl::Span< const double > input, absl::Span< const double > lb, absl::Span< const double > ub, double scaling_factor, double *max_relative_coeff_error, double *max_scaled_sum_error)
 
int64_t operations_research::ComputeGcdOfRoundedDoubles (absl::Span< const double > x, double scaling_factor)
 
template<typename FloatType >
FloatType operations_research::Interpolate (FloatType x, FloatType y, FloatType alpha)
 Returns alpha * x + (1 - alpha) * y.
 
int operations_research::fast_ilogb (double value)
 
double operations_research::fast_scalbn (double value, int exponent)
 
void operations_research::fast_scalbn_inplace (double &mutable_value, int exponent)
 

Macro Definition Documentation

◆ EXPECT_COMPARABLE

#define EXPECT_COMPARABLE ( expected,
obtained,
epsilon )
Value:
expected, obtained, epsilon, epsilon)) \
<< obtained << " != expected value " << expected \
<< " within epsilon = " << epsilon;
bool AreWithinAbsoluteOrRelativeTolerances(FloatType x, FloatType y, FloatType relative_tolerance, FloatType absolute_tolerance)
Definition fp_utils.h:126

Handy alternatives to EXPECT_NEAR(), using relative and absolute tolerance instead of relative tolerance only, and with a proper support for infinity.

Definition at line 175 of file fp_utils.h.

◆ EXPECT_NOTCOMPARABLE

#define EXPECT_NOTCOMPARABLE ( expected,
obtained,
epsilon )
Value:
expected, obtained, epsilon, epsilon)) \
<< obtained << " == expected value " << expected \
<< " within epsilon = " << epsilon;

Definition at line 181 of file fp_utils.h.