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


C++ array::size方法代码示例

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


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

示例1: getBScaleFactor

double BTagWeight::getBScaleFactor(const JetPointer jet, double uncertaintyFactor) const {
	const boost::array<double, 14> SFb_error = { { 0.0295675, 0.0295095, 0.0210867, 0.0219349, 0.0227033, 0.0204062,
			0.0185857, 0.0256242, 0.0383341, 0.0409675, 0.0420284, 0.0541299, 0.0578761, 0.0655432 } };

	const boost::array<double, 14> ptbins = { { 30, 40, 50, 60, 70, 80, 100, 120, 160, 210, 260, 320, 400, 500 } };

	double SFb(0);
	double sf_error(0);
	//these numbers are for CSVM only
	double pt = jet->pt();
	if (pt < 30) {
		SFb = 0.6981 * (1. + 0.414063 * 30) / (1. + 0.300155 * 30);
		sf_error = 0.12;
	} else if (pt > 670) {
		SFb = 0.6981 * (1. + 0.414063 * 670) / (1. + 0.300155 * 670);
		//use twice the uncertainty
		sf_error = 2 * SFb_error[SFb_error.size() - 1];
	} else {
		SFb = 0.6981 * (1. + 0.414063 * pt) / (1. + 0.300155 * pt);
		unsigned int ptbin(0);
		for (unsigned int bin = 0; bin < ptbins.size() + 1; ++bin) {
			double upperCut = bin + 1 < ptbins.size() ? ptbins.at(bin + 1) : 670.;
			double lowerCut = ptbins.at(bin);

			if (pt > lowerCut && pt <= upperCut) {
				ptbin = bin;
				break;
			}
		}
		sf_error = SFb_error.at(ptbin);
	}
	SFb += sf_error * Globals::BJetSystematic * uncertaintyFactor;
	return SFb;
}
开发者ID:nikberry,项目名称:AnalysisSoftware,代码行数:34,代码来源:BTagWeight.cpp

示例2: if

    void serialize_vc6(SF::Archive & ar, boost::array<T, N> & a, const unsigned int)
    {
        if (ar.isRead())
        {
            unsigned int count = 0;
            ar & count;

            RCF_VERIFY(
                count == a.size(), 
                RCF::Exception(RCF::_RcfError_RcfError_ArraySizeMismatch(a.size(), count)));

            for (std::size_t i=0; i<a.size(); ++i)
            {
                ar & a[i];
            }
        }
        else if (ar.isWrite())
        {
            unsigned int count = a.size();
            ar & count;

            for (std::size_t i=0; i<a.size(); ++i)
            {
                ar & a[i];
            }
        }
    }
开发者ID:mkotsbak,项目名称:librcf-cpp,代码行数:27,代码来源:array.hpp

示例3: buffer

inline const_buffer_container_1 buffer(const boost::array<Pod_Type, N>& data,
    std::size_t max_size_in_bytes)
{
  return const_buffer_container_1(
      const_buffer(data.data(),
        data.size() * sizeof(Pod_Type) < max_size_in_bytes
        ? data.size() * sizeof(Pod_Type) : max_size_in_bytes));
}
开发者ID:Sukumi,项目名称:python-libtorrent,代码行数:8,代码来源:buffer.hpp

示例4: container_type

inline typename detail::buffer_types<Pod_Type>::container_type
buffer(boost::array<Pod_Type, N>& data, std::size_t max_size_in_bytes)
{
  typedef typename asio::detail::buffer_types<Pod_Type>::buffer_type
    buffer_type;
  typedef typename asio::detail::buffer_types<Pod_Type>::container_type
    container_type;
  return container_type(
      buffer_type(data.c_array(),
        data.size() * sizeof(Pod_Type) < max_size_in_bytes
        ? data.size() * sizeof(Pod_Type) : max_size_in_bytes));
}
开发者ID:Sukumi,项目名称:python-libtorrent,代码行数:12,代码来源:buffer.hpp

示例5: getBScaleFactor

