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


C++ Algebra类代码示例

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


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

示例1: assert

void AlgebraManager::matchingOperators(const int algId,
                                       const ListExpr arguments,
                       vector< pair< pair<int,int>, ListExpr> >& result){
  assert( (algId>0) && (algId<(int)algebra.size()) ); // 0 is an invalid algId!
  ListExpr typeError = nl->SymbolAtom(Symbol::TYPEERROR());
  Algebra* alg = algebra[algId];
  if(alg!=0){
    for(int o=0 ; o<alg->GetNumOps() ; o++){
      Operator* op = alg->GetOperator(o);
      try{
          ListExpr res = op->CallTypeMapping(arguments);
         // cout << "Check finished" << endl << endl;
          if(!nl->Equal(res,typeError)){
            pair<int, int> p1(algId,o);
            pair<pair<int, int>, ListExpr> p(p1, res);
            result.push_back(p);
          }
      } catch (...){
          cerr << "Problem in Typemapping of operator " << op->GetName()
               << " in Algebra" << GetAlgebraName(algId) << endl;
          cerr << "Throws an exception when called with "
               << nl->ToString(arguments) << endl;
      }
    }
  }
}
开发者ID:awarematics,项目名称:SECONDO,代码行数:26,代码来源:AlgebraManager.cpp

示例2:

Operator*
AlgebraManager::GetOP( int algebraId, int opId )
{
  if(algebraId < 0 || algebraId >= (int)algebra.size()){
    return 0;
  }
  Algebra* alg = algebra[algebraId];
  if(!alg){
    return 0;
  }
  return  alg->GetOperator(opId);
}
开发者ID:awarematics,项目名称:SECONDO,代码行数:12,代码来源:AlgebraManager.cpp

示例3: operator

 void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , Time dt ) const
 {
     typedef typename Coefficients::value_type value_type;
     algebra.for_each7( out , in , steps[0].m_v , steps[1].m_v , steps[2].m_v , steps[3].m_v , steps[4].m_v ,
             typename Operations::template scale_sum6< value_type , Time , Time , Time , Time >(
                     1.0 , dt * coef[0] , dt * coef[1] , dt * coef[2] , dt * coef[3] , dt * coef[4] ) );
 }
开发者ID:imos,项目名称:icfpc2015,代码行数:7,代码来源:adams_bashforth_call_algebra.hpp

示例4:

std::pair<Algebra, Algebra> Algebra::algDiv(const Algebra &D) const
/**
  Divide by D algebrically
  @param D :: Divisor
  @return Quotian + Remainder
 */
{
  Algebra Q;
  Algebra R;
  Acomp Tf = F;
  // std::cerr<<"AlgDiv:"<<std::endl;
  std::pair<Acomp, Acomp> QR = Tf.algDiv(D.F);
  if (!QR.first.isNull() && !QR.second.isNull()) {
    Q.setFunction(QR.first);
    R.setFunction(QR.second);
  }
  return std::pair<Algebra, Algebra>(Q, R);
}
开发者ID:nimgould,项目名称:mantid,代码行数:18,代码来源:Algebra.cpp

示例5:

R PPForest<L>::maxScore(const Algebra<R,L> &alg, size_type i, size_type j) const
{
	R down, over;

	if(j==0)
		return 0;

	if(isLeave(i))
	{
		over=maxScore(alg,rb(i),j-1);
		return alg.replace(label(i),0,label(i),over);
	}
	else
	{
		down=maxScore(alg,i+1,noc(i));
		over=maxScore(alg,rb(i),j-1);
		return alg.replace(label(i),down,label(i),over);
	}
}  
开发者ID:ElNando888,项目名称:vrna-hack,代码行数:19,代码来源:ppforest.t.cpp

示例6: GetAlgebraName

