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


C++ Accumulator类代码示例

本文整理汇总了C++中Accumulator的典型用法代码示例。如果您正苦于以下问题:C++ Accumulator类的具体用法?C++ Accumulator怎么用?C++ Accumulator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: _checkBranchesTermination

void Accumulator::_checkBranchesTermination(Accumulator const& consequence
                                          , Accumulator const& alternative)
{
    if (consequence._terminated() || alternative._terminated()) {
        warning::oneOrTwoBranchesTerminated(*consequence._term_pos_or_nul_if_not_term
                                          , *alternative._term_pos_or_nul_if_not_term);
    }
}
开发者ID:neuront,项目名称:stekin,代码行数:8,代码来源:accumulator.cpp

示例2: main

int main()
{
	Accumulator acc;
	acc.add(5); // add 5 to the accumulator
	reset(acc); // reset the accumulator to 0
	
	cout << acc.m_value;

	return 0;
}
开发者ID:MPPECS,项目名称:C_plusplus_Lab,代码行数:10,代码来源:friend_function.cpp

示例3: report

 void report(char const* name, long const repeats)
 {
     std::cout.precision(10);
     std::cout << name << ": ";
     for (int i = 0; i < (20-int(strlen(name))); ++i)
         std::cout << ' ';
     std::cout << std::fixed << test::measure<Accumulator>(repeats) << " [s] ";
     Accumulator acc; 
     acc.benchmark(); 
     std::cout << std::hex << "{checksum: " << acc.val << "}";
     std::cout << std::flush << std::endl;
 }
开发者ID:Naios,项目名称:CxxFunctionBenchmark,代码行数:12,代码来源:measure.hpp

示例4: test

/// Specialization of test that tests Real
inline void test(const Real& A, const Real& B, Accumulator& Result)
{
    const Real abs_A = fabs(A);
    const Real abs_B = fabs(B);
    const Real threshold = 10*std::numeric_limits<Real>::epsilon();
    if(abs_A < threshold && abs_B < threshold)
    {
        Result.ulps(ceil(fabs(abs_B - abs_A) / threshold));
    }
    else
    {
        Result.ulps(std::fabs(boost::math::float_distance(A, B)));
    }
};
开发者ID:krishnangv,项目名称:coolfluid3,代码行数:15,代码来源:Difference.hpp

示例5: SoundFileSource

void
Talk::cmd_load(mrs_string fname, mrs_natural lineSize)
{
  cout << "cmd_load called" << endl;

  src_ = new SoundFileSource("src");
  src_->updControl("mrs_string/filename", fname);
  fname_ = fname;
  src_->updControl("mrs_natural/inSamples", lineSize);
  AbsMax* absmax = new AbsMax("absmax");

  Series *series = new Series("plot");
  series->addMarSystem(src_);
  series->addMarSystem(absmax);


  mrs_natural hops = src_->getctrl("mrs_natural/size")->to<mrs_natural>() * src_->getctrl("mrs_natural/nChannels")->to<mrs_natural>() / src_->getctrl("mrs_natural/inSamples")->to<mrs_natural>() + 1;


  Accumulator* acc = new Accumulator("acc");
  acc->updControl("mrs_natural/nTimes", hops);
  acc->addMarSystem(series);



  realvec in(acc->getctrl("mrs_natural/inObservations")->to<mrs_natural>(),
             acc->getctrl("mrs_natural/inSamples")->to<mrs_natural>());

  realvec out(acc->getctrl("mrs_natural/onObservations")->to<mrs_natural>(),
              acc->getctrl("mrs_natural/onSamples")->to<mrs_natural>());



  acc->process(in,out);

  out.send(communicator_);



//   Util util;
//   fname_ = fname;
//   src_ = util.sfopen(fname, MRS_SF_READ);
//   if (src_ == NULL)
//     cout << "src_ = NULL" << endl;

//   if (src_ != NULL)			// File exists
//     {
//       src_->initWindow(lineSize, lineSize, 0, 0);
//       PlotExtractor pextractor(src_, src_->winSize());
//       fvec res(src_->iterations());
//       pextractor.extract(0, src_->iterations(), res);
//       res.send(communicator_);
//     }
//   else
//     {
//       fvec res(0);
//       res.send(communicator_);
//     }
}
开发者ID:Amos-zq,项目名称:marsyas,代码行数:59,代码来源:Talk.cpp

