WSL/SLF GitLab Repository

Commit 0ba39366 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

Cosmetic changes: whitespaces, comments, etc

parent 48cfe285
......@@ -229,11 +229,10 @@ size_t IOManager::getMeteoData(const Date& i_date, METEO_SET& vecMeteo)
//Let's make sure we have the data we need, in the filtered_cache or in vec_cache
vector< vector<MeteoData> >* data = NULL; //reference to either filtered_cache or vec_cache
if ((IOManager::filtered & processing_level) == IOManager::filtered){
if ((fcache_start <= i_date-proc_properties.time_before) && (fcache_end >= i_date+proc_properties.time_after)) {
//already cached data
} else {
const bool cached = (fcache_start <= i_date-proc_properties.time_before) && (fcache_end >= i_date+proc_properties.time_after);
if (!cached) {
//explicit caching, this forces the bufferediohandler to rebuffer, if necessary
bufferedio.readMeteoData(i_date-proc_properties.time_before, i_date+proc_properties.time_after, vec_cache);
bufferedio.readMeteoData(i_date-proc_properties.time_before, i_date+proc_properties.time_after, vec_cache); //HACK: vec_cache is not used
fill_filtered_cache();
}
data = &filtered_cache;
......@@ -242,7 +241,6 @@ size_t IOManager::getMeteoData(const Date& i_date, METEO_SET& vecMeteo)
data = &vec_cache;
}
if ((IOManager::resampled & processing_level) != IOManager::resampled) { //no resampling required
for (size_t ii=0; ii<(*data).size(); ii++) { //for every station
const size_t index = IOUtils::seek(i_date, (*data)[ii], true); //needs to be an exact match
......@@ -263,9 +261,9 @@ size_t IOManager::getMeteoData(const Date& i_date, METEO_SET& vecMeteo)
//Store result in the local cache
add_to_cache(i_date, vecMeteo);
return vecMeteo.size();
}
#ifdef _POPC_ //HACK popc
void IOManager::writeMeteoData(/*const*/ std::vector< METEO_SET >& vecMeteo, /*const*/ std::string& name)
#else
......
......@@ -165,25 +165,23 @@ namespace Optim {
}
//see http://metamerist.com/cbrt/cbrt.htm
template <int n>
inline float nth_rootf(float x) {
template <int n> inline float nth_rootf(float x) {
const int ebits = 8;
const int fbits = 23;
int& i = (int&) x;
const int bias = (1 << (ebits-1))-1;
int& i = reinterpret_cast<int&>(x);
i = (i - (bias << fbits)) / n + (bias << fbits);
return x;
}
template <int n>
inline double nth_rootd(double x) {
template <int n> inline double nth_rootd(double x) {
const int ebits = 11;
const int fbits = 52;
int64_t& i = (int64_t&) x;
const int64_t bias = (1 << (ebits-1))-1;
int64_t& i = reinterpret_cast<int64_t&>(x);
i = (i - (bias << fbits)) / n + (bias << fbits);
return x;
......@@ -194,7 +192,8 @@ namespace Optim {
* This version is based on a single iteration Halley's method (see https://en.wikipedia.org/wiki/Halley%27s_method)
* with a seed provided by a bit hack approximation. It should offer 15-16 bits precision and be three times
* faster than pow(x, 1/3). In some test, between -500 and +500, the largest relative error was 1.2e-4.
* Source: http://metamerist.com/cbrt/cbrt.htm
* Source: Otis E. Lancaster, Machine Method for the Extraction of Cube Root Journal of the American Statistical Association, Vol. 37, No. 217. (Mar., 1942), pp. 112-115.
* and http://metamerist.com/cbrt/cbrt.htm
*
* Please benchmark your code before deciding to use this!!
* @param x argument
......@@ -203,7 +202,7 @@ namespace Optim {
inline double cbrt(double x) {
const double a = nth_rootd<3>(x);
const double a3 = a*a*a;
const double b = a * ( a3 + x + x) / ( a3 + a3 + x );
const double b = a * ( (a3 + x) + x) / ( a3 + (a3 + x) );
return b; //single iteration, otherwise set a=b and do it again
}
......
......@@ -62,7 +62,6 @@ void MeteoProcessor::getWindowSize(ProcessingProperties& o_properties)
for (map<string, ProcessingStack*>::const_iterator it=processing_stack.begin(); it != processing_stack.end(); ++it){
(*(it->second)).getWindowSize(tmp);
compareProperties(tmp, o_properties);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment