Peano 4
Loading...
Searching...
No Matches
Scalar.cpp
Go to the documentation of this file.
1#include "tarch/la/Scalar.h"
2
3#include <algorithm>
4#include <cmath>
5
7
8double tarch::la::max(double a, double b, double c) { return std::max(a, std::max(b, c)); }
9
10double tarch::la::relativeEpsNormaledAgainstValueGreaterOne(double valueA, double valueB, double eps) {
11 return std::max(std::abs(valueA), std::abs(valueB)) <= 1.0 ? eps : eps * std::max(std::abs(valueA), std::abs(valueB));
12}
13
14double tarch::la::relativeEps(double valueA, double valueB, double eps) {
15 return eps * std::max(std::abs(valueA), std::abs(valueB));
16}
17
18#ifdef CompilerICC
19#include <mathimf.h>
20
21double tarch::la::pow(double base, double exponent) { return pow(base, exponent); }
22#else
23double tarch::la::pow(double base, double exponent) { return std::pow(base, exponent); }
24#endif
25
26double tarch::la::convertAbsoluteIntoRelativeValue(double referenceValue, double value) {
27 const double weight = std::max(1.0, std::abs(referenceValue));
28 return value / weight;
29}
double relativeEpsNormaledAgainstValueGreaterOne(double valueA, double valueB=std::numeric_limits< double >::min(), double eps=NUMERICAL_ZERO_DIFFERENCE)
Determine a relative tolerance from one or two values.
Definition Scalar.cpp:10
double relativeEps(double valueA, double valueB=std::numeric_limits< double >::min(), double eps=NUMERICAL_ZERO_DIFFERENCE)
Determine a relative tolerance from one or two values.
Definition Scalar.cpp:14
double max(double a, double b, double c)
I need the maximum of three values all the time, to I decided to write a function for this.
Definition Scalar.cpp:8
double convertAbsoluteIntoRelativeValue(double referenceValue, double value)
Convert an absolute value into a relative one.
Definition Scalar.cpp:26
double pow(double base, double exponent)
Wrapper around std::pow which is redirected to Intel's implementation on Intel machines.
Definition Scalar.cpp:23