bool APPARecord::APPADATA::operator ==(const APPADATA &other) const { return (apparatus == other.apparatus && value == other.value && AlmostEqual(weight,other.weight,2) && AlmostEqual(quality,other.quality,2)); }
bool Result::operator< ( const Result &other ) const { // Yes, this is ugly but it also needs to be fast. Since this is called a // bazillion times, we have to make sure only the required comparisons are // made, and no more. if ( !query_is_empty_ ) { if ( first_char_same_in_query_and_text_ != other.first_char_same_in_query_and_text_ ) { return first_char_same_in_query_and_text_; } bool equal_wb_ratios = AlmostEqual( ratio_of_word_boundary_chars_in_query_, other.ratio_of_word_boundary_chars_in_query_ ); bool equal_wb_utilization = AlmostEqual( word_boundary_char_utilization_, other.word_boundary_char_utilization_ ); if ( AlmostEqual( ratio_of_word_boundary_chars_in_query_, 1.0 ) || AlmostEqual( other.ratio_of_word_boundary_chars_in_query_, 1.0 ) ) { if ( !equal_wb_ratios ) { return ratio_of_word_boundary_chars_in_query_ > other.ratio_of_word_boundary_chars_in_query_; } else { if ( !equal_wb_utilization ) return word_boundary_char_utilization_ > other.word_boundary_char_utilization_; } } if ( query_is_candidate_prefix_ != other.query_is_candidate_prefix_ ) return query_is_candidate_prefix_; if ( !equal_wb_ratios ) { return ratio_of_word_boundary_chars_in_query_ > other.ratio_of_word_boundary_chars_in_query_; } else { if ( !equal_wb_utilization ) return word_boundary_char_utilization_ > other.word_boundary_char_utilization_; } if ( char_match_index_sum_ != other.char_match_index_sum_ ) return char_match_index_sum_ < other.char_match_index_sum_; if ( text_->length() != other.text_->length() ) return text_->length() < other.text_->length(); if ( text_is_lowercase_ != other.text_is_lowercase_ ) return text_is_lowercase_; } // Lexicographic comparison return *text_ < *other.text_; }
bool AMMORecord::AMMODAT2::operator ==(const AMMODAT2 &other) const { return (projectilesPerShot == other.projectilesPerShot && projectile == other.projectile && consumedAmmo == other.consumedAmmo && AlmostEqual(weight,other.weight,2) && AlmostEqual(consumedPercentage,other.consumedPercentage,2)); }
bool IPCTRecord::IPCTDATA::operator ==(const IPCTDATA &other) const { return (AlmostEqual(duration, other.duration, 2) && orientation == other.orientation && AlmostEqual(angleThreshold, other.angleThreshold, 2) && AlmostEqual(placementRadius, other.placementRadius, 2) && soundLevel == other.soundLevel && flags == other.flags ); }
bool WEAPRecord::WEAPDATA::operator ==(const WEAPDATA &other) const { return (weaponType == other.weaponType && AlmostEqual(speed,other.speed,2) && AlmostEqual(reach,other.reach,2) && flags == other.flags && value == other.value && health == other.health && AlmostEqual(weight,other.weight,2) && damage == other.damage); }
bool LIGHRecord::LIGHDATA::operator ==(const LIGHDATA &other) const { return (duration == other.duration && radius == other.radius && color == other.color && flags == other.flags && AlmostEqual(falloff,other.falloff,2) && AlmostEqual(fov,other.fov,2) && value == other.value && AlmostEqual(weight,other.weight,2)); }
bool RGDLRecord::RGDLRAPS::operator ==(const RGDLRAPS &other) const { return (matchBones1 == other.matchBones1 && matchBones2 == other.matchBones2 && matchBones3 == other.matchBones3 && flags == other.flags && // unused AlmostEqual(motorsStrength, other.motorsStrength, 2) && AlmostEqual(poseDelay, other.poseDelay, 2) && AlmostEqual(errorAllowance, other.errorAllowance, 2) && AlmostEqual(disableDisplacement, other.disableDisplacement, 2) ); }
bool GRASRecord::GRASDATA::operator ==(const GRASDATA &other) const { return (density == other.density && minSlope == other.minSlope && maxSlope == other.maxSlope && waterDistance == other.waterDistance && waterOp == other.waterOp && AlmostEqual(posRange,other.posRange,2) && AlmostEqual(heightRange,other.heightRange,2) && AlmostEqual(colorRange,other.colorRange,2) && AlmostEqual(wavePeriod,other.wavePeriod,2) && flags == other.flags); }
bool SHOURecord::SHOUSNAM::operator == (const SHOUSNAM &other) const { return (word == other.word && spell == other.spell && AlmostEqual(recovery, other.recovery, 2) ); }
bool AMMORecord::AMMODATA::operator ==(const AMMODATA &other) const { return (flags == other.flags && value == other.value && clipRounds == other.clipRounds && AlmostEqual(speed,other.speed,2)); }
bool BOOKRecord::BOOKDATA::operator ==(const BOOKDATA &other) const { return (flags == other.flags && teaches == other.teaches && value == other.value && AlmostEqual(weight,other.weight,2)); }
void addRegion(vector<pair<Region*, bool> > & regs, vector<Point>& cycle){ bool isFace = getDir(cycle); if(cycle.size()<2){ return; } if(!AlmostEqual(cycle[0],cycle[cycle.size()-1])){ // cycle not closed } if(cycle.size() < 4){ return; } Line* hss = new Line(cycle.size()*2); hss->StartBulkLoad(); for(size_t i = 0; i<cycle.size()-1; i++){ HalfSegment hs(true, cycle[i],cycle[i+1]); hs.attr.edgeno = i; (*hss) += hs; hs.SetLeftDomPoint(!hs.IsLeftDomPoint()); (*hss) += hs; } hss->EndBulkLoad(); Region* res= new Region(cycle.size()*2); hss->Transform(*res); hss->DeleteIfAllowed(); regs.push_back(pair<Region*,bool>(res, isFace)); }
bool AMEFRecord::AMEFDATA::operator ==(const AMEFDATA &other) const { return (type == other.type && op == other.op && AlmostEqual(value, other.value, 2) ); }
int getUnusedExtension(const DbArray<HalfSegment>& segs, const int pos, const bool* used){ HalfSegment hs; segs.Get(pos,hs); Point dp = hs.GetDomPoint(); double dpx = dp.GetX(); bool done = false; int pos2=pos-1; while(pos2>=0 && !done){ if(used[pos2]){ pos2--; } else { segs.Get(pos2,hs); if(AlmostEqual(dp,hs.GetDomPoint())){ return pos2; } else { double dpx2 = hs.GetDomPoint().GetX(); if(AlmostEqual(dpx,dpx2)){ pos2--; } else { // outside the X-Range done = true; } } } } pos2 = pos+1; while(pos2<segs.Size() ){ if(used[pos2]){ pos2++; }else { segs.Get(pos2,hs); if(AlmostEqual(dp,hs.GetDomPoint())){ return pos2; } else { double dpx2 = hs.GetDomPoint().GetX(); if(AlmostEqual(dpx,dpx2)){ pos2++; }else{ return -1; } } } } return -1; }
/* ~separateCycles~ Finds simple subcycles within ~path~ and inserts each of them into ~cycles~. */ void separateCycles(const vector<Point>& path, vector <vector<Point> >& cycles){ if(path.size()<4){ // path too short for a polyon return; } if(!AlmostEqual(path[0], path[path.size()-1])){ cout << "Ignore Dead end" << endl; return; } set<Point> visitedPoints; vector<Point> cycle; for(unsigned int i=0;i<path.size(); i++){ Point p = path[i]; if(visitedPoints.find(p)!=visitedPoints.end()){ // subpath found vector<Point> subpath; subpath.clear(); subpath.push_back(p); int pos = cycle.size()-1; while(pos>=0 && !AlmostEqual(cycle[pos],p)){ subpath.push_back(cycle[pos]); visitedPoints.erase(cycle[pos]); pos--; } if(pos<0){ cerr << "internal error during searching a subpath" << endl; return; } else { subpath.push_back(p); // close path; if(subpath.size()>3){ cycles.push_back(subpath); } cycle.erase(cycle.begin()+(pos+1), cycle.end()); } } else { cycle.push_back(p); visitedPoints.insert(p); } } if(cycle.size()>3){ cycles.push_back(cycle); } }
bool CSNORecord::CSNODATA::operator ==(const CSNODATA &other) const { return (AlmostEqual(shufflePercent, other.shufflePercent, 2) && AlmostEqual(bjPayoutRatio, other.bjPayoutRatio, 2) && symbol1Stop == other.symbol1Stop && symbol2Stop == other.symbol2Stop && symbol3Stop == other.symbol3Stop && symbol4Stop == other.symbol4Stop && symbol5Stop == other.symbol5Stop && symbol6Stop == other.symbol6Stop && symbolWStop == other.symbolWStop && numDecks == other.numDecks && maxWinnings == other.maxWinnings && currency == other.currency && winningsQuest == other.winningsQuest && flags == other.flags ); }
bool REGNRecord::REGNRDOT::operator ==(const REGNRDOT &other) const { return (objectId == other.objectId && parentIndex == other.parentIndex && clustering == other.clustering && minSlope == other.minSlope && maxSlope == other.maxSlope && flags == other.flags && radiusWRTParent == other.radiusWRTParent && radius == other.radius && angleVarX == other.angleVarX && angleVarY == other.angleVarY && angleVarZ == other.angleVarZ && AlmostEqual(density,other.density,2) && AlmostEqual(maxHeight,other.maxHeight,2) && AlmostEqual(sink,other.sink,2) && AlmostEqual(sinkVar,other.sinkVar,2) && AlmostEqual(sizeVar,other.sizeVar,2)); }
bool MGEFRecord::MGEFDATA::operator ==(const MGEFDATA &other) const { return (flags == other.flags && associated == other.associated && schoolType == other.schoolType && resistValue == other.resistValue && numCounters == other.numCounters && light == other.light && effectShader == other.effectShader && enchantEffect == other.enchantEffect && castingSound == other.castingSound && boltSound == other.boltSound && hitSound == other.hitSound && areaSound == other.areaSound && AlmostEqual(baseCost,other.baseCost,2) && AlmostEqual(projectileSpeed,other.projectileSpeed,2) && AlmostEqual(cefEnchantment,other.cefEnchantment,2) && AlmostEqual(cefBarter,other.cefBarter,2)); }
bool getDir(const vector<Point>& vp){ // determine the direction of cycle int min = 0; for(unsigned int i=1;i<vp.size();i++){ if(vp[i] < vp[min]){ min = i; } } bool cw; int s = vp.size(); if(AlmostEqual(vp[0],vp[vp.size()-1])){ s--; } Point a = vp[ (min - 1 + s ) % s ]; Point p = vp[min]; Point b = vp[ (min+1) % s]; if(AlmostEqual(a.GetX(),p.GetX())){ // a -> p vertical if(a.GetY()>p.GetY()){ cw = false; } else { cw = true; } } else if(AlmostEqual(p.GetX(), b.GetX())){ //p -> b vertical if(p.GetY()>b.GetY()){ cw = false; } else { cw = true; } } else { // both segments are non-vertical double m_p_a = (a.GetY() - p.GetY()) / (a.GetX() - p.GetX()); double m_p_b = (b.GetY() - p.GetY()) / (b.GetX() - p.GetX()); if(m_p_a > m_p_b){ cw = false; } else { cw = true; } } return cw; }
bool Same(const DataVector &data, size_t len) { assert(len <= data.size()); if (len <= 1) return true; ValueType t = data[0]->target; for (size_t i = 1; i < len; ++i) { if (!AlmostEqual(t, data[i]->target)) return false; } return true; }
bool TREERecord::TREECNAM::operator ==(const TREECNAM &other) const { return (shadowRadius == other.shadowRadius && AlmostEqual(curvature,other.curvature,2) && AlmostEqual(minAngle,other.minAngle,2) && AlmostEqual(maxAngle,other.maxAngle,2) && AlmostEqual(branchDim,other.branchDim,2) && AlmostEqual(leafDim,other.leafDim,2) && AlmostEqual(rockSpeed,other.rockSpeed,2) && AlmostEqual(rustleSpeed,other.rustleSpeed,2)); }
bool LANDRecord::LANDVHGT::operator ==(const LANDVHGT &other) const { if(AlmostEqual(offset,other.offset,2)) { //Record order matters on heights, so equality testing is easy for(uint32_t x = 0; x < 33; ++x) for(uint32_t y = 0; y < 33; ++y) if(VHGT[x][y] != other.VHGT[x][y]) return false; return true; } return false; }
/** * Return true if n>0 is equal to e^k for some small integer k. * The latex representation e^{k} is returned in string s */ bool isExpPower (double n, string& s) { faustassert(n>0); stringstream ss (stringstream::out|stringstream::in); int k = (int)floor(log(n)); if ( AlmostEqual(n, exp(float(k))) && (k!=0) && (abs(k)<5.0) ) { ss << "e"; if (k!=1) ss << "^{"<< k <<"}"; s = ss.str(); return true; } else { return false; } }
bool WTHRRecord::WTHRFNAM::operator ==(const WTHRFNAM &other) const { return (AlmostEqual(fogDayNear,other.fogDayNear,2) && AlmostEqual(fogDayFar,other.fogDayFar,2) && AlmostEqual(fogNightNear,other.fogNightNear,2) && AlmostEqual(fogNightFar,other.fogNightFar,2) && AlmostEqual(fogDayPower,other.fogDayPower,2) && AlmostEqual(fogNightPower,other.fogNightPower,2)); }
bool GMSTRecord::GMSTDATA::operator ==(const GMSTDATA &other) const { if(format != other.format) return false; switch(format) { case 's': return cmps(s, other.s) == 0; case 'i': return i == other.i; case 'f': return AlmostEqual(f, other.f, 2); default: return false; } }
bool MGEFRecord::MGEFDATA::operator ==(const MGEFDATA &other) const { return (flags == other.flags && associated == other.associated && resistType == other.resistType && numCounters == other.numCounters && light == other.light && AlmostEqual(projectileSpeed,other.projectileSpeed,2) && effectShader == other.effectShader && displayShader == other.displayShader && effectSound == other.effectSound && boltSound == other.boltSound && hitSound == other.hitSound && areaSound == other.areaSound && archType == other.archType && actorValue == other.actorValue); }
bool EXPLRecord::EXPLDATA::operator ==(const EXPLDATA &other) const { return (light == other.light && sound1 == other.sound1 && flags == other.flags && impactDataSet == other.impactDataSet && sound2 == other.sound2 && soundLevel == other.soundLevel && AlmostEqual(force,other.force,2) && AlmostEqual(damage,other.damage,2) && AlmostEqual(radius,other.radius,2) && AlmostEqual(ISRadius,other.ISRadius,2) && AlmostEqual(radLevel,other.radLevel,2) && AlmostEqual(radTime,other.radTime,2) && AlmostEqual(radRadius,other.radRadius,2)); }
bool LANDRecord::LANDVTXT::operator ==(const LANDVTXT &other) const { return (position == other.position && AlmostEqual(opacity,other.opacity,2)); }
bool GetImpurity(DataVector *data, size_t len, int index, ValueType *value, double *impurity, double *gain) { *impurity = std::numeric_limits<double>::max(); *value = kUnknownValue; *gain = 0; #ifndef USE_OPENMP std::sort(data->begin(), data->begin() + len, TupleCompare(index)); #else __gnu_parallel::sort(data->begin(), data->begin() + len, TupleCompare(index)); #endif size_t unknown = 0; double s = 0; double ss = 0; double c = 0; while (unknown < len && (*data)[unknown]->feature[index] == kUnknownValue) { s += (*data)[unknown]->target * (*data)[unknown]->weight; ss += Squared((*data)[unknown]->target) * (*data)[unknown]->weight; c += (*data)[unknown]->weight; unknown++; } if (unknown == len) { return false; } double fitness0 = c > 1? (ss - s*s/c) : 0; if (fitness0 < 0) { // std::cerr << "fitness0 < 0: " << fitness0 << std::endl; fitness0 = 0; } s = 0; ss = 0; c = 0; for (size_t j = unknown; j < len; ++j) { s += (*data)[j]->target * (*data)[j]->weight; ss += Squared((*data)[j]->target) * (*data)[j]->weight; c += (*data)[j]->weight; } double fitness00 = c > 1? (ss - s*s/c) : 0; double ls = 0, lss = 0, lc = 0; double rs = s, rss = ss, rc = c; double fitness1 = 0, fitness2 = 0; for (size_t j = unknown; j < len-1; ++j) { s = (*data)[j]->target * (*data)[j]->weight; ss = Squared((*data)[j]->target) * (*data)[j]->weight; c = (*data)[j]->weight; ls += s; lss += ss; lc += c; rs -= s; rss -= ss; rc -= c; ValueType f1 = (*data)[j]->feature[index]; ValueType f2 = (*data)[j+1]->feature[index]; if (AlmostEqual(f1, f2)) continue; fitness1 = lc > 1? (lss - ls*ls/lc) : 0; if (fitness1 < 0) { // std::cerr << "fitness1 < 0: " << fitness1 << std::endl; fitness1 = 0; } fitness2 = rc > 1? (rss - rs*rs/rc) : 0; if (fitness2 < 0) { // std::cerr << "fitness2 < 0: " << fitness2 << std::endl; fitness2 = 0; } double fitness = fitness0 + fitness1 + fitness2; if (g_conf.feature_costs && g_conf.enable_feature_tunning) { fitness *= g_conf.feature_costs[index]; } if (*impurity > fitness) { *impurity = fitness; *value = (f1+f2)/2; *gain = fitness00 - fitness1 - fitness2; } } return *impurity != std::numeric_limits<double>::max(); }
bool WATRRecord::WATRDNAM::operator ==(const WATRDNAM &other) const { return (shallow == other.shallow && deep == other.deep && refl == other.refl && AlmostEqual(unknown1,other.unknown1,2) && AlmostEqual(unknown2,other.unknown2,2) && AlmostEqual(unknown3,other.unknown3,2) && AlmostEqual(unknown4,other.unknown4,2) && AlmostEqual(sunPower,other.sunPower,2) && AlmostEqual(reflectAmt,other.reflectAmt,2) && AlmostEqual(fresnelAmt,other.fresnelAmt,2) && AlmostEqual(fogNear,other.fogNear,2) && AlmostEqual(fogFar,other.fogFar,2) && AlmostEqual(rainForce,other.rainForce,2) && AlmostEqual(rainVelocity,other.rainVelocity,2) && AlmostEqual(rainFalloff,other.rainFalloff,2) && AlmostEqual(rainDampner,other.rainDampner,2) && AlmostEqual(dispSize,other.dispSize,2) && AlmostEqual(dispForce,other.dispForce,2) && AlmostEqual(dispVelocity,other.dispVelocity,2) && AlmostEqual(dispFalloff,other.dispFalloff,2) && AlmostEqual(dispDampner,other.dispDampner,2) && AlmostEqual(rainSize,other.rainSize,2) && AlmostEqual(normalsNoiseScale,other.normalsNoiseScale,2) && AlmostEqual(noise1Direction,other.noise1Direction,2) && AlmostEqual(noise2Direction,other.noise2Direction,2) && AlmostEqual(noise3Direction,other.noise3Direction,2) && AlmostEqual(noise1Speed,other.noise1Speed,2) && AlmostEqual(noise2Speed,other.noise2Speed,2) && AlmostEqual(noise3Speed,other.noise3Speed,2) && AlmostEqual(normalsFalloffStart,other.normalsFalloffStart,2) && AlmostEqual(normalsFalloffEnd,other.normalsFalloffEnd,2) && AlmostEqual(fogAmt,other.fogAmt,2) && AlmostEqual(normalsUVScale,other.normalsUVScale,2) && AlmostEqual(underFogAmt,other.underFogAmt,2) && AlmostEqual(underFogNear,other.underFogNear,2) && AlmostEqual(underFogFar,other.underFogFar,2) && AlmostEqual(distAmt,other.distAmt,2) && AlmostEqual(shininess,other.shininess,2) && AlmostEqual(hdrMult,other.hdrMult,2) && AlmostEqual(lightRadius,other.lightRadius,2) && AlmostEqual(lightBright,other.lightBright,2) && AlmostEqual(noise1UVScale,other.noise1UVScale,2) && AlmostEqual(noise2UVScale,other.noise2UVScale,2) && AlmostEqual(noise3UVScale,other.noise3UVScale,2) && AlmostEqual(noise1AmpScale,other.noise1AmpScale,2) && AlmostEqual(noise2AmpScale,other.noise2AmpScale,2) && AlmostEqual(noise3AmpScale,other.noise3AmpScale,2)); }