diff --git a/include/CoolPropTools.h b/include/CoolPropTools.h index 2cc281ae..b4969876 100644 --- a/include/CoolPropTools.h +++ b/include/CoolPropTools.h @@ -242,8 +242,7 @@ if (double_vectors.find(s) != double_vectors.end()){ return double_vectors[s]; } else{ throw std::exception(); } }; }; - - /// Utility function for a std::map of pointers + /// Utility function to clear a std::map of pointers //http://stackoverflow.com/questions/569110/why-is-memory-still-accessible-after-stdmapclear-is-called template void freeClear( M & amap ) { for ( typename M::iterator it = amap.begin(); it != amap.end(); ++it ) { @@ -252,6 +251,16 @@ amap.clear(); } + /// Make a linearly spaced vector of points + template std::vector linspace(T xmin, T xmax, int n) { + std::vector x(n, 0.0); + + for ( std::size_t i = 0; i < n; ++i) { + x[i] = (xmax-xmin)/(n-1)*i+xmin; + } + return x; + } + /// Some functions related to testing and comparison of values bool inline check_abs(double A, double B, double D){ double max = fabs(A);