void AlgebraManager::findTMExceptions(const string& algName,
                                      const ListExpr argList,
                                      queue<pair<string,string> >& q,
                                      const bool print) {

   if(algName.size()==0){
     for(unsigned int a=1 ; a<algebra.size() ; a++){ // algId=0 is prohibited
       Algebra* alg = algebra[a];
       if(alg!=0){
          if(print){
              cout << "process algebra" << GetAlgebraName(a) << endl;
          }
          for(int o=0;o<alg->GetNumOps(); o++){
             Operator* op = alg->GetOperator(o);
             if(print){
               cout << "process operator " << op->GetName() << endl; 
             }  
             try{
               op->CallTypeMapping(argList);
             } catch(...){
               pair<string,string> p(GetAlgebraName(a), op->GetName());
               q.push(p);  
             }
          }
       }    
     }
   } else {
     int a = GetAlgebraId(algName);
     if(a<1){
        if(print){
          cout << "Algebra " << algName << " not found" << endl;
        }
        return;
     }
     if(print){
         cout << "process algebra" << GetAlgebraName(a) << endl;
     }
     Algebra* alg = algebra[a];
     for(int o=0;o<alg->GetNumOps(); o++){
        Operator* op = alg->GetOperator(o);
        if(print){
          cout << "process operator " << op->GetName() << endl; 
        }  
        try{
          op->CallTypeMapping(argList);
        } catch(...){
          pair<string,string> p(GetAlgebraName(a), op->GetName());
          q.push(p);  
        }
     }
   }
}
开发者ID:awarematics,项目名称:SECONDO,代码行数:52,代码来源:AlgebraManager.cpp

示例7: process

 void process(Algebra &algebra) const
 {
     Type a00 = algebra.getInput(0,0);
     Type result = (a00 & Type((uint16_t)0x00FF)) << 4;
     algebra.putOutput(0,0,result);
 }
开发者ID:PimenovAlexander,项目名称:corecvs,代码行数:6,代码来源:g12Buffer.cpp

示例8: for_each3

    void for_each3( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Iterator3 first3, Operation op , Algebra &algebra )
{
    for( ; first1 != last1 ; )
        algebra.for_each3( *first1++ , *first2++ , *first3++ , op );
}
开发者ID:AlexMioMio,项目名称:boost,代码行数:5,代码来源:nested_range_algebra.hpp

示例9: getMtrxVal

