double tolupp(std::string str, double sign) { size_t start = 0; reltypes_et reltype; double val1, val2, factor; reltype = is_relative(str); if(ABS==reltype){ // absolute tolerance value // first number val1 = norm_value(str,start); //second number val2 = norm_value(str,start); if(isnan(val2)) return sign*abs(val1); // if only one value - negative lower bound if(sign*val2>sign*val1) return val2; return val1; }else{ //relative tolerance value factor = getfactor(reltype); // first number val1 = getval(str,start) * factor; //second number val2 = getval(str,start) * factor; if(isnan(val2)) return sign*abs(val1); // if only one value - negative lower bound if(sign*val2>sign*val1) return val2; return val1; } }
double CSVop::getHighest(int col, vector<int> rows) { double maxval; unsigned i; if(0==rows.size()) return NAN; maxval = norm_value(tab.Tableread(rows[0], col)); for(i=1;i<rows.size();i++){ maxval = max(maxval,norm_value(tab.Tableread(rows[i], col))); } return maxval; }
double CSVop::getHighest(int col) { double maxval; int i; if(0==tab.getNorows()) return NAN; maxval = norm_value(tab.Tableread(0, col)); for(i=1;i<getNorows();i++){ maxval = max(maxval,norm_value(tab.Tableread(i, col))); } return maxval; }
double CSVop::getLowest(int col) { double minval; int i; if(0==tab.getNorows()) return NAN; minval = norm_value(tab.Tableread(0, col)); for(i=1;i<getNorows();i++){ minval = min(minval,norm_value(tab.Tableread(i, col))); } return minval; }
double CSVop::getNearest(int col, double val, vector<int> rows) { double minval, retval, tabval; unsigned i; if(0==rows.size()) return NAN; retval = norm_value(tab.Tableread(rows[0], col)); minval = abs(retval-val); for(i=1;i<rows.size();i++){ tabval = norm_value(tab.Tableread(rows[i], col)); if(abs(tabval-val)<minval){ minval = abs(tabval-val); retval = tabval; } } return retval; }
double CSVop::getNearest(int col, double val) { double minval, retval, tabval; int i; if(0==tab.getNorows()) return NAN; retval = norm_value(tab.Tableread(0, col)); minval = abs(retval-val); for(i=1;i<getNorows();i++){ tabval = norm_value(tab.Tableread(i, col)); if(abs(tabval-val)<minval){ minval = abs(tabval-val); retval = tabval; } } return retval; }
vector<int> CSVop::getrowswtol(vector<int> irows, int col, double val, double prec, bool absolute) { unsigned i; double tabval; vector<int> rows; rows.clear(); if(absolute){ for(i=0;i<irows.size();i++){ tabval = norm_value(tab.Tableread(irows[i],col)); if((val-prec < tabval) && (tabval < val+prec)){ rows.push_back(irows[i]); } } }else{ for(i=0;i<irows.size();i++){ tabval = norm_value(tab.Tableread(irows[i],col)); if((val*(1-prec) < tabval) && (tabval < val*(1+prec))){ rows.push_back(irows[i]); } } } return rows; }
vector<int> CSVop::getrowswtol(int col, double val, double prec, bool absolute) { int i; double tabval; vector<int> rows; rows.clear(); if(absolute){ for(i=0;i<tab.getNorows();i++){ tabval = norm_value(tab.Tableread(i,col)); if((val-prec < tabval) && (tabval < val+prec)){ rows.push_back(i); } } }else{ for(i=0;i<tab.getNorows();i++){ tabval = norm_value(tab.Tableread(i,col)); if((val*(1-prec) < tabval) && (tabval < val*(1+prec))){ rows.push_back(i); } } } return rows; }
vector<int> CSVop::findbestrows(vector<int> rows, datapair_t sortdata) { int col; vector<int> rrows; if(2>rows.size()) return rows; col = tab.findcol(sortdata.fieldname, 0, 0, sortdata.namecontains,sortdata.strcontainsname); if(sortdata.lowest){ rrows = getLowestrows(rows, col, sortdata.precision, false); }else if(sortdata.highest){ rrows = getHighestrows(rows, col, sortdata.precision, false); }else if(sortdata.nearest){ rrows = getNearestrows(rows, col, norm_value(sortdata.fieldentry), sortdata.precision, false); }else{ rrows = rows; } return rrows; }
static void make_expected(void) { float *pe = expected; int i, j; for (j = 0; j < TEXTURE_HEIGHT; j++) for (i = 0; i < TEXTURE_WIDTH; i++) { if (comptype == SHADOW_T) { *pe++ = shadow_compare(norm_value(pixel_value(i, j + 1))); *pe++ = shadow_compare(norm_value(pixel_value(i + 1, j + 1))); *pe++ = shadow_compare(norm_value(pixel_value(i + 1, j))); *pe++ = shadow_compare(norm_value(pixel_value(i, j))); } else { *pe++ = norm_value(pixel_value(i, j + 1)); *pe++ = norm_value(pixel_value(i + 1, j + 1)); *pe++ = norm_value(pixel_value(i + 1, j)); *pe++ = norm_value(pixel_value(i, j)); } } }
static void make_expected(void) { float *pe = expected; int i, j; for (j = 0; j < texture_height; j++) for (i = 0; i < texture_width; i++) { if (comptype == SHADOW_T) { if (use_offsets) { *pe++ = shadow_compare(norm_value(pixel_value(i, j, 0))); *pe++ = shadow_compare(norm_value(pixel_value(i, j, 1))); *pe++ = shadow_compare(norm_value(pixel_value(i, j, 2))); *pe++ = shadow_compare(norm_value(pixel_value(i, j, 3))); } else { *pe++ = shadow_compare(norm_value(pixel_value(i, j + 1, 0))); *pe++ = shadow_compare(norm_value(pixel_value(i + 1, j + 1, 0))); *pe++ = shadow_compare(norm_value(pixel_value(i + 1, j, 0))); *pe++ = shadow_compare(norm_value(pixel_value(i, j, 0))); } } else { if (use_offsets) { *pe++ = norm_value(pixel_value(i, j, 0)); *pe++ = norm_value(pixel_value(i, j, 1)); *pe++ = norm_value(pixel_value(i, j, 2)); *pe++ = norm_value(pixel_value(i, j, 3)); } else { *pe++ = norm_value(pixel_value(i, j + 1, 0)); *pe++ = norm_value(pixel_value(i + 1, j + 1, 0)); *pe++ = norm_value(pixel_value(i + 1, j, 0)); *pe++ = norm_value(pixel_value(i, j, 0)); } } } }