CoolPropTools.h

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
This commit is contained in:
Ian Bell
2014-06-21 00:00:40 +02:00

View File

@@ -4,6 +4,7 @@
#define _CRT_SECURE_NO_WARNINGS
#include "PlatformDetermination.h"
#include "Exceptions.h"
#include <string>
#include <vector>
@@ -235,6 +236,21 @@
};
};
/// Some functions related to testing and comparison of values
bool inline check_abs(double A, double B, double D){
double max = fabs(A);
double min = fabs(B);
if (min>max) {
max = min;
min = fabs(A);
}
if (max>D) return ( ( 1.0-min/max*1e0 ) < D );
else throw CoolProp::ValueError(format("Too small numbers: %f cannot be tested with an accepted error of %f. ",max,D));
};
bool inline check_abs(double A, double B){
return check_abs(A,B,1e5*DBL_EPSILON);
};
template<class T> void normalize_vector(std::vector<T> &x)
{
// Sum up all the elements in the vector