double BTagWeight::getBScaleFactor(const Jet& jet, double uncertaintyFactor) const {
	const boost::array<double, 16> SFb_error = { {0.0554504,
			 0.0209663,
			 0.0207019,
			 0.0230073,
			 0.0208719,
			 0.0200453,
			 0.0264232,
			 0.0240102,
			 0.0229375,
			 0.0184615,
			 0.0216242,
			 0.0248119,
			 0.0465748,
			 0.0474666,
			 0.0718173,
			 0.0717567 } };

	const boost::array<double, 16> ptbins = { {20, 30, 40, 50, 60, 70, 80,100, 120, 160, 210, 260, 320, 400, 500, 600 } };

	double SFb(0);
	double sf_error(0);
	//these numbers are for CSVM only
	double pt = getSmearedJetPtScale(jet, 0)*jet.pt();
	if (pt < 20) {
		SFb = 0.726981*((1.+(0.253238*20))/(1.+(0.188389*20)));
		sf_error = 0.12;
	} else if (pt > 800) {
		SFb = 0.726981*((1.+(0.253238*800))/(1.+(0.188389*800)));
		//use twice the uncertainty
		sf_error = 2 * SFb_error[SFb_error.size() - 1];
	} else {
		SFb = 0.726981*((1.+(0.253238*pt))/(1.+(0.188389*pt)));
		unsigned int ptbin(0);
		for (unsigned int bin = 0; bin < ptbins.size() + 1; ++bin) {
			double upperCut = bin + 1 < ptbins.size() ? ptbins.at(bin + 1) : 800.;
			double lowerCut = ptbins.at(bin);

			if (pt > lowerCut && pt <= upperCut) {
				ptbin = bin;
				break;
			}
		}
		sf_error = SFb_error.at(ptbin);
	}
	SFb += sf_error * BJetSystematic_ * uncertaintyFactor;
	return SFb;
}
开发者ID:phy6phs,项目名称:NTupleProduction,代码行数:48,代码来源:BTagWeight.cpp

示例6: pow

		inline double operator-(Center<D> other) const
		{
			double d = 0;
			for(size_t i=0; i<coords.size(); ++i)
				d += pow(coords[i]-other[i], 2);
			return d;
		}
开发者ID:MathieuLeocmach,项目名称:colloids,代码行数:7,代码来源:center.hpp

示例7: FLOG

OSG::Action::ResultE
initAnimationsEnterFunc(OSG::Node *node)
{
    OSG::Action::ResultE    retVal  = OSG::Action::Continue;
    OSG::GlobalsAttachment *globals = dynamic_cast<OSG::GlobalsAttachment *>(
                                          node->findAttachment(OSG::GlobalsAttachment::getClassType()));

    if(globals == NULL)
        return retVal;

    OSG::GlobalsAttachment::MFElementsType::const_iterator eIt  = globals->getMFElements()->begin();
    OSG::GlobalsAttachment::MFElementsType::const_iterator eEnd = globals->getMFElements()->end  ();

    for(; eIt != eEnd; ++eIt)
    {
        OSG::AnimTemplate *animTmpl = dynamic_cast<OSG::AnimTemplate *>(*eIt);

        if(animTmpl == NULL)
            continue;

        for(OSG::UInt32 i = 0; i < animNames.size(); ++i)
        {
            if(animNames[i] == animTmpl->getName())
            {
                FLOG(("instantiating anim %s\n", animNames[i].c_str()));
                g->anims    [i] = animTmpl->instantiate(node);
                g->anims    [i]->setWeight(0.f);
                g->animState[i] = AnimOff;
            }
        }
    }

    return retVal;
}
开发者ID:vossg,项目名称:OpenSGDevMaster,代码行数:34,代码来源:character.cpp

示例8: gain_interp

static double gain_interp(double gain, boost::array<double, 17> db_vector, boost::array<double, 17> volts_vector) {
    double volts;
    gain = uhd::clip<double>(gain, db_vector.front(), db_vector.back()); //let's not get carried away here

    boost::uint8_t gain_step = 0;
    //find which bin we're in
    for(size_t i = 0; i < db_vector.size()-1; i++) {
        if(gain >= db_vector[i] && gain <= db_vector[i+1]) gain_step = i;
    }

    //find the current slope for linear interpolation
    double slope = (volts_vector[gain_step + 1] - volts_vector[gain_step])
                / (db_vector[gain_step + 1] - db_vector[gain_step]);

    //the problem here is that for gains approaching the maximum, the voltage slope becomes infinite
    //i.e., a small change in gain requires an infinite change in voltage
    //to cope, we limit the slope

    if(slope == std::numeric_limits<double>::infinity())
        return volts_vector[gain_step];

    //use the volts per dB slope to find the final interpolated voltage
    volts = volts_vector[gain_step] + (slope * (gain - db_vector[gain_step]));

    UHD_LOGV(often) << "Gain interp: gain: " << gain << ", gain_step: " << int(gain_step) << ", slope: " << slope << ", volts: " << volts << std::endl;

    return volts;
}
开发者ID:Gabotero,项目名称:UHD,代码行数:28,代码来源:db_tvrx.cpp

示例9: getPileUpHistogram