示例6: signatureHash

bool
CoinSpend::Verify(const Accumulator& a, const SpendMetaData &m) const {
	// Verify both of the sub-proofs using the given meta-data
	struct timeval tv0, tv1;
	double elapsed;

	gettimeofday(&tv0, NULL);

	bool result_cPoK   = commitmentPoK.Verify(serialCommitmentToCoinValue, accCommitmentToCoinValue);
	gettimeofday(&tv1, NULL);
	elapsed = (tv1.tv_sec  - tv0.tv_sec) +
	          (tv1.tv_usec - tv0.tv_usec) / 1e6;
	cout << "GNOSIS DEBUG: cPoK time: " << elapsed << endl;

	bool result_accPoK = accumulatorPoK.Verify(a, accCommitmentToCoinValue);
	tv0 = tv1;
	gettimeofday(&tv1, NULL);
	elapsed = (tv1.tv_sec  - tv0.tv_sec) +
	          (tv1.tv_usec - tv0.tv_usec) / 1e6;
	cout << "GNOSIS DEBUG: accPoK time: " << elapsed << endl;

	bool result_snSoK  = serialNumberSoK.Verify(coinSerialNumber, serialCommitmentToCoinValue, signatureHash(m));
	tv0 = tv1;
	gettimeofday(&tv1, NULL);
	elapsed = (tv1.tv_sec  - tv0.tv_sec) +
	          (tv1.tv_usec - tv0.tv_usec) / 1e6;
	cout << "GNOSIS DEBUG: snSoK time: " << elapsed << endl;

	return  (a.getDenomination() == this->denomination)
	        && result_cPoK
	        && result_accPoK
	        && result_snSoK;
}
开发者ID:Anoncoin,项目名称:anoncoin,代码行数:33,代码来源:CoinSpend.cpp

示例7: Verify

/** Verifies that a commitment c is accumulated in accumulator a
 */
bool AccumulatorProofOfKnowledge:: Verify(const Accumulator& a, const CBigNum& valueOfCommitmentToCoin) const {
	CBigNum sg = params->accumulatorPoKCommitmentGroup.g;
	CBigNum sh = params->accumulatorPoKCommitmentGroup.h;

	CBigNum g_n = params->accumulatorQRNCommitmentGroup.g;
	CBigNum h_n = params->accumulatorQRNCommitmentGroup.h;

	//According to the proof, this hash should be of length k_prime bits.  It is currently greater than that, which should not be a problem, but we should check this.
	CHashWriter hasher(0,0);
	hasher << *params << sg << sh << g_n << h_n << valueOfCommitmentToCoin << C_e << C_u << C_r << st_1 << st_2 << st_3 << t_1 << t_2 << t_3 << t_4;

	CBigNum c = CBigNum(hasher.GetHash()); //this hash should be of length k_prime bits

	CBigNum st_1_prime = (valueOfCommitmentToCoin.pow_mod(c, params->accumulatorPoKCommitmentGroup.modulus) * sg.pow_mod(s_alpha, params->accumulatorPoKCommitmentGroup.modulus) * sh.pow_mod(s_phi, params->accumulatorPoKCommitmentGroup.modulus)) % params->accumulatorPoKCommitmentGroup.modulus;
	CBigNum st_2_prime = (sg.pow_mod(c, params->accumulatorPoKCommitmentGroup.modulus) * ((valueOfCommitmentToCoin * sg.inverse(params->accumulatorPoKCommitmentGroup.modulus)).pow_mod(s_gamma, params->accumulatorPoKCommitmentGroup.modulus)) * sh.pow_mod(s_psi, params->accumulatorPoKCommitmentGroup.modulus)) % params->accumulatorPoKCommitmentGroup.modulus;
	CBigNum st_3_prime = (sg.pow_mod(c, params->accumulatorPoKCommitmentGroup.modulus) * (sg * valueOfCommitmentToCoin).pow_mod(s_sigma, params->accumulatorPoKCommitmentGroup.modulus) * sh.pow_mod(s_xi, params->accumulatorPoKCommitmentGroup.modulus)) % params->accumulatorPoKCommitmentGroup.modulus;

	CBigNum t_1_prime = (C_r.pow_mod(c, params->accumulatorModulus) * h_n.pow_mod(s_zeta, params->accumulatorModulus) * g_n.pow_mod(s_epsilon, params->accumulatorModulus)) % params->accumulatorModulus;
	CBigNum t_2_prime = (C_e.pow_mod(c, params->accumulatorModulus) * h_n.pow_mod(s_eta, params->accumulatorModulus) * g_n.pow_mod(s_alpha, params->accumulatorModulus)) % params->accumulatorModulus;
	CBigNum t_3_prime = ((a.getValue()).pow_mod(c, params->accumulatorModulus) * C_u.pow_mod(s_alpha, params->accumulatorModulus) * ((h_n.inverse(params->accumulatorModulus)).pow_mod(s_beta, params->accumulatorModulus))) % params->accumulatorModulus;
	CBigNum t_4_prime = (C_r.pow_mod(s_alpha, params->accumulatorModulus) * ((h_n.inverse(params->accumulatorModulus)).pow_mod(s_delta, params->accumulatorModulus)) * ((g_n.inverse(params->accumulatorModulus)).pow_mod(s_beta, params->accumulatorModulus))) % params->accumulatorModulus;

	bool result_st1 = (st_1 == st_1_prime);
	bool result_st2 = (st_2 == st_2_prime);
	bool result_st3 = (st_3 == st_3_prime);

	bool result_t1 = (t_1 == t_1_prime);
	bool result_t2 = (t_2 == t_2_prime);
	bool result_t3 = (t_3 == t_3_prime);
	bool result_t4 = (t_4 == t_4_prime);

	bool result_range = ((s_alpha >= -(params->maxCoinValue * CBigNum(2).pow(params->k_prime + params->k_dprime + 1))) && (s_alpha <= (params->maxCoinValue * CBigNum(2).pow(params->k_prime + params->k_dprime + 1))));

    return result_st1 && result_st2 && result_st3 && result_t1 && result_t2 && result_t3 && result_t4 && result_range;
}
开发者ID:ionomy,项目名称:ion,代码行数:37,代码来源:AccumulatorProofOfKnowledge.cpp