void Alignment<R,L,AL>::calculateGlobal(const PPForest<L> *ppfx, const PPForest<L> *ppfy, const Algebra<R,L> &alg, bool noSpeedup)
{
	assert(ppfx != NULL);
	assert(ppfy != NULL);

	Ulong m,n,h,cols;
	long i,k;
	Uint j,l,r;

	R score,h_score;

	// alloc space for the score matrix, backtrack structure  and , if wanted, for the calculation-order-matrix
	m_mtrxSize=ppfx->getNumCSFs()*ppfy->getNumCSFs();

	m_mtrx=new R[m_mtrxSize];
	m_rowStart=new Ulong[ppfx->getNumCSFs()];
	m_ppfx = new PPForest<L>(*ppfx);				// copy the ppforests
	m_ppfy = new PPForest<L>(*ppfy);
	m_alg=&alg;
	m_rnaAlg=NULL;
	m_localOptimum=alg.worst_score();


	// initialize variables
	m=ppfx->size();
	n=ppfy->size();
	cols=ppfy->getNumCSFs();

	m_rowStart[0]=0;
	for(h=1;h<ppfx->getNumCSFs();h++)
		m_rowStart[h]=m_rowStart[h-1]+cols;

	// align forests fx and fy

	// the easiest case .. 
	setMtrxVal(0,0,alg.empty());

	// align fx to the empty forest (fill first row of array)
	for(i=m-1;i>=0;i--)  // for all nodes in fx
	{
		for(j=1;j<=ppfx->getMaxLength(i);j++)  // for all non empty csfs induced by i
		{
			score = alg.del(ppfx->label(i),
				            getMtrxVal(ppfx->down(i),0),
				            getMtrxVal(ppfx->over(i,j),0));	  

			setMtrxVal(ppfx->indexpos(i,j),0,score);
		}
	}

	// align fy to the empty forest (fill first column of array)
	for(k=n-1;k>=0;k--)  // for all nodes in fx
	{
		for(l=1;l<=ppfy->getMaxLength(k);l++)  // for all non empty csfs induced by k
		{
			score = alg.insert(getMtrxVal(0,ppfy->down(k)),
					            ppfy->label(k),
					            getMtrxVal(0,ppfy->over(k,l)));

			setMtrxVal(0,ppfy->indexpos(k,l),score);
		}
	}

	// align the rest
	for(i=m-1;i>=0;i--)  // for all nodes in fx  
		for(k=n-1;k>=0;k--)  // for all nodes in fx
		        {
			        j=ppfx->getMaxLength(i);
				for(l=1;l<=ppfy->getMaxLength(k);l++)  // for all non empty csfs induced by k
				{
					// replace
		  
					score = alg.replace(ppfx->label(i),
							            getMtrxVal(ppfx->down(i),ppfy->down(k)),
							            ppfy->label(k),
							            getMtrxVal(ppfx->over(i,j),ppfy->over(k,l)));
					
					// delete				       
					if(ppfx->noc(i)==0 && !noSpeedup)  // no child
					  {
					    h_score = alg.del(ppfx->label(i),0,
							              getMtrxVal(ppfx->over(i,j),ppfy->indexpos(k,l)));

						score=alg.choice(score,h_score);
					  }
					else					  
					  {	
					    if(ppfx->rb(i)==0 && !noSpeedup) // no right brother
					      {
						h_score = alg.del(ppfx->label(i),
								  getMtrxVal(ppfx->down(i),ppfy->indexpos(k,l)),
								  0);
						
						score=alg.choice(score,h_score);
					      }
					    else
					      {
						h=k;               // h is the node where the suffix of the split begins		   					
						for(r=0;r<=l;r++)  // for all splits of fy
						  {
//.........这里部分代码省略.........
开发者ID:jrgreen7,项目名称:SMIRP,代码行数:101,代码来源:alignment.t.cpp

示例10: operator

 void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const DerivIn &dxdt , const StepStorage &steps , const Coefficients &coef , Time dt ) const
 {
     typedef typename Coefficients::value_type value_type;
     algebra.for_each3( out , in , dxdt , typename Operations::template scale_sum2< value_type , Time >( 1.0 , dt * coef[0] ) );
 }
开发者ID:AsKorysti,项目名称:anura,代码行数:5,代码来源:adams_moulton_call_algebra.hpp

示例11: catch

bool AlgebraManager::findOperator(const string& name,
                                  const ListExpr argList,
                                  ListExpr& resultList,
                                  int& algId,
                                  int& opId,
                                  int& funId){

   ListExpr typeError = nl->SymbolAtom(Symbol::TYPEERROR());

   NestedList* nl_orig = NList::getNLRef();
   NList::setNLRef(nl);

   int mode = 0;  // normal mode, search for matching arglist
   string algName ="";
   if(nl->HasLength(argList,2)){
     if(nl->IsEqual(nl->First(argList),"algebra")
        && nl->AtomType(nl->Second(argList)==SymbolType)){
        mode = 1; // search within a specific algebra
        algName = nl->SymbolValue(nl->Second(argList));
        stringutils::toLower(algName);
        if(algName=="all"){
           mode = 2; // search all algebras, return first hit
        }
     } 
   }
   for(unsigned int a=0;a<algebra.size();a++){
     Algebra* alg = algebra[a];
     if(alg!=0){
       string an = algebraNames[a];
       stringutils::toLower(an);
       if(mode==0 || mode==2 || an==algName){
         for(int o=0; o< alg->GetNumOps(); o++){
           Operator* op = alg->GetOperator(o);
           if(op->GetName() == name){
             if(mode==0){
               try{
                  ListExpr res = op->CallTypeMapping(argList);
                  if(!nl->Equal(res,typeError)){ //  appropriate operator found
                     algId = a;
                     opId = o;
                     funId = op->Select(argList);
                     resultList = res;
                     NList::setNLRef(nl_orig);
                     return true;
                  }
               } catch (...){
                  cerr << "Problem in Typemapping of operator " << op->GetName()
                       << " in Algebra" << GetAlgebraName(a) << endl;
                  cerr << "Throws an exception when called with "
                       << nl->ToString(argList) << endl;
               }
            } else { // mode <>0
                algId = a;
                opId = o;
                funId = 0;
                resultList = nl->TheEmptyList();
                NList::setNLRef(nl_orig);
                return true;
            }
          }
        }
      } // fitting algebra name
    }
  }
  algId = 0;
  opId = 0;
  resultList = nl->TheEmptyList();
  NList::setNLRef(nl_orig);
  return false;
}
开发者ID:awarematics,项目名称:SECONDO,代码行数:70,代码来源:AlgebraManager.cpp

示例12: operator

 void operator()( Algebra &algebra , S1 &s1 , S2 &s2 , S3 &s3 , S4 s4_array[7] , Op op ) const
 {
     algebra.for_each10( s1 , s2 , s3 , s4_array[0].m_v , s4_array[1].m_v , s4_array[2].m_v , s4_array[3].m_v , s4_array[4].m_v ,
             s4_array[5].m_v , s4_array[6].m_v , op );
 }
开发者ID:HRZaheri,项目名称:batch-informed-trees,代码行数:5,代码来源:generic_rk_call_algebra.hpp

示例13: progressiveAlign

void progressiveAlign(std::vector<RNAProfileAlignment*> &inputList, 
											std::vector<std::pair<double,RNAProfileAlignment*> > &resultList, const Score& score, const Options &options, bool anchored) {

		Algebra<double,RNA_Alphabet_Profile> *alg = NULL;
		AlgebraAffine<double,RNA_Alphabet_Profile> *alg_affine = NULL;

    if (options.has(Options::Affine)) {
			if (options.has(Options::CalculateDistance)) {
        alg_affine = new AffineDoubleDistProfileAlgebra(score);
			}
			else {
        alg_affine = new AffineDoubleSimiProfileAlgebra(score);
			}
		}
		else {
			// distance or similarity
			if (options.has(Options::CalculateDistance))
        alg = new DoubleDistProfileAlgebra(score);
			else
        alg = new DoubleSimiProfileAlgebra(score);
		}

    std::cout << "*** Calculation ***" << std::endl << std::endl;

    // create inputMapProfile to access a profile by an index value
    RNAProfileAliMapType inputMapProfile;
    std::vector<RNAProfileAlignment*>::const_iterator inpIt;
    long i = 1;
    for (inpIt=inputList.begin(); inpIt!=inputList.end(); inpIt++) {
        inputMapProfile[i]=*inpIt;
        i++;
    }
    inputList.clear();

    // create matrix for all against all comparison
		double bestScore;
		if (options.has(Options::Affine))
			bestScore = alg_affine->worst_score();
		else
			bestScore = alg->worst_score();
    Matrix<double> *score_mtrx = new Matrix<double>(inputMapProfile.size(),inputMapProfile.size());

    // set threshold for the clustering algorithm
    double threshold = 0; 
    if (options.has(Options::CalculateDistance))
        options.get(Options::ClusterThreshold, threshold, 20.0);
    else
        options.get(Options::ClusterThreshold, threshold, 0.7);
    std::cout << "clustering threshold is: " << threshold << std::endl;

    // set cutoff value for clustering
		double cutoff = 0;
    if (options.has(Options::CalculateDistance))
        options.get(Options::ClusterJoinCutoff, cutoff, 100.0);
    else
        options.get(Options::ClusterJoinCutoff, cutoff, 0.0);
    std::cout << "join clusters cutoff is: " << cutoff << std::endl << std::endl;

		bool topdown = options.has(Options::Topdown);
		//bool anchored = options.has(Options::Anchoring);
    bool local = options.has(Options::LocalSimilarity);
		bool printBT = options.has(Options::Backtrace);

    // generate dot file
		std::string clusterfilename = options.generateFilename(Options::Help,"_cluster.dot", "cluster.dot");  // use Help as dummy
    std::ofstream s;
    s.open(clusterfilename.c_str());
    s << "digraph forest" << std::endl << "{" << std::endl;

		// generate nodes for the input forests
	  RNAProfileAliMapType::iterator it;
    for (it = inputMapProfile.begin(); it!=inputMapProfile.end(); it++) {
        RNAProfileAlignment * f = it->second;

        s << "\"" << f->getName() << "\"" << "[label=\"" << f->getName() << "\"]" << std::endl;
        s << "\"" << f->getName() << "\"" << "[label=\"" << f->getName() << "\"]" << std::endl;
    }

		// compute all pairwise alignment scores
    // !! NOTE !! iterating through the map is ordered by key number
    // as i only calculate a triangle matrix this is a prerequisite
		long x = 0, y = 0;
		RNAProfileAlignment *f1 = NULL, *f2 = NULL;
    std::cout << "Computing all pairwise similarities" << std::endl;

    RNAProfileAliMapType::iterator it2;
    for (it=inputMapProfile.begin(); it!=inputMapProfile.end(); it++) {
        x = it->first;
        f1 = it->second;
        for (it2=inputMapProfile.begin(); it2->first<it->first; it2++) {
            y = it2->first;
            f2 = it2->second;

						if (options.has(Options::Affine)) {
							AlignmentAffine<double,RNA_Alphabet_Profile,RNA_Alphabet_Profile> * ali = new AlignmentAffine<double,RNA_Alphabet_Profile,RNA_Alphabet_Profile>(f1,f2,*alg_affine,topdown,anchored,local,printBT);
	            if (local)
		              score_mtrx->setAt(x-1,y-1,ali->getLocalOptimum());
			        else
				          score_mtrx->setAt(x-1,y-1,ali->getGlobalOptimumRelative());

//.........这里部分代码省略.........
开发者ID:linse,项目名称:RNAforester,代码行数:101,代码来源:progressive_align.cpp

示例14: testMultiplicationSquares

void testMultiplicationSquares(std::size_t noBits, DynamicElementStorageType lhsStorage, DynamicElementStorageType rhsStorage)
{
    Bitset activeBits;
    for(std::size_t i = 0; i < noBits; ++i)
        activeBits[std::rand() & MAX_K_VALUE] = true;

    Element lhs(activeBits, lhsStorage);

    // get a non-zero value
    Z2k value;
    while(value.getValue() == 0)
        value = Z2k( rand() & activeBits.to_ulong() );

    // get a coeff
    GaloisField coeff( rand() & 255 );

    lhs.setCoefficient(value, coeff);
    lhs.setCoefficient(Z2k(), coeff);


    Element rhs(lhs, rhsStorage);

    Element prod;
    algebra.multiply(lhs, rhs, prod);

    BOOST_CHECK_EQUAL(prod.isZero(), true);
}
开发者ID:thomasfannes,项目名称:gf2algebra,代码行数:27,代码来源:dynamicMultiplicationTest.cpp

示例15: h

            static Size Search3D (const System::Collection::Array<1,Vector<3,T> > &p, Size a, Size b)
            {
                Size c;
                for (c = 0; c == a || c == b; c++)
                    ;

                Hyperplane<3,T> h(CrossProduct(p[b]-p[a],p[c]-p[a]), p[a]);

                for (Size i = c + 1; i < p.Elements(); i++) 
                {
                    if (i != a && i != b && h.IsAbove(p[i]))
                    {
                        c = i;
                        h.Set(CrossProduct(p[b]-p[a],p[c]-p[a]), p[a]);
                    }
                }

                return c;
            }
开发者ID:odanek,项目名称:gc,代码行数:19,代码来源:ConvexHull.cpp


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