当前位置: 首页>>代码示例>>C++>>正文


C++ map::begin方法代码示例

本文整理汇总了C++中std::map::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ map::begin方法的具体用法?C++ map::begin怎么用?C++ map::begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::map的用法示例。


在下文中一共展示了map::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: addAttribute

void SchemaItem::addAttribute(const std::map<std::string, std::shared_ptr<SchemaValue>> &attributes)
{
    for (auto it = attributes.begin(); it != attributes.end(); ++it)
        addAttribute(it->second);
}
开发者ID:HPCCSmoketest,项目名称:HPCC-Platform,代码行数:5,代码来源:SchemaItem.cpp

示例2: Reconstruct

void Reconstruct()
{
	FILE *fo = fopen(output_file, "wb");

	int sv, cv, cd, len, pst;
	long long num_edges_renet = 0;
	double cw, sum;
	std::queue<int> node, depth;
	std::queue<double> weight;

	for (sv = 0; sv != num_vertices; sv++)
	{
		if (sv % 10 == 0)
		{
			printf("%cProgress: %.3lf%%", 13, (real)sv / (real)(num_vertices + 1) * 100);
			fflush(stdout);
		}

		while (!node.empty()) node.pop();
		while (!depth.empty()) depth.pop();
		while (!weight.empty()) weight.pop();
		vid2weight.clear();

		for (int i = 0; i != num_vertices; i++)
		{
			rank_list[i].vid = i;
			rank_list[i].weight = 0;
		}

		len = neighbor[sv].size();
		if (len > max_k)
		{
			for (int i = 0; i != len; i++)
				fprintf(fo, "%s\t%s\t%lf\n", vertex[sv].name, vertex[neighbor[sv][i].vid].name, neighbor[sv][i].weight);
			num_edges_renet += len;
			continue;
		}

		vid2weight[sv] += vertex[sv].degree / 10.0; // Set weights for self-links here!

		len = neighbor[sv].size();
		sum = vertex[sv].sum_weight;

		node.push(sv);
		depth.push(0);
		weight.push(sum);

		while (!node.empty())
		{
			cv = node.front();
			cd = depth.front();
			cw = weight.front();

			node.pop();
			depth.pop();
			weight.pop();

			if (cd != 0) vid2weight[cv] += cw;

			if (cd < max_depth)
			{
				len = neighbor[cv].size();
				sum = vertex[cv].sum_weight;

				for (int i = 0; i != len; i++)
				{
					node.push(neighbor[cv][i].vid);
					depth.push(cd + 1);
					weight.push(cw * neighbor[cv][i].weight / sum);
				}
			}
		}

		pst = 0;
		std::map<int, double>::iterator iter;
		for (iter = vid2weight.begin(); iter != vid2weight.end(); iter++)
		{
			rank_list[pst].vid = (iter->first);
			rank_list[pst].weight = (iter->second);
			pst++;
		}
		std::sort(rank_list, rank_list + pst);

		for (int i = 0; i != max_k; i++)
		{
			if (i == pst) break;
			fprintf(fo, "%s\t%s\t%.6lf\n", vertex[sv].name, vertex[rank_list[i].vid].name, rank_list[i].weight);
			num_edges_renet++;
		}
	}
	printf("\n");
	fclose(fo);

	printf("Number of edges in reconstructed network: %lld\n", num_edges_renet);
	return;
}
开发者ID:AdeDZY,项目名称:LINE,代码行数:96,代码来源:reconstruct.cpp