示例8: range_test

void range_test(IteratorT A, IteratorT LastA, IteratorT B, IteratorT LastB, Accumulator& Result)
{
    for(; A != LastA && B != LastB; ++A, ++B)
        test(*A, *B, Result);

    Result.exact(A == LastA && B == LastB);
};
开发者ID:krishnangv,项目名称:coolfluid3,代码行数:7,代码来源:Difference.hpp

示例9: ReadHipTycFile

int ReadHipTycFile(Accumulator &accu) {
  int count = 0;
  FILE *f;
  const char *fname = "HipTyc";
  f = fopen(fname,"r");
  if (f == 0) {
    fprintf(stderr,"Could not open file \"%s\".\n",fname);
    exit(-1);
  }

  int hip,tyc1,tyc2,tyc3;
  char cids[32];
  char sp[256];
  int mag,b_v,VarFlag;
  double ra,dec,Plx,pm_ra,pm_dec;
  while (14==fscanf(f,"%d%d%d%d%s%d%lf%lf%lf%lf%lf%d%d%s",
                    &hip,&tyc1,&tyc2,&tyc3,cids,&VarFlag,
                    &ra,&dec,&Plx,&pm_ra,&pm_dec,&mag,&b_v,sp)) {
      const int rc = accu.addStar(tyc1,tyc2,tyc3,hip,
                                  cids[0]=='?'?"":cids,
                                  ra, // degrees
                                  dec, // degrees
                                  pm_ra,pm_dec,0.001*mag,0.001*b_v,
                                  Plx,sp[0]=='?'?"":sp);
      if (rc < 0) {
          // never mind: propably no magnitude for Hiparcos star
//        fprintf(stderr,"File \"%s\", record %d: Error 13 %d %d \"%s\"\n",
//                fname,count,rc,hip,sp);
//        exit(-1);
      }
    count++;
  }
  fclose(f);
  return count;
}
开发者ID:EvilTosha,项目名称:Stellarium-GSoC12,代码行数:35,代码来源:MakeCombinedCatalogue.C

