SimpleNode<T>* SearchableList<T>::NextMatch(SimpleNode<T>* Ptr_, PtrCompare<T>& Compare_) { SimpleNode<T>* Node_ = Ptr_->_Next; if (Ptr_) while (Node_ && !Compare_(Ptr_->_Object, Node_->_Object)) Node_ = Node_->_Next; return ((Ptr_ && Node_) ? Node_:NULL); }
SimpleNode<T>* SearchableList<T>::Find(T* Obj_, PtrCompare<T>& Compare_) { SimpleNode<T>* Node_ = _List; if (Obj_) while (Node_ && !Compare_(Obj_, Node_->_Object)) Node_ = Node_->_Next; return ((Obj_ && Node_) ? Node_:NULL); }
/** * Interpret all the numbers. * * @version * - JR Lewis 2012.03.07 * - Initial version. * - JR Lewis 2012.04.25 * - This now does something. */ bool ComparisonBuiltinsImplementation::InterpretAllNumbers_(std::vector<Element> const& parms) const { bool equals = true; size_t const PARMS_SIZE = parms.size(); for(size_t i=1; i<PARMS_SIZE && equals; ++i) { bool correct = true; Number lhs = CastToNumber(parms[i-1], correct); Number rhs = CastToNumber(parms[i], correct); equals = Compare_(lhs, rhs); } return equals; }
int CStr::operator!=( const char * pcStr ) const { return ( Compare_( m_pcData, pcStr ) != 0 ); }
int CStr::operator!=( const CStr & roStr ) const { return ( Compare_( m_pcData, roStr.m_pcData ) != 0 ); }
// Analysis_Lifetime::Analyze() Analysis::RetType Analysis_Lifetime::Analyze() { float favg; int current = 0; if (standalone_ != 0) { standalone_->Printf("%-10s %10s %10s %10s %10s %s\n","#Set","Nlifetimes", "MaxLT","AvgLT","TotFrames","SetName"); } ProgressBar progress( inputDsets_.size() ); std::vector<int> lifetimeCurve; std::vector<int> localCurve; for (unsigned int setIdx = 0; setIdx < inputDsets_.size(); setIdx++) { lifetimeCurve.clear(); localCurve.clear(); DataSet_1D const& DS = static_cast<DataSet_1D const&>( *inputDsets_[setIdx] ); if (standalone_ != 0) mprintf("\t\tCalculating lifetimes for set %s\n", DS.legend()); else progress.Update( current++ ); if (DS.Size() < 1) { mprintf("Warning: Set %s is empty, skipping.\n", DS.legend()); continue; } // Loop over all values in set. int setSize = (int)DS.Size(); double sum = 0.0; double previous_windowavg = 0.0; int windowcount = 0; // Used to trigger averaging int Ncount = 0; // Used in averaging; if !cumulative, == windowcount int frame = 0; // Frame to add data at. int maximumLifetimeCount = 0; // Max observed lifetime int Nlifetimes = 0; // # of separate lifetimes observed int sumLifetimes = 0; // sum of lifetimeCount for each lifetime observed int potentialLifetimeStart=0; int potentialLifetimeStop=0; // Are we using fuzz values? int startingFuzzCount; if (fuzzCut_ < 1) startingFuzzCount = -1; else startingFuzzCount = 0; int fuzzCount = startingFuzzCount; // Where are we starting enum LocationType { OUTSIDE=0, INSIDE, OUTER_FUZZ, INNER_FUZZ }; //static const char* Lstr[] = {"OUTSIDE", "INSIDE", "OUTER_FUZZ", "INNER_FUZZ"}; LocationType location; if ( Compare_(DS.Dval(0), cut_) ) location = INSIDE; else location = OUTSIDE; // Loop over all data points for (int i = 0; i < setSize; ++i) { double dval = DS.Dval(i); //mprintf("\t\t\tValue[%i]= %.2f", i,dval); if (averageonly_) // Average only sum += dval; else { // Lifetime calculation bool frameIsInside = Compare_(dval, cut_); bool calculateLifetime = false; // mprintf("%8i Location=%s, frameIsInside=%i, fuzzCount=%i\n", // DEBUG // i+1, Lstr[location], (int)frameIsInside, fuzzCount); // DEBUG // NOTE: As currently implemented, there must be fuzzCut + 1 // consecutive frames for a lifetime to exist. switch (location) { case OUTSIDE: if (frameIsInside) { potentialLifetimeStart = i; if (fuzzCount == 0) { // We have come in from outside but are within fuzz boundary. fuzzCount = 1; //mprintf("%i: Entered inner fuzz boundary. POTENTIAL LIFETIME START.\n", i+1); location = INNER_FUZZ; } else { // Not doing fuzz calc. We are now inside. location = INSIDE; } } break; case INSIDE: if (!frameIsInside) { potentialLifetimeStop = i; if (fuzzCount == 0) { // We have gone out from inside but are within fuzz boundary. fuzzCount = 1; //mprintf("%i: Exited to outer fuzz boundary. POTENTIAL LIFETIME STOP.\n", i+1); location = OUTER_FUZZ; } else { // Not doing fuzz calc. We are now outside. location = OUTSIDE; calculateLifetime = true; } } break; case OUTER_FUZZ: if (frameIsInside) { // We were in outer fuzz but have come back in. //mprintf("%i: Back inside from outer fuzz after %i frames. Still a lifetime.\n", i+1, fuzzCount); location = INSIDE; fuzzCount = startingFuzzCount; } else { fuzzCount++; if (fuzzCount > fuzzCut_) { // We have been in outer fuzz too long. Now outside. //mprintf("%i: Exited outer fuzz for outside after %i frames.\n", i+1, fuzzCount); location = OUTSIDE; calculateLifetime = true; fuzzCount = startingFuzzCount; } } break; case INNER_FUZZ: if (!frameIsInside) { // We were in inner fuzz but have come back out. if (fuzzCount == 0) { //mprintf("%i: Exiting inner fuzz for outside. Not a lifetime.\n", i+1); location = OUTSIDE; fuzzCount = startingFuzzCount; } else fuzzCount--; } else { fuzzCount++; if (fuzzCount > fuzzCut_) { // We have been inside inner fuzz enough. //mprintf("%i: Entering inside from inner fuzz after %i frames.\n", i+1, fuzzCount); location = INSIDE; fuzzCount = startingFuzzCount; } } break; } // END switch location //mprintf("%8i Start=%i, Stop=%i\n", i+1, potentialLifetimeStart+1, potentialLifetimeStop+1); if (calculateLifetime) { // Were there enough frames? //potentialLifetimeStop++; // Include last frame in lifetime. int lifetimeLength = potentialLifetimeStop - potentialLifetimeStart; if (lifetimeLength > fuzzCut_) { // TODO: Necessary? Always true if calcLifetime? sum += (double)lifetimeLength; RecordCurrentLifetime(potentialLifetimeStart, potentialLifetimeStop, lifetimeLength, maximumLifetimeCount, sumLifetimes, Nlifetimes, lifetimeCurve); } } } // END lifetime calc for this frame //sum += inputDsets_[setIdx]->Dval(i); ++Ncount; ++windowcount; if (windowcount == windowSize_) { // Treat this as the end of an independent run. If lifetime was not // calcd this frame, determine if it should be. if (!averageonly_) { if (location == INSIDE || location == OUTER_FUZZ) { // Were there enough frames? potentialLifetimeStop = i + 1; // Include last frame in lifetime. int lifetimeLength = potentialLifetimeStop - potentialLifetimeStart; if (lifetimeLength > fuzzCut_) { // TODO: Necessary? Always true if calcLifetime? sum += (double)lifetimeLength; RecordCurrentLifetime(potentialLifetimeStart, potentialLifetimeStop, lifetimeLength, maximumLifetimeCount, sumLifetimes, Nlifetimes, lifetimeCurve); } // Reset location to prevent potential lifetime trigger next frame location = OUTSIDE; } // If Nlifetimes is 0 then value was never present. if (Nlifetimes == 0) favg = 0.0; else favg = (float)sumLifetimes / (float)Nlifetimes; //mprintf("\t\t\t[%i]Max lifetime observed: %i frames\n", frame,maximumLifetimeCount); //mprintf("\t\t\t[%i]Avg lifetime: %f frames\n", frame, favg); maxDsets_[setIdx]->Add( frame, &maximumLifetimeCount ); avgDsets_[setIdx]->Add( frame, &favg ); } //mprintf("WINDOW BREAK\n"); double windowavg = sum / (double)Ncount; float fval = (float)(windowavg - previous_windowavg); if (deltaAvg_) previous_windowavg = windowavg; outputDsets_[setIdx]->Add( frame, &fval ); //frame += windowcount; frame++; // Window counter is always reset windowcount = 0; if (!cumulative_) { // Reset average counters sum = 0; Ncount = 0; // Reset lifetime counters maximumLifetimeCount = 0; Nlifetimes = 0; sumLifetimes = 0; } } } // END loop over data points. // Print lifetime information if no window if ( standalone_ != 0 ) { // Update current lifetime total if (location == INSIDE || location == OUTER_FUZZ) { // Were there enough frames? potentialLifetimeStop = setSize; // Include last frame in lifetime. int lifetimeLength = potentialLifetimeStop - potentialLifetimeStart; if (lifetimeLength > fuzzCut_) { // TODO: Necessary? Always true if calcLifetime? sum += (double)lifetimeLength; RecordCurrentLifetime(potentialLifetimeStart, potentialLifetimeStop, lifetimeLength, maximumLifetimeCount, sumLifetimes, Nlifetimes, lifetimeCurve); } } // If Nlifetimes is 0 then value was never present. if (Nlifetimes == 0) favg = 0.0; else favg = (float)sumLifetimes / (float)Nlifetimes; standalone_->Printf("%10u %10i %10i %10.4f %10.0f %s\n",setIdx, Nlifetimes, maximumLifetimeCount, favg, sum, DS.legend()); } // Calculate normalized lifetime curve if (!lifetimeCurve.empty() && !curveSets_.empty()) { curveSets_[setIdx]->Allocate( DataSet::SizeArray(1, lifetimeCurve.size()) ); double norm; if (normalizeCurves_) norm = 1.0 / (double)lifetimeCurve.front(); else norm = 1.0; for (unsigned int n = 0; n != lifetimeCurve.size(); n++) { double dval = lifetimeCurve[n] * norm; curveSets_[setIdx]->Add(n, &dval); } } } return Analysis::OK; }