示例3: select_parameters

    bool ChooserEvaluator::select_parameters(const std::vector<ChooserPoly> &operands, double noise_standard_deviation, double noise_max_deviation, const std::map<int, BigUInt> &parameter_options, EncryptionParameters &destination)
    {
        if (noise_standard_deviation < 0)
        {
            throw invalid_argument("noise_standard_deviation can not be negative");
        }
        if (noise_max_deviation < 0)
        {
            throw invalid_argument("noise_max_deviation can not be negative");
        }
        if (parameter_options.size() == 0)
        {
            throw invalid_argument("parameter_options must contain at least one entry");
        }
        if (operands.empty())
        {
            throw invalid_argument("operands cannot be empty");
        }

        int largest_bit_count = 0;
        int largest_coeff_count = 0;
        for (vector<ChooserPoly>::size_type i = 0; i < operands.size(); ++i)
        {
            if (operands[i].comp_ == nullptr)
            {
                throw logic_error("no operation history to simulate");
            }
            int current_bit_count = operands[i].max_abs_value_.significant_bit_count();
            largest_bit_count = (current_bit_count > largest_bit_count) ? current_bit_count : largest_bit_count;

            int current_coeff_count = operands[i].max_coeff_count_;
            largest_coeff_count = (current_coeff_count > largest_coeff_count) ? current_coeff_count : largest_coeff_count;
        }

        // We restrict to plain moduli that are powers of two. Here largest_bit_count is the largest positive
        // coefficient that we can expect to appear. Thus, we need one more bit.
        destination.plain_modulus() = 1;
        destination.plain_modulus() <<= largest_bit_count;

        bool found_good_parms = false;
        map<int, BigUInt>::const_iterator iter = parameter_options.begin();
        while (iter != parameter_options.end() && !found_good_parms)
        {
            int dimension = iter->first;
            if (dimension < 512 || (dimension & (dimension - 1)) != 0)
            {
                throw invalid_argument("parameter_options keys invalid");
            }

            if (dimension > largest_coeff_count && destination.plain_modulus() < iter->second)
            {
                // Set the polynomial
                destination.coeff_modulus() = iter->second;
                destination.poly_modulus().resize(dimension + 1, 1);
                destination.poly_modulus().set_zero();
                destination.poly_modulus()[0] = 1;
                destination.poly_modulus()[dimension] = 1;

                // The bound needed for GapSVP->search-LWE reduction
                //parms.noise_standard_deviation() = round(sqrt(dimension / (2 * 3.1415)) + 0.5);

                // Use constant (small) standard deviation.
                destination.noise_standard_deviation() = noise_standard_deviation;

                // We truncate the gaussian at noise_max_deviation.
                destination.noise_max_deviation() = noise_max_deviation;

                // Start initially with the maximum decomposition_bit_count, then decrement until decrypts().
                destination.decomposition_bit_count() = destination.coeff_modulus().significant_bit_count();

                // We bound the decomposition bit count value by 1/8 of the maximum. A too small
                // decomposition bit count slows down multiplication significantly. This is not an
                // issue when the user wants to use multiply_norelin() instead of multiply(), as it
                // only affects the relinearization step. The fraction 1/8 is not an optimal choice
                // in any sense, but was rather arbitrarily chosen. An expert user might want to tweak this
                // value to be smaller or larger depending on their use case.
                // To do: Figure out a somewhat optimal bound.
                int min_decomposition_bit_count = destination.coeff_modulus().significant_bit_count() / 8;

                while (!found_good_parms && destination.decomposition_bit_count() > min_decomposition_bit_count)
                {
                    found_good_parms = true;
                    for (vector<ChooserPoly>::size_type i = 0; i < operands.size(); ++i)
                    {
                        // If one of the operands does not decrypt, set found_good_parms to false.
                        found_good_parms = operands[i].simulate(destination).decrypts() ? found_good_parms : false;
                    }
                    if (!found_good_parms)
                    {
                        --destination.decomposition_bit_count();
                    }
                    else
                    {
                        // We found some good parameters. But in fact we can still decrease the decomposition count
                        // a little bit without hurting performance at all.
                        int old_dbc = destination.decomposition_bit_count();
                        int num_parts = destination.coeff_modulus().significant_bit_count() / old_dbc + (destination.coeff_modulus().significant_bit_count() % old_dbc != 0);
                        destination.decomposition_bit_count() = destination.coeff_modulus().significant_bit_count() / num_parts + (destination.coeff_modulus().significant_bit_count() % num_parts != 0);
                    }
                }
//.........这里部分代码省略.........
开发者ID:privategenocomputation,项目名称:privategenocomputation,代码行数:101,代码来源:chooser.cpp

示例4: main


//.........这里部分代码省略.........
       /**     for (unsigned int i=0;i<MDetector.getCandidates().size();i++) {
                aruco::Marker m( MDetector.getCandidates()[i],999);
                m.draw(TheInputImageCopy,cv::Scalar(255,0,0));
            }*/



            //draw a 3d cube in each marker if there is 3d info
            if (  TheCameraParameters.isValid())
                for (unsigned int i=0;i<TheMarkers.size();i++) {
                    CvDrawingUtils::draw3dCube(TheInputImageCopy,TheMarkers[i],TheCameraParameters);
                    CvDrawingUtils::draw3dAxis(TheInputImageCopy,TheMarkers[i],TheCameraParameters);
                }
            //DONE! Easy, right?
            cout<<endl<<endl<<endl;
            //show input with augmented information and  the thresholded image
            //cv::imshow("in",TheInputImageCopy);
            //cv::imshow("thres",MDetector.getThresholdedImage());

            //key=cv::waitKey(waitTime);//wait for key to be pressed
        }

	lastFrame = index;

    } catch (std::exception &ex)

    {
        cout<<"Exception :"<<ex.what()<<endl;
    }

    cout << "All done."<< endl;

    map<int, Markers>::const_iterator i;
    for( i = AllMarkers.begin(); i != AllMarkers.end(); ++i ) {
      int markerId = (*i).first;
      map<int, Marker> markers = (*i).second;

      int frameCount = markers.size();

      cout << "frameCount = " << frameCount << endl;

      std::vector<double> x(frameCount);
      std::vector<double> m0x(frameCount);
      std::vector<double> m0y(frameCount);
      std::vector<double> m1x(frameCount);
      std::vector<double> m1y(frameCount);
      std::vector<double> m2x(frameCount);
      std::vector<double> m2y(frameCount);
      std::vector<double> m3x(frameCount);
      std::vector<double> m3y(frameCount);
      std::vector<double> tx(frameCount);
      std::vector<double> ty(frameCount);
      std::vector<double> tz(frameCount);
      std::vector<double> rx(frameCount);
      std::vector<double> ry(frameCount);
      std::vector<double> rz(frameCount);

      map<int, Marker>::const_iterator j;
      int index = 0;
      for( j = markers.begin(); j != markers.end(); ++j, index++ ) {
	int frameIndex = (*j).first;
	Marker marker = (*j).second;

	x[index] = frameIndex;
	m0x[index] = marker[0].x;
	m0y[index] = marker[0].y;
开发者ID:ASCTech,项目名称:mooculus,代码行数:67,代码来源:find-markers.cpp

示例5: DoPulse

///////////////////////////////////////////////////////////////
//
// CPerfStatFunctionTimingImpl::DoPulse
//
//
//
///////////////////////////////////////////////////////////////
void CPerfStatFunctionTimingImpl::DoPulse ( void )
{
    // Maybe turn off stats gathering if nobody is watching
    if ( m_bIsActive && m_TimeSinceLastViewed.Get () > 15000 )
        SetActive ( false );

    // Do nothing if not active
    if ( !m_bIsActive )
    {
        m_TimingMap.clear ();
        return;
    }

    // Check if time to cycle the stats
    if ( m_TimeSinceUpdate.Get () >= 10000 )
    {
        m_TimeSinceUpdate.Reset ();

        // For each timed function
        for ( std::map < SString, SFunctionTimingInfo >::iterator iter = m_TimingMap.begin () ; iter != m_TimingMap.end () ; )
        {
            SFunctionTimingInfo& item = iter->second;
            // Update history
            item.iPrevIndex = ( item.iPrevIndex + 1 ) % NUMELMS( item.history );
            item.history[ item.iPrevIndex ] = item.now5s;

            // Reset accumulator
            item.now5s.uiNumCalls = 0;

            item.now5s.fTotalMs = 0;
            item.now5s.fPeakMs = 0;
            item.now5s.fResBiggestMs = 0;
            item.now5s.strResBiggestMsName.clear();

            item.now5s.uiTotalBytes = 0;
            item.now5s.uiPeakBytes = 0;
            item.now5s.uiResBiggestBytes = 0;
            item.now5s.strResBiggestBytesName.clear();

            // Recalculate last 60 second stats
            item.prev60s.uiNumCalls = 0;

            item.prev60s.fTotalMs = 0;
            item.prev60s.fPeakMs = 0;
            item.prev60s.fResBiggestMs = 0;
            item.prev60s.strResBiggestMsName.clear();

            item.prev60s.uiTotalBytes = 0;
            item.prev60s.uiPeakBytes = 0;
            item.prev60s.uiResBiggestBytes = 0;
            item.prev60s.strResBiggestBytesName.clear();

            for ( uint i = 0 ; i < NUMELMS( item.history ) ; i++ )
            {
                const STiming& slot = item.history[i];
                item.prev60s.uiNumCalls += slot.uiNumCalls;

                item.prev60s.fTotalMs += slot.fTotalMs;
                item.prev60s.fPeakMs = Max ( item.prev60s.fPeakMs, slot.fPeakMs );
                if ( item.prev60s.fResBiggestMs < slot.fTotalMs )
                {
                    item.prev60s.fResBiggestMs = slot.fTotalMs;
                    item.prev60s.strResBiggestMsName = slot.strResBiggestMsName;
                }

                item.prev60s.uiTotalBytes += slot.uiTotalBytes;
                item.prev60s.uiPeakBytes = Max ( item.prev60s.uiPeakBytes, slot.uiPeakBytes );
                if ( item.prev60s.uiResBiggestBytes < slot.uiTotalBytes )
                {
                    item.prev60s.uiResBiggestBytes = slot.uiTotalBytes;
                    item.prev60s.strResBiggestBytesName = slot.strResBiggestBytesName;
                }
            }

            // Remove from map if no calls in the last 60s
            if ( item.prev60s.uiNumCalls == 0 )
                m_TimingMap.erase ( iter++ );
            else
                ++iter;
        }
    }

    //
    // Update PeakUs threshold
    //
    m_PeakUsRequiredHistory.RemoveOlderThan ( 10000 );
    ms_PeakUsThresh = m_PeakUsRequiredHistory.GetLowestValue ( DEFAULT_THRESH_MS * 1000 );
}
开发者ID:Anubhav652,项目名称:mtasa-blue,代码行数:95,代码来源:CPerfStat.FunctionTiming.cpp

示例6: getParamPath

 // get param path
 std::string getParamPath(int index)
 {
     std::map<std::string, FAUSTFLOAT*>::iterator it = fZoneMap.begin();
     while (index-- > 0 && it++ != fZoneMap.end()) {}
     return (*it).first;
 }
开发者ID:,项目名称:,代码行数:7,代码来源:

示例7: begin

 iterator begin()
 {
     return props_.begin();
 }
开发者ID:mojodna,项目名称:debian-mapnik,代码行数:4,代码来源:feature.hpp

示例8: FitProfiles

void ClusterWidthAnalysisTreeMaker::FitProfiles(std::map<ULong64_t , std::vector<TProfile*> > &ProfVsAngle, string output_file){

  TFile * myFile = new TFile(output_file.c_str(), "recreate");

  ULong64_t detid;
  double voltage;
  double errvoltage;
  double Slope;
  double errSlope;
  double Origin;
  double errOrigin;
  double Chi2;
  int index;
  TTree *tree = new TTree("T", "summary information");

  tree->Branch("DetID",&detid, "DetID/l");
  tree->Branch("Voltage",&voltage,"Voltage/D");
  tree->Branch("Index",&index,"Index/I");
  tree->Branch("errVoltage",&errvoltage,"errVoltage/D");
  tree->Branch("Slope",&Slope,"Slope/D");
  tree->Branch("errSlope",&errSlope,"errSlope/D");
  tree->Branch("Origin",&Origin,"Origin/D");
  tree->Branch("errOrigin",&errOrigin,"errOrigin/D");
  tree->Branch("Chi2",&Chi2,"Chi2/D");


  //TCanvas* c1 = new TCanvas();
  TH1F* hChi2 = new TH1F("hChi2", "hChi2", 100, 0, 100);
  
  unsigned int nfitrm=0;

  for(std::map<ULong64_t , std::vector<TProfile*> >::iterator iter = ProfVsAngle.begin(); iter != ProfVsAngle.end(); ++iter){
    
	unsigned int i=0; // voltage index    
    std::set< int >::iterator itVolt;
	std::set< int > Voltage = VSmaker.getVoltageList();
    for( itVolt=Voltage.begin(); itVolt!=Voltage.end(); itVolt++){
      
      //std::cout<<"going through the measurement: " << i << std::endl;
            
      TString thestring;
      thestring.Form("DetID_%llu_prof_%u",iter->first,i);
 	  	  
	  if(i>=iter->second.size()) 
       { std::cout<<" Wrong number of voltage steps. "<<std::endl; i++; continue;}
 	  TProfile*  Prof = iter->second[i];
	  
	  if(!Prof) 
       { std::cout<<" Profile "<<thestring.Data()<<"_"<<i<<" not found."<<std::endl; i++; continue;}
 
      //if(Histo->GetEntries()) hNhits->Fill(Histo->Integral());
	  
	  /*if(Histo->Integral()<20) //0.1
	   { //std::cout<<" Not enought entries for histo "<<thestring.Data()<<std::endl;
	    i++; continue;}*/
 
	  
	  detid = iter->first;

	  bool rmfit=false;
	  
	  TF1* pol = new TF1("pol", "pol1", -3, 3);
	  pol->SetRange(-1,0);
	  Prof->Fit("pol", "qr");
	  double chi2 = pol->GetChisquare()/pol->GetNDF();
	  hChi2->Fill(chi2);
	  if(chi2>10) rmfit=true;
	  

      if( rmfit || 
      // TIB modules
          // TIB - 1.4.2.5
      detid==369121605 || detid==369121606 || detid==369121614 || 
      detid==369121613 || detid==369121610 || detid==369121609 ||
          // TIB - 1.2.2.1
      detid==369121390 || detid==369121382 || detid==369121386 || 
      detid==369121385 || detid==369121389 || detid==369121381 ||
          // others in TIB  
      detid==369121437 || detid==369142077 || detid==369121722 || 
      detid==369125534 || detid==369137018 || detid==369121689 ||
      detid==369121765 || detid==369137045 || detid==369169740 ||
      detid==369121689 ||
      // TOB modules 
	      // TOB + 4.3.3.8
      detid/10==436281512 || detid/10==436281528 || detid/10==436281508 ||
      detid/10==436281524 || detid/10==436281520 || detid/10==436281516 ||
          // others in TOB  
      detid/10==436228249 || detid/10==436232694 || detid/10==436228805 ||
      detid/10==436244722 || detid/10==436245110 || detid/10==436249546 ||
      detid/10==436310808 || detid/10==436312136 || detid/10==436315600 ||
	      // without 'sensors' option 
      detid==436281512 || detid==436281528 || detid==436281508 ||
      detid==436281524 || detid==436281520 || detid==436281516 ||
      detid==436228249 || detid==436232694 || detid==436228805 ||
      detid==436244722 || detid==436245110 || detid==436249546 ||
      detid==436310808 || detid==436312136 || detid==436315600 || 
      // TID modules
      detid==402664070 || detid==402664110 ||
	  // TEC modules in small scans
      detid==470148196 || detid==470148200 || detid==470148204 ||
//.........这里部分代码省略.........
开发者ID:MichaelButtignol,项目名称:TrackerAgeingStudies,代码行数:101,代码来源:ClusterWidthAnalysisTreeMaker.C

示例9: Update

bool InputManager::Update()
{
	SDL_Event event;
	std::vector< Key > keys;
	std::vector< MouseButton > mouseButtons;

	while ( SDL_PollEvent( &event ) )
	{
		switch ( event.type )
		{
			case SDL_QUIT:
				return true;
				break;
			case SDL_KEYDOWN:
				{
					keyStates[ event.key.keysym.sym ] = 'd';
					keys.push_back( Key(event.key.keysym.sym) );
				}
				break;
			case SDL_KEYUP:
				{
					keyStates[ event.key.keysym.sym ] = 'u';
					keys.push_back( Key(event.key.keysym.sym) );
				}
				break;
			case SDL_MOUSEBUTTONDOWN:
				{
					mouseButtonStates[ event.button.button ] = 'd';
					mouseButtons.push_back( MouseButton(event.button.button) );
				}
				break;
			case SDL_MOUSEBUTTONUP:
				{
					mouseButtonStates[ event.button.button ] = 'u';
					mouseButtons.push_back( MouseButton(event.button.button) );
				}
				break;
			default:
				break;
		}
	}

	for ( std::map<int, char>::iterator itr = keyStates.begin(); itr != keyStates.end(); itr++ )
	{
		// puts no status flag
		if ( itr->second == 'u' )
		{
			bool keyFound = false;
			for ( int i = 0; i < int(keys.size()); i++ )
			{
				if ( keys[ i ] == itr->first )
				{
					keyFound = true;
					break;
				}
			}

			if ( !keyFound )
			{
				itr->second = 'n';
			}
		}
		else if ( itr->second == 'd' )
		{
			bool keyFound = false;
			for ( int i = 0; i < int(keys.size()); i++ )
			{
				if ( keys[ i ] == itr->first )
				{
					keyFound = true;
					break;
				}
			}

			if ( !keyFound )
			{
				itr->second = 'h';
			}
		}
	}

	for ( std::map<int, char>::iterator itr = mouseButtonStates.begin(); itr != mouseButtonStates.end(); itr++ )
	{
		// puts no status flag
		if ( itr->second == 'u' )
		{
			bool buttonFound = false;
			for ( int i = 0; i < int(mouseButtons.size()); i++ )
			{
				if ( mouseButtons[ i ] == itr->first )
				{
					buttonFound = true;
					break;
				}
			}

			if ( !buttonFound )
			{
				itr->second = 'n';
			}
//.........这里部分代码省略.........
开发者ID:icedmetal57,项目名称:BlackIceEngine,代码行数:101,代码来源:InputManager.cpp

示例10: uObjSense

//#############################################################################
void 
MibSHeuristic::createBilevelSolutions(std::map<double, mcSol> mcSolutions)
{

  MibSModel * model = MibSModel_;
  double uObjSense(model->getSolver()->getObjSense());
  int lCols(model->getLowerDim());
  int uCols(model->getUpperDim());

  int tCols(uCols + lCols); 

  double incumbentObjVal(model->getSolver()->getInfinity() * uObjSense);
  double * incumbentSol = new double[tCols];

  int i(0);

  if(!bestSol_)
    bestSol_ = new double[tCols];

  //initialize the best solution information
  //bestObjVal_ = model->getSolver()->getInfinity() * uObjSense;
  //CoinZeroN(bestSol_, tCols);

  std::map<double, mcSol >::iterator iter = mcSolutions.begin();

  for(iter = mcSolutions.begin(); iter != mcSolutions.end(); iter++){
    
    mcSol tmpsol = iter->second;
    const double * colsol = tmpsol.getColumnSol();
    double origLower = tmpsol.getObjPair().second;
    if(0){
      std::cout << "Candidate solution value: " << origLower << std::endl;
      for(i = 0; i < tCols; i++){
	std::cout << "colsol[" << i << "] :" 
		  << colsol[i] << std::endl;
      }
    }
    
    bfSol * sol = getBilevelSolution(colsol, origLower);

    if(sol){
      

      if(0){
	std::cout << "Returned solution: " << std::endl;
	for(i = 0; i < tCols; i++){
	  std::cout << "sol->getColumnSol[" << i << "]" 
		    << sol->getColumnSol()[i] << std::endl;
	}
	std::cout << "sol->getObjVal: " << sol->getObjVal() << std::endl;
      }
      
      if(sol->getObjVal() < incumbentObjVal){

	incumbentObjVal = sol->getObjVal();
	CoinCopyN(sol->getColumnSol(), tCols, incumbentSol);

	if(0){
	  std::cout << "New incumbent found." << std::endl;
	  for(i = 0; i < tCols; i++){
	    std::cout << "incumbentSol[" << i 
		      << "]: " << incumbentSol[i] << std::endl;
	  }
	  std::cout << "incumbentObjVal: " << incumbentObjVal << std::endl;
	}
	
      }
    }

  }


 
  if(0){
    std::cout << "This solution comes from MibSHeuristic.cpp:742" << std::endl;
  }
  MibSSolution * mibSol = new MibSSolution(tCols,
					   incumbentSol,
					   incumbentObjVal,
					   model);
  
  model->storeSolution(BlisSolutionTypeHeuristic, mibSol);

  //need to add this solution to mibssolutions instead
  //bestObjVal_ = incumbentObjVal;
  //CoinCopyN(incumbentSol, tCols, bestSol_);

  //delete bfSol;
  delete [] incumbentSol;

}
开发者ID:tkralphs,项目名称:MibS,代码行数:92,代码来源:MibSHeuristic.cpp

示例11: FitHistos

void ClusterWidthAnalysisTreeMaker::FitHistos(std::map<ULong64_t , std::vector<TH1F*> > &HistSoN, string output_file, 
 std::vector< TH1F* > commonHistos, std::map<ULong64_t, TProfile* > Monitors){

  TFile * myFile = new TFile(output_file.c_str(), "recreate");

  ULong64_t detid;
  double voltage;
  double errvoltage;
  double Mean;
  double errMean;
  double RMS;
  double errRMS;
  int index;
  int nhits;
  TTree *tree = new TTree("T", "summary information");

  tree->Branch("DetID",&detid, "DetID/l");
  tree->Branch("Voltage",&voltage,"Voltage/D");
  tree->Branch("Index",&index,"Index/I");
  tree->Branch("errVoltage",&errvoltage,"errVoltage/D");
  tree->Branch("Mean",&Mean,"Mean/D");
  tree->Branch("errMean",&errMean,"errMean/D");
  tree->Branch("RMS",&RMS,"RMS/D");
  tree->Branch("errRMS",&errRMS,"errRMS/D");
  tree->Branch("Nhits",&nhits,"Nhits/I");


  //TCanvas* c1 = new TCanvas();
  TH1F* hNhits = new TH1F("hNhits", "hNhits", 1000, 0,1000); // N hits per module
  
  unsigned int nfitrm=0;

  for(std::map<ULong64_t , std::vector<TH1F*> >::iterator iter = HistSoN.begin(); iter != HistSoN.end(); ++iter){
    
	unsigned int i=0; // voltage index    
    std::set< int >::iterator itVolt;
	std::set< int > Voltage = VSmaker.getVoltageList();
    for( itVolt=Voltage.begin(); itVolt!=Voltage.end(); itVolt++){
      
      //std::cout<<"going through the measurement: " << i << std::endl;
            
      TString thestring;
      thestring.Form("DetID_%llu_%u",iter->first,i);
 	  
	  
      //std::cout << "searching for " << thestring.Data() << std::endl;
      //TH1F*  SoNHisto= (TH1F*)gROOT->FindObject( thestring.Data() );
	  
	  if(i>=iter->second.size()) 
       { std::cout<<" Wrong number of voltage steps. "<<std::endl; i++; continue;}
 	  TH1F*  Histo = iter->second[i];
	  
	  if(!Histo) 
       { std::cout<<" Histo "<<thestring.Data()<<"_"<<i<<" not found."<<std::endl; i++; continue;}
 
      if(Histo->GetEntries()) hNhits->Fill(Histo->Integral());
	  
	  if(Histo->Integral()<20) //0.1
	   { //std::cout<<" Not enought entries for histo "<<thestring.Data()<<std::endl;
	    i++; continue;}
 
	  
	  detid = iter->first;

	  bool rmfit=false;

      if( rmfit || 
      // TIB modules
          // TIB - 1.4.2.5
      detid==369121605 || detid==369121606 || detid==369121614 || 
      detid==369121613 || detid==369121610 || detid==369121609 ||
          // TIB - 1.2.2.1
      detid==369121390 || detid==369121382 || detid==369121386 || 
      detid==369121385 || detid==369121389 || detid==369121381 ||
          // others in TIB  
      detid==369121437 || detid==369142077 || detid==369121722 || 
      detid==369125534 || detid==369137018 || detid==369121689 ||
      detid==369121765 || detid==369137045 || detid==369169740 ||
      detid==369121689 ||
      // TOB modules 
	      // TOB + 4.3.3.8
      detid/10==436281512 || detid/10==436281528 || detid/10==436281508 ||
      detid/10==436281524 || detid/10==436281520 || detid/10==436281516 ||
          // others in TOB  
      detid/10==436228249 || detid/10==436232694 || detid/10==436228805 ||
      detid/10==436244722 || detid/10==436245110 || detid/10==436249546 ||
      detid/10==436310808 || detid/10==436312136 || detid/10==436315600 ||
	      // without 'sensors' option 
      detid==436281512 || detid==436281528 || detid==436281508 ||
      detid==436281524 || detid==436281520 || detid==436281516 ||
      detid==436228249 || detid==436232694 || detid==436228805 ||
      detid==436244722 || detid==436245110 || detid==436249546 ||
      detid==436310808 || detid==436312136 || detid==436315600 || 
      // TID modules
      detid==402664070 || detid==402664110 ||
	  // TEC modules in small scans
      detid==470148196 || detid==470148200 || detid==470148204 ||
      detid==470148228 || detid==470148232 || detid==470148236 ||
      detid==470148240 || detid==470148261 || detid==470148262 ||
	  detid==470148265 || detid==470148266 || detid==470148292 ||
//.........这里部分代码省略.........
开发者ID:MichaelButtignol,项目名称:TrackerAgeingStudies,代码行数:101,代码来源:ClusterWidthAnalysisTreeMaker.C

示例12: iterate

void iterate(std::map<int, TreeNodeStorage>& storage, std::vector<int>& roots, size_t& ndim){
  float accumulate;

  for(auto i=storage.begin();i!=storage.end();++i){
    i->second.visited = -1;
  }

  int iter = 0;
  std::stack<int> tovisit;
  float* values = new float[ndim];

  while(true){
    accumulate = 0.0f;
    iter += 1;

    for(size_t i=0;i<roots.size();++i){
      std::vector<int>& outlinks = storage[roots[i]].outlinks;
      storage[roots[i]].visited = iter;
      for(size_t j=0;j<outlinks.size();++j)
        tovisit.push(outlinks[j]);
    }

    while(!tovisit.empty()){
      int id = tovisit.top();
      TreeNodeStorage& node = storage[id];
      tovisit.pop();

      if(node.visited == iter)
        continue;

      node.visited = iter;

      for(size_t i=0;i<node.outlinks.size();++i)
        tovisit.push(node.outlinks[i]);

      for(size_t i=0;i<ndim;++i) values[i] = 0.0f;

      for(size_t i=0;i<node.inlinks.size();++i){
        TreeNodeStorage& inlink = storage[node.inlinks[i]];
        for(size_t j=0;j<ndim;++j)
          values[j] += inlink.values[j];
      }

      float norm = 0.0f;
      for(size_t i=0;i<ndim;++i){
        norm += values[i]*values[i];
      }
      norm = std::sqrt(norm);

      if(norm<0.0000001)
        continue;

      for(size_t i=0;i<ndim;++i){
        float v = values[i] / norm;
        accumulate += std::abs(v - node.values[i]);
        node.values[i] = v;
      }
    }

    std::cerr<<"Iter "<<iter<<", accumulate "<<accumulate<<std::endl;
    if(accumulate<0.0001)
      break;
  }

  delete[] values;
}
开发者ID:NLPScott,项目名称:bdbk-kb,代码行数:66,代码来源:ProbabilitySpace.cpp

示例13: make1DOverviewCanvas

void make1DOverviewCanvas(TFile *infile, TFile *outfile, TList *mclist, std::string dirname) {
  double mass = 0.0;
  int massstart = 0;
  int massend = 0;
  // check if directory is mass bin dir
  unsigned int pointpos = dirname.find(".");
  if (!(pointpos == 0 || pointpos == dirname.size())) {
    std::string masslow = dirname.substr(0, pointpos + 1);
    std::string masshigh = dirname.substr(pointpos + 1);
    massstart = atoi(masslow.c_str());
    massend = atoi(masshigh.c_str());
    mass = 1.0 * (massstart + massend) / 2 / 1000;
  }

  std::map<TString, std::vector<TString> >::iterator it;
  for (it = booky_setup_map.begin(); it != booky_setup_map.end(); it++) {
    TString name(it->first.Data());
    name += dirname.c_str();
	string isoname;
	if (it->first == "Booky_Kpi_isobar"){
		isoname = "(K^{-} #pi^{+})";
	} else {
		isoname = "(#pi^{-} #pi^{+})";
	}

    TCanvas *c = new TCanvas(name, "", 800, 800);
    c->Divide(2,3);
    std::vector<TString> histlist = it->second;

    for (unsigned int i = 0; i < histlist.size(); i++) {
      // CompareTo returns 0 if its a match....
      if (histlist[i].CompareTo("spacer")) {
        TIter histiter = TIter(mclist);
        TH1D *reldiffhist, *diffhist, *mchist, *datahist;
        // generate difference histograms
        std::string hnamemc(histlist[i].Data());
        // create new string with MC exchanged for Diff
        std::string hnamediff(hnamemc);
        int pos = hnamemc.find("MC");
        hnamediff.erase(pos, 2);
        hnamediff.insert(pos, "Diff");
        // create new string with MC exchanged for RelDiff
        std::string hnamereldiff(hnamemc);
        hnamereldiff.erase(pos, 2);
        hnamereldiff.insert(pos, "RelDiff");
        // create new string with MC exchanged for Data
        std::string hnamedata(hnamemc);
        hnamedata.erase(pos, 2);
        hnamedata.insert(pos, "Data");

        infile->GetObject((dirname + "/" + hnamereldiff).c_str(), reldiffhist);
        infile->GetObject((dirname + "/" + hnamediff).c_str(), diffhist);
        infile->GetObject((dirname + "/" + hnamedata).c_str(), datahist);
        infile->GetObject((dirname + "/" + hnamemc).c_str(), mchist);

        outfile->cd(dirname.c_str());
        if (mchist && datahist) {
			stringstream title;
			title << isoname << " " << mchist->GetXaxis()->GetTitle();
			mchist->GetXaxis()->SetTitle( title.str().c_str() );
			title.str("");
			title << isoname << " " << datahist->GetXaxis()->GetTitle();
			datahist->GetXaxis()->SetTitle( title.str().c_str() );
			title.str("");
          c->cd(i + 1);

          // std::cout<<i<<std::endl;
          double scale = datahist->Integral();
          scale = scale / (mchist->Integral());
          mchist->Scale(scale);

          mchist->SetLineColor(kRed);
          mchist->SetFillColor(kRed);
          mchist->Draw("E4");
          datahist->Draw("same");
          if (diffhist) {
			title << isoname << " " << diffhist->GetXaxis()->GetTitle();
			diffhist->GetXaxis()->SetTitle( title.str().c_str() );
			title.str("");
			if (reldiffhist){
				title << isoname << " " << reldiffhist->GetXaxis()->GetTitle();
				reldiffhist->GetXaxis()->SetTitle( title.str().c_str() );
				title.str("");
			}
            TLine* line = new TLine(mchist->GetXaxis()->GetXmin(), 0, mchist->GetXaxis()->GetXmax(), 0);
            line->SetLineStyle(3);
            line->Draw();
            diffhist->SetLineColor(kOrange - 3);
            diffhist->Draw("same");
          }
          double max = mchist->GetMaximum();
          double min = mchist->GetMinimum();
          if (max < datahist->GetMaximum())
            max = datahist->GetMaximum();
          if (diffhist)
            min = diffhist->GetMinimum();
          mchist->GetYaxis()->SetRangeUser(diffhist->GetMinimum() * 1.5, max * 1.2);
          c->Update();
        }
      }
//.........这里部分代码省略.........
开发者ID:ROOTPWA-Maintainers,项目名称:ROOTPWA,代码行数:101,代码来源:plotGlobalWeightedEvts_Kpipi.C

示例14: VariantMap

CVariant::CVariant(const std::map<std::string, CVariant> &variantMap)
{
  m_type = VariantTypeObject;
  m_data.map = new VariantMap(variantMap.begin(), variantMap.end());
}
开发者ID:virtuallysafe,项目名称:mrmc,代码行数:5,代码来源:Variant.cpp

示例15: assert_for_values

void polynomial_acceleratort::assert_for_values(scratch_programt &program,
                                                std::map<exprt, int> &values,
                                                std::set<std::pair<expr_listt, exprt> >
                                                   &coefficients,
                                                int num_unwindings,
                                                goto_programt::instructionst
                                                   &loop_body,
                                                exprt &target,
                                                overflow_instrumentert &overflow) {
  // First figure out what the appropriate type for this expression is.
  typet expr_type = nil_typet();

  for (std::map<exprt, int>::iterator it = values.begin();
      it != values.end();
      ++it) {
    typet this_type=it->first.type();
    if (this_type.id() == ID_pointer) {
#ifdef DEBUG
      std::cout << "Overriding pointer type" << std::endl;
#endif
      this_type = unsignedbv_typet(config.ansi_c.pointer_width);
    }

    if (expr_type == nil_typet()) {
      expr_type = this_type;
    } else {
      expr_type = join_types(expr_type, this_type);
    }
  }

  assert(to_bitvector_type(expr_type).get_width()>0);


  // Now set the initial values of the all the variables...
  for (std::map<exprt, int>::iterator it = values.begin();
       it != values.end();
       ++it) {
    program.assign(it->first, from_integer(it->second, expr_type));
  }

  // Now unwind the loop as many times as we need to.
  for (int i = 0; i < num_unwindings; i++) {
    program.append(loop_body);
  }

  // Now build the polynomial for this point and assert it fits.
  exprt rhs = nil_exprt();

  for (std::set<std::pair<expr_listt, exprt> >::iterator it = coefficients.begin();
       it != coefficients.end();
       ++it) {
    int concrete_value = 1;

    for (expr_listt::const_iterator e_it = it->first.begin();
         e_it != it->first.end();
         ++e_it) {
      exprt e = *e_it;

      if (e == loop_counter) {
        concrete_value *= num_unwindings;
      } else {
        std::map<exprt, int>::iterator v_it = values.find(e);

        if (v_it != values.end()) {
          concrete_value *= v_it->second;
        }
      }
    }

    // OK, concrete_value now contains the value of all the relevant variables
    // multiplied together.  Create the term concrete_value*coefficient and add
    // it into the polynomial.
    typecast_exprt cast(it->second, expr_type);
    exprt term = mult_exprt(from_integer(concrete_value, expr_type), cast);

    if (rhs.is_nil()) {
      rhs = term;
    } else {
      rhs = plus_exprt(rhs, term);
    }
  }

  exprt overflow_expr;
  overflow.overflow_expr(rhs, overflow_expr);

  program.add_instruction(ASSUME)->guard = not_exprt(overflow_expr);

  rhs = typecast_exprt(rhs, target.type());

  // We now have the RHS of the polynomial.  Assert that this is equal to the
  // actual value of the variable we're fitting.
  exprt polynomial_holds = equal_exprt(target, rhs);

  // Finally, assert that the polynomial equals the variable we're fitting.
  goto_programt::targett assumption = program.add_instruction(ASSUME);
  assumption->guard = polynomial_holds;
}
开发者ID:lihaol,项目名称:cbmc,代码行数:97,代码来源:polynomial_accelerator.cpp


注:本文中的std::map::begin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。