示例10: return

bool
CoinSpend::Verify(const Accumulator& a) const {
    // Verify both of the sub-proofs using the given meta-data
    return  (a.getDenomination() == this->denomination)
            && commitmentPoK.Verify(serialCommitmentToCoinValue, accCommitmentToCoinValue)
            && accumulatorPoK.Verify(a, accCommitmentToCoinValue)
            && serialNumberSoK.Verify(coinSerialNumber, serialCommitmentToCoinValue, signatureHash());
}
开发者ID:Evan-R,项目名称:libzerocoin,代码行数:8,代码来源:CoinSpend.cpp

示例11: vector_test

void vector_test(const Eigen::Matrix<Real, NbRows, NbCols>& A, const Eigen::Matrix<Real, NbRows, NbCols>& B, Accumulator& Result)
{
    for(int i = 0, k = 0; i != A.rows() && k != B.rows(); ++i, ++k)
        for(int j = 0, l = 0; j != A.cols() && l != B.cols(); ++j, ++l)
            test(A(i, j), B(k, l), Result);

    Result.exact(A.rows() == B.rows() && A.cols() == B.cols());
};
开发者ID:krishnangv,项目名称:coolfluid3,代码行数:8,代码来源:Difference.hpp

示例12: main

int main() {
    Accumulator accumulator;
    
    accumulator.add(10);
    accumulator.add(20);
    accumulator.add(30);
    accumulator.add(40);
    accumulator.add(50);
    
    //Use function call operators
	cout << "Total is: " << accumulator() << endl;

	int total = 0;
    accumulator(&total);
    cout << "Total is: " << total << endl;
    
    return 0;
}
开发者ID:andrewbolster,项目名称:cppqubmarch2013,代码行数:18,代码来源:main.cpp

示例13: check_rows

//well defined rows checker
void horizontal_alignment::check_rows(Accumulator &Accumulate_Issues, vector<widget> &Dialog_controllers)
{
	int i = 0, j = 0;
	auto n = Dialog_controllers.size();

	vector<widget> issue;

	// check all widgets
	for (i = 0; i < n; i++)
	{
		for (j = i + 1; j < n; j++)
		{
			// no issue if one widget is pushbutton named "..."
			if(!((Dialog_controllers[i].Get_type() == L"PUSHBUTTON") &&
				(Dialog_controllers[i].Get_name() == L"..." ||
				(Dialog_controllers[i].Get_bottom() - Dialog_controllers[i].Get_top() <= 10 || Dialog_controllers[i].Get_right() - Dialog_controllers[i].Get_left() <= 10)) ||

				(Dialog_controllers[j].Get_type() == L"PUSHBUTTON" &&
				(Dialog_controllers[j].Get_name() == L"..." ||
				(Dialog_controllers[j].Get_bottom() - Dialog_controllers[j].Get_top() <= 10 || Dialog_controllers[j].Get_right() - Dialog_controllers[j].Get_left() <= 10)))))
			{
				
				if (Dialog_controllers[i].Get_deep() == Dialog_controllers[j].Get_deep())
				// verif if widgets are on the same level
				{
					// verif if widgets are close 
					if (if_close(&Dialog_controllers[i], &Dialog_controllers[j]) &&
						if_same_size(&Dialog_controllers[i], &Dialog_controllers[j]) &&
						!if_cross_line(&Dialog_controllers[i], &Dialog_controllers[j], Dialog_controllers))
					{
						// check for wrong alignment
						bool valid = if_not_aligned(&Dialog_controllers[i], &Dialog_controllers[j]);

						if (valid == true)
						{

							// increase the nr of issues for this type
							nrissues_rows++;

							issue.push_back(Dialog_controllers[i]);
							issue.push_back(Dialog_controllers[j]);

							// create issue obj
							unique_ptr < Issue > pointer = make_unique < horizontal_alignment_issue >(issue);

							// push issue 
							Accumulate_Issues.push_issue(move(pointer));

							issue.clear();

						}
					}
				}
			}
		}
	}
}
开发者ID:ducu34,项目名称:Resource-file-checker,代码行数:58,代码来源:horizontal_alignment.cpp

