예제 #1
0
/* ===================================================================== */
VOID DumpHistogram(std::ostream& out)
{
    const UINT64 cutoff = KnobCutoff.Value();
    const UINT64 maxlines = KnobMaxLines.Value();
    FLT64 factor = KnobDecayFactor.Value();

    out << "\033[0;0H";
    out << "\033[2J";
    out << "\033[44m";
    out << "Functions with at least " << cutoff << " invocations in the last " <<
        KnobThreshold.Value() << " calls ";
    out << "\033[0m";
    out << endl;

    
    VEC CountMap;
    
    for (ADDR_CNT_MAP::iterator bi = RtnMap.begin(); bi != RtnMap.end(); bi++)
    {
        if( bi->second < cutoff ) continue;

        CountMap.push_back(*bi);
#if 0
        out << setw(18) << (void *)(bi->first) << " " <<
            setw(10) << bi->second <<
            "   " << Target2String(bi->first) << endl;
#endif
    }

    sort( CountMap.begin(), CountMap.end(), CompareLess );
    UINT64 lines = 0;
    for (VEC::iterator bi = CountMap.begin(); bi != CountMap.end(); bi++)
    {
        out << setw(18) << (void *)(bi->first) << " " <<
            setw(10) << bi->second <<
            "   " << Target2String(bi->first) << endl;
        lines++;
        if (lines >= maxlines) break;
    }
    
    for (ADDR_CNT_MAP::iterator bi = RtnMap.begin(); bi != RtnMap.end(); bi++)
    {
        bi->second = UINT64(bi->second * factor);
    }
    
    //out << "Total Functions: " << CountMap.size() << endl;
    
}
예제 #2
0
vector<HTML *> HTMLGraph(T * parent) {
  vector<HTML*> result;
  bool border = true;
  typedef vector<T*> VEC;
  VEC V;
  parent->GetGraphChildren(V);
  VEC::const_iterator w = V.begin(), e = V.end();
  HTML * child;
  HTML * aroot;
  while(w!=e) {
    child = *w;
    table = new HTMLTable(border);
    result.push_back(table); 
    table->add(p->HTMLGraphNode(),1,1);
    vector<HTML *> L;
    child->GetGraphChildren(L);
    vector<HTML*>::const_iterator ww = L.begin(), ee = L.end();
    if(ww!=ee) {
      HTMLTable * subtable = new HTMLTable(border);
      table->add(subtable,1,2);
      int i=1;
      while(ww!=ee) {
        subtable->add(*ww,1,i);
        ++ww;++i;
      };
    };
    ++w;
  };
};
예제 #3
0
파일: st2010.hpp 프로젝트: cmsi/bcl
 static std::size_t choose_next(VEC const& weights, std::size_t present, RNG& rng){
   double sum = *(std::max_element(weights.begin(), weights.end()));
   sum -= weights[present] * rng();
   for (int i = 0; i < weights.size(); ++i) {
     int j = (present + i + 1) % weights.size();
     if (sum <= weights[j]) return j;
     sum -= weights[j];
   }
   return present;
 }
예제 #4
0
파일: st2010.hpp 프로젝트: cmsi/bcl
  static void generate_transition_matrix(VEC const& weights, MAT& tm) {
    using std::abs;
    typedef typename VEC::value_type value_type;
    std::size_t n = weights.size();
    std::vector<double> accum(n+1, 0);
    double sum = std::accumulate(weights.begin(), weights.end(), 0.0);
    double shift = *(std::max_element(weights.begin(), weights.end())) / sum;
    accum[0] = 0;
    for (std::size_t i = 0; i < n; ++i) accum[i+1] = accum[i] + weights[i] / sum;

    for (std::size_t i = 0; i < n; ++i) {
      for (std::size_t j = 0; j < n; ++j) {
        tm[i][j] = (std::max(std::min(accum[i+1] + shift, accum[j+1]) -
                             std::max(accum[i] + shift, accum[j]), 0.0) +
                    std::max(std::min(accum[i+1] + shift, accum[j+1] + 1) -
                             std::max(accum[i] + shift, accum[j] + 1), 0.0)) / (weights[i] / sum);
      }
    }
  }
예제 #5
0
void TestServerPrint(const string& cmd,VEC& vec)
{
    cout<<cmd<<":"<<endl;
    VEC::const_iterator it = vec.begin();
    VEC::const_iterator end = vec.end();
    for ( ; it != end; ++it )
    {
        cout<<*it<<endl;
    }
    cout<<endl;
}
예제 #6
0
vector<HTML *> HTMLShallowGraph(T * parent) {
  vector<HTML*> result;
  bool border = true;
  typedef vector<T*> VEC;
  VEC V;
  parent->GetGraphChildren(V);
  VEC::const_iterator w = V.begin(), e = V.end();
  HTML * child;
  HTML * aroot;
  while(w!=e) {
    child = *w;
    table = new HTMLTable(border);
    result.push_back(table); 
    table->add(HTMLGraphNode(p),1,1);
    ++w;
  };
};
예제 #7
0
파일: tools.cpp 프로젝트: Open-IOT/EEMD
//----------------------------------------------------------------------
VEC Tools::getRands(int n) {
if(VERBOSE) printf("\nVEC Tools::getRands(int n=%d)\n", n);
    VEC rands;
    rands.set_size(n);
    arma::Col<float>::iterator elem = rands.begin();
	float f;
    seedRandom();

	for (int i=0; i < n; i++) {
		f = (float)rand() / RAND_MAX;
		f = 2.0*f - 1.0;
		*elem = f;
        elem++;
	}

	return rands;
}