// for background Summer11 MC samples
void EventWeightProvider::generate_observedPileUp2011_weights(void){

    if( currentReweightingModel == observedPileUp2011 ) return;

    boost::shared_ptr<TH1D> estimatedPileUp = getPileUpHistogram(observedPUdistfile);

    const boost::array<double, 35> npu_probs = {{     1.45346E-01,    6.42802E-02,    6.95255E-02,    6.96747E-02,
      6.92955E-02,    6.84997E-02,    6.69528E-02,    6.45515E-02,    6.09865E-02,    5.63323E-02,    5.07322E-02,
      4.44681E-02,    3.79205E-02,    3.15131E-02,    2.54220E-02,    2.00184E-02,    1.53776E-02,    1.15387E-02,
      8.47608E-03,    6.08715E-03,    4.28255E-03,    2.97185E-03,    2.01918E-03,    1.34490E-03,    8.81587E-04,
      5.69954E-04,    3.61493E-04,    2.28692E-04,    1.40791E-04,    8.44606E-05,    5.10204E-05,    3.07802E-05,
      1.81401E-05,    1.00201E-05,    5.80004E-06
    }};

    double s = 0.0;
    for (unsigned int npu = 0; npu < npu_probs.size(); ++npu) {
        double npu_estimated = estimatedPileUp->GetBinContent(estimatedPileUp->GetXaxis()->FindBin(npu));
        pileUpWeights[npu] = npu_estimated / npu_probs[npu];
        s += npu_estimated;
    }
    // normalize weights such that the total sum of weights over thw whole sample is 1.0, i.e., sum_i  result[i] * npu_probs[i] should be 1.0 (!)
    for (unsigned int npu = 0; npu < pileUpWeights.size(); ++npu) {
        pileUpWeights[npu] /= s;
    }

    currentReweightingModel = observedPileUp2011;
} 
开发者ID:koskot77,项目名称:OSUAnalysis,代码行数:28,代码来源:EventWeightProvider.cpp

示例10:

boost::array<double, NWEIGHTSSIZE> EventWeightProvider::generateWeights(
		const boost::array<double, NWEIGHTSSIZE> inputMC) {
	boost::array<double, NWEIGHTSSIZE> weights;

	double s = 0.0;

	for (unsigned int npu = 0; npu < inputMC.size(); ++npu) {
		if (npu >= (unsigned int) estimatedPileUp->GetNbinsX())
			break;
		DATAdistribution[npu] = estimatedPileUp->GetBinContent(estimatedPileUp->GetXaxis()->FindBin(npu));
		if (inputMC[npu] != 0)
			weights[npu] = DATAdistribution[npu] / inputMC[npu];
		else
			weights[npu] = 0;
		s += DATAdistribution[npu];
	}
	/**
	 * normalize weights such that the total sum of weights over thw whole sample is 1.0,
	 * i.e., sum_i  result[i] * npu_probs[i] should be 1.0 (!)
	 */
	for (unsigned int npu = 0; npu < pileUpWeights.size(); ++npu) {
		weights[npu] /= s;
	}

	return weights;
}
开发者ID:nikberry,项目名称:AnalysisSoftware,代码行数:26,代码来源:EventWeightProvider.cpp

示例11: trial

bool trial(const backpropSettings& bSettings, const boost::array< boost::array<float, inputWidth>, numTrials >& cTrials, const boost::array< boost::array<float, outputWidth>, numTrials >& cResults)
{
	size_t midWidth = (inputWidth + outputWidth);
	while ((midWidth & 15) != 0) { ++midWidth; };
	boost::array<size_t, 3> layers = {{inputWidth , midWidth , outputWidth}};

	std::cout << "dimensions= " << inputWidth << "," << midWidth << "," << outputWidth << "\nnumTrials= " << cTrials.size() << "\n";

	//boost::array<size_t, 2> layers = {{16 , 2}};
	neuralNet cNet(layers.begin(), layers.end());

	backpropNet bpNet(cNet, bSettings);
	bpNet.randomizeWeights();

	double _MSE = 1.0;
	double MSE = 0.0;
	double numTrials = 0.0;
	boost::timer cTimer;
	for (size_t iEpoch = 0; iEpoch < 3000; ++iEpoch)
	{
		// determine an order that we intend to visit the trials:
		std::vector<size_t> order(cTrials.size());
		for (size_t iTurn = 0; iTurn != order.size(); ++iTurn) { order[iTurn] = iTurn; }
		std::random_shuffle(order.begin(), order.end());

		// jitter:
		if ((iEpoch % 1000) == 0)
		{
			bpNet.jitterNetwork();
		}

		// perform trials:
		for (size_t iNTrial = 0; iNTrial != order.size(); ++iNTrial)
		{
			size_t iTrial = order[iNTrial];

			bpNet.getNeuralNet().feedForward(cTrials[iTrial].begin());
			MSE += bpNet.backPropagate(cResults[iTrial].begin());
			assert(MSE == MSE);
			numTrials += 1.0;
			bpNet.updateWeights();
		}


		// debug:
		if ((iEpoch+1) % 100 == 0)
		{
			//rankedNet.updateWeights();
			_MSE = MSE/numTrials;
			std::cout << std::setw(4) << iEpoch << " " << _MSE << "\n";
			MSE = 0.0;
			numTrials = 0.0;
		}
	}

	std::cout << "test " << ((_MSE<0.05)?"passed":"FAILED") << "! Elapsed time = " << cTimer.elapsed() << "\n";
	return _MSE<0.05;
};
开发者ID:ubermouser,项目名称:pokemonAI,代码行数:58,代码来源:networkXorTest.cpp