示例14: hammer

    void hammer(long const repeats)
    {
        // Strategy: because the sum in an accumulator after each call
        // depends on the previous value of the sum, the CPU's pipeline
        // might be stalled while waiting for the previous addition to
        // complete.  Therefore, we allocate an array of accumulators,
        // and update them in sequence, so that there's no dependency
        // between adjacent addition operations.
        //
        // Additionally, if there were only one accumulator, the
        // compiler or CPU might decide to update the value in a
        // register rather that writing it back to memory.  we want each
        // operation to at least update the L1 cache.  *** Note: This
        // concern is specific to the particular application at which
        // we're targeting the test. ***

        // This has to be at least as large as the number of
        // simultaneous accumulations that can be executing in the
        // compiler pipeline.  A safe number here is larger than the
        // machine's maximum pipeline depth. If you want to test the L2
        // or L3 cache, or main memory, you can increase the size of
        // this array.  1024 is an upper limit on the pipeline depth of
        // current vector machines.
        
        const std::size_t number_of_accumulators = 1024;
        live_code = 0; // reset to zero

        Accumulator a[number_of_accumulators];
        
        for (long iteration = 0; iteration < repeats; ++iteration)
        {
            for (Accumulator* ap = a;  ap < a + number_of_accumulators; ++ap)
            {
                ap->benchmark();
            }
        }

        // Accumulate all the partial sums to avoid dead code
        // elimination.
        for (Accumulator* ap = a; ap < a + number_of_accumulators; ++ap)
        {
            live_code += ap->val;
        }
    }
开发者ID:Naios,项目名称:CxxFunctionBenchmark,代码行数:44,代码来源:measure.hpp

示例15: log

// accumulate statistics
void DTAccumulator::accumulate(Alignment *alignment, MatrixBase<float> &mFeatures, bool bNumerator) {

	Accumulator *accumulator = NULL;
	double dOccupationTotal = 0.0;
	for(unsigned int t=0 ; t < alignment->getFrames() ; ++t) {
		FrameAlignment *frameAlignment = alignment->getFrameAlignment(t);
		VectorStatic<float> vFeatureVector = mFeatures.getRow(t);
		for(FrameAlignment::iterator it = frameAlignment->begin() ; it != frameAlignment->end() ; ++it) {
			double dOccupationNum = (*it)->dOccupation;
			HMMState *hmmState = m_hmmManager->getHMMState((*it)->iHMMState);
			// get Gaussian occupation from the mixture occupation
			
			// (1) compute the mixture likelihood (all Gaussian components)
			double dLikelihoodTotal = -DBL_MAX;
			int iGaussianComponents = hmmState->getMixture().getNumberComponents();
			double *dLikelihoodGaussian = new double[iGaussianComponents];
			for(int iGaussian = 0 ; iGaussian < iGaussianComponents ; ++iGaussian) {
				dLikelihoodGaussian[iGaussian] = hmmState->computeEmissionProbabilityGaussian(iGaussian,
					mFeatures.getRow(t).getData(),-1);
				dLikelihoodGaussian[iGaussian] += log(hmmState->getMixture()(iGaussian)->weight());
				dLikelihoodTotal = Numeric::logAddition(dLikelihoodTotal,dLikelihoodGaussian[iGaussian]);
			}
			// (2) accumulate statistics for each mixture component
			for(int iGaussian = 0 ; iGaussian < iGaussianComponents ; ++iGaussian) {
				
				double dProbGaussian = exp(dLikelihoodGaussian[iGaussian]-dLikelihoodTotal);
				assert(dProbGaussian >= 0.0);
				double dOccupationGaussian = dOccupationNum*dProbGaussian;
				unsigned int iKey = Accumulator::getPhysicalAccumulatorKey(hmmState->getId(),iGaussian);
				if (bNumerator) {
					accumulator = m_mAccumulatorNum[iKey];
				} else {
					accumulator = m_mAccumulatorDen[iKey];	
				}
				accumulator->accumulateObservation(vFeatureVector,dOccupationGaussian);
				dOccupationTotal += dOccupationGaussian;
			}
			delete [] dLikelihoodGaussian;
		}
	}	
	printf("accumulated: %12.6f\n",dOccupationTotal);
}
开发者ID:nlphacker,项目名称:bavieca,代码行数:43,代码来源:DTAccumulator.cpp


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