示例12: initInternal

 static void initInternal(
   boost::array< float, array_size > &_dest,
   float total_time,
   const std::map< float, float > &_sorted
 ) {
   std::map< float, float >::const_iterator previous = sorted.begin();
   std::map< float, float >::const_iterator current = sorted.begin();
   current++;
   std::map< float, float >::const_iterator end = sorted.end();
   int index;
   for( ; current != end; previous = current, current++ ) {
     // y = ax + b
     float a = ( current->y - previous->y ) / ( current->x - previous->x );
     float b = -a * current->x + current->y;
     for( index = 0; index != _dest.size(); index++ ) {
       double current_time = total_time * index / _dest.size();
       _dest[ index ] = a * current_time + b;
     }
   }
 }
开发者ID:Fadis,项目名称:harps,代码行数:20,代码来源:vector.hpp

示例13: subscribe

		void stress_subscriber::subscribe()
		{
			const subject* const next_subject = &subjects[ random( 0, subjects.size()-1 ) ];

			if ( subscriptions_.find( next_subject ) != subscriptions_.end() )
			{
				return next_action_impl();
			}

			subscriptions_.insert( next_subject );
			open_responses_.insert( next_subject );
			root_.subscribe( shared_from_this(), next_subject->name_ );
		}
开发者ID:TorstenRobitzki,项目名称:Sioux,代码行数:13,代码来源:stress_subscriber.cpp

示例14: main

int main()
{
  //const boost::array<int,3> v = { 0,1 }; //Does compile: too few elements is not checked in assignment
  //const boost::array<int,3> v = { 0,1,2,3 }; //Does not compile: too many elements is checked in assignment

  //Note: at around 2013-05-01, v needed to be initialized with double braces:
  //  const boost::array<int,3> v = {{ 0,1,2 }};
  const boost::array<int,3> v = { 0,1,2 };

  //static_assert(v.size() == 3,""); //Not allowed, v.size() is not a constexpr
  assert(v.size() == 3);
  assert(v[1] == 1);
}
开发者ID:RLED,项目名称:ProjectRichelBilderbeek,代码行数:13,代码来源:main.cpp

示例15: read_block_impl_

static block_t* read_block_impl_( ::tbb::flow_control* flow = NULL )
{
    static boost::array< block_t, 3 > blocks;
    static boost::optional< block_t::pair_t > last;
    static comma::uint32 block_id = 0;
    block_t::pairs_t* points = new block_t::pairs_t;
    while( true ) // quick and dirty, only if --discard
    {
        static comma::csv::input_stream< input_t > istream( std::cin, csv );
        points->clear();
        while( true )
        {
            if( last )
            {
                block_id = last->first.block;
                points->push_back( *last );
                last.reset();
            }
            if( is_shutdown || std::cout.bad() || std::cin.bad() || std::cin.eof() )
            {
                if( bursty_reader ) { bursty_reader->stop(); } // quick and dirty, it sucks...
                if( flow ) { flow->stop(); }
                break;
            }
            const input_t* p = istream.read();
            if( !p ) { break; }
            std::string line;
            if( csv.binary() )
            {
                line.resize( csv.format().size() );
                ::memcpy( &line[0], istream.binary().last(), csv.format().size() );
            }
            else
            {
                line = comma::join( istream.ascii().last(), csv.delimiter );
            }
            last = std::make_pair( *p, line );
            if( p->block != block_id ) { break; }
        }
        for( unsigned int i = 0; i < blocks.size(); ++i )
        {
            if( !blocks[i].empty ) { continue; }
            blocks[i].clear();
            blocks[i].id = block_id;
            blocks[i].points.reset( points );
            blocks[i].empty = false;
            return &blocks[i];
        }
    }
}
开发者ID:acfr,项目名称:snark,代码行数:50,代码来源:points-foreground-partitions.cpp


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