• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ vec类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: mid

inline vec mid(const vec&v, int start, int num){
  return v.segment(start, std::min(num, (int)(v.size()-start)));
}
开发者ID:Prokopp,项目名称:graphchi-cpp,代码行数:3,代码来源:eigen_wrapper.hpp


示例2: sort

inline void sort(vec & a){
  std::sort(a.data(), a.data()+a.size());
}
开发者ID:Prokopp,项目名称:graphchi-cpp,代码行数:3,代码来源:eigen_wrapper.hpp


示例3: buildConstraint

static
void buildConstraint(vec<Formula>& ps, vec<Int>& Cs, vec<Formula>& carry, vec<int>& base, int digit_no, vec<vec<Formula> >& out_digits, int max_cost)
{
    assert(ps.size() == Cs.size());

    if (FEnv::topSize() > max_cost) throw Exception_TooBig();
    /**
    pf("buildConstraint(");
    for (int i = 0; i < ps.size(); i++)
        pf("%d*%s ", Cs[i], (*debug_names)[index(ps[i])]);
    pf("+ %d carry)\n", carry.size());
    **/

    if (digit_no == base.size()){
        // Final digit, build sorter for rest:
        // -- add carry bits:
        for (int i = 0; i < carry.size(); i++)
            ps.push(carry[i]),
            Cs.push(1);
        out_digits.push();
        buildSorter(ps, Cs, out_digits.last());

    }else{
        vec<Formula>    ps_rem;
        vec<int>        Cs_rem;
        vec<Formula>    ps_div;
        vec<Int>        Cs_div;

        // Split sum according to base:
        int B = base[digit_no];
        for (int i = 0; i < Cs.size(); i++){
            Int div = Cs[i] / Int(B);
            int rem = toint(Cs[i] % Int(B));
            if (div > 0){
                ps_div.push(ps[i]);
                Cs_div.push(div);
            }
            if (rem > 0){
                ps_rem.push(ps[i]);
                Cs_rem.push(rem);
            }
        }

        // Add carry bits:
        for (int i = 0; i < carry.size(); i++)
            ps_rem.push(carry[i]),
            Cs_rem.push(1);

        // Build sorting network:
        vec<Formula> result;
        buildSorter(ps_rem, Cs_rem, result);

        // Get carry bits:
        carry.clear();
        for (int i = B-1; i < result.size(); i += B)
            carry.push(result[i]);

        out_digits.push();
        for (int i = 0; i < B-1; i++){
            Formula out = _0_;
            for (int j = 0; j < result.size(); j += B){
                int n = j+B-1;
                if (j + i < result.size())
                    out |= result[j + i] & ((n >= result.size()) ? _1_ : ~result[n]);
            }
            out_digits.last().push(out);
        }

        buildConstraint(ps_div, Cs_div, carry, base, digit_no+1, out_digits, max_cost); // <<== change to normal loop
    }
}
开发者ID:bytekid,项目名称:mkbtt,代码行数:71,代码来源:PbSolver_convertSort.C


示例4: optimizeBase

static
void optimizeBase(vec<Int>& seq, int carry_ins, vec<Int>& rhs, int cost, vec<int>& base, int& cost_bestfound, vec<int>& base_bestfound)
{
    if (cost >= cost_bestfound)
        return;

    // "Base case" -- don't split further, build sorting network for current sequence:
    int final_cost = 0;
    for (int i = 0; i < seq.size(); i++){
        if (seq[i] > INT_MAX)
            goto TooBig;
      #ifdef ExpensiveBigConstants
        final_cost += toint(seq[i]);
      #else
        int c; for (c = 1; c*c < seq[i]; c++);
        final_cost += c;
      #endif
        if (final_cost < 0)
            goto TooBig;
    }
    if (cost + final_cost < cost_bestfound){
        base.copyTo(base_bestfound);
        cost_bestfound = cost + final_cost;
    }
  TooBig:;

    /**/static int depth = 0;

    // <<== could count 1:s here for efficiency

    vec<Int> new_seq;
    vec<Int> new_rhs;
#ifdef PickSmallest
    int p = -1;
    for (int i = 0; i < seq.size(); i++)
        if (seq[i] > 1){ p = seq[i]; break; }
    if (p != -1){
#else
    //int upper_lim = (seq.size() == 0) ? 1 : seq.last(); // <<== Check that sqRoot is an 'int' (no truncation of 'Int')
    //for (int i = 0; i < (int)elemsof(primes) && primes[i] <= upper_lim; i++){
    for (int i = 0; i < (int)elemsof(primes); i++){
        int p    = primes[i];
#endif
        int rest = carry_ins;   // Sum of all the remainders.
        Int div, rem;

        /**/for (int n = depth; n != 0; n--) pf("  "); pf("prime=%d   carry_ins=%d\n", p, carry_ins);
        /**/for (int n = depth; n != 0; n--) pf("  "); pf("New seq:");
        for (int j = 0; j < seq.size(); j++){
            rest += toint(seq[j] % Int(p));
            div = seq[j] / Int(p);
            if (div > 0)
                //**/pf(" %d", div),
                new_seq.push(div);
        }
        /**/pf("\n");
        /**/for (int n = depth; n != 0; n--) pf("  "); pf("rest=%d\n", rest);

        /**/for (int n = depth; n != 0; n--) pf("  "); pf("New rhs:");
#ifdef AllDigitsImportant
        bool    digit_important = true;
#else
        bool    digit_important = false;
#endif
        for (int j = 0; j < rhs.size(); j++){
            div = rhs[j] / p;
            if (new_rhs.size() == 0 || div > new_rhs.last()){
                rem = rhs[j] % p;
                /**/pf(" %d:%d", div, rem),
                new_rhs.push(div);
                if (!(rem == 0 && rest < p) && !(rem > rest))
                    digit_important = true;
            }
            /* <<==
            om 'rhs' slutar på 0:a och 'rest' inte kan overflowa, då behövs inte det sorterande nätverket för 'rest' ("always TRUE")
            samma sak om 'rhs' sista siffra är strikt större än 'rest' ("never TRUE")
            */
        }
        /**/pf("\n\n");

        base.push(p);
        /**/depth++;
        optimizeBase(new_seq, rest/p, new_rhs, cost+(digit_important ? rest : 0), base, cost_bestfound, base_bestfound);
        /**/depth--;
        base.pop();

        new_seq.clear();
        new_rhs.clear();
    }
}


static
void optimizeBase(vec<Int>& seq, vec<Int>& rhs, int& cost_bestfound, vec<int>& base_bestfound)
{
    vec<int>    base;
    cost_bestfound = INT_MAX;
    base_bestfound.clear();
    optimizeBase(seq, 0, rhs, 0, base, cost_bestfound, base_bestfound);
}
开发者ID:bytekid,项目名称:mkbtt,代码行数:100,代码来源:PbSolver_convertSort.C


示例5: ggc_register_root_tab

void
ggc_register_root_tab (const struct ggc_root_tab* rt)
{
  if (rt)
    extra_root_vec.safe_push (rt);
}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:6,代码来源:ggc-common.c


示例6: addPb

void addPb(const vec<Formula>& ps, const vec<Int>& Cs_, vec<Formula>& out, int bits)
{
    assert(ps.size() == Cs_.size());
    vec<vec<Formula> >  pools;
    vec<Int>            Cs(Cs_.size());
    Int                 max_C = -1;
    for (int i = 0; i < Cs_.size(); i++){
        Cs[i] = Cs_[i];
        if (Cs[i] > max_C)
            max_C = Cs[i];
    }

    for (; max_C > 0; max_C >>= 1){
        pools.push();
        for (int i = 0; i < Cs.size(); i++){
            if ((Cs[i] & 1) != 0)
                pools.last().push(ps[i]);
            Cs[i] >>= 1;
        }
    }

    vec<Formula> carry;
    for (int p = 0; p < pools.size(); p++){
        vec<Formula>& pool = pools[p];
        carry.clear();

        if (p == bits){
            Formula overflow = _0_;
            for (; p < pools.size(); p++)
                for (int i = 0; i < pools[p].size(); i++)
                    overflow |= pools[p][i];
            out.push(overflow);
        }else if (pool.size() == 0)
            out.push(_0_);
        else{
            int head = 0;
            while (pool.size()-head >= 3){
                pool .push(FAs(pool[head], pool[head+1], pool[head+2]));
                carry.push(FAc(pool[head], pool[head+1], pool[head+2]));
                head += 3;
            }
            if (pool.size()-head == 2){
                pool .push(FAs(pool[head], pool[head+1], _0_));
                carry.push(FAc(pool[head], pool[head+1], _0_));
                head += 2;
            }
            assert(pool.size()-head == 1);
            out.push(pool[head]);
        }

        if (carry.size() > 0){
            if (p+1 == pools.size())
                pools.push();
            for (int i = 0; i < carry.size(); i++)
                pools[p+1].push(carry[i]);
        }
    }

    #if 0
    //DEBUG
    for (int p = 0; p < pools.size(); p++){
        printf("pool %d:", (1 << p));
        for (int i = 0; i < pools[p].size(); i++){
            printf(" ");
            dump(pools[p][i]);
        }
        printf("\n");
    }
    #endif
}
开发者ID:bakhansen,项目名称:service-technology.org,代码行数:70,代码来源:Hardware_adders.C


示例7: lexComp

static
Formula lexComp(vec<int>& num, vec<vec<Formula> >& digits) {
    assert(num.size() == digits.size());
    return lexComp(num.size(), num, digits); }
开发者ID:bytekid,项目名称:mkbtt,代码行数:4,代码来源:PbSolver_convertSort.C


示例8: head

inline vec head(const vec& v, int num){
  return v.head(num);
}
开发者ID:Prokopp,项目名称:graphchi-cpp,代码行数:3,代码来源:eigen_wrapper.hpp


示例9: tail

inline vec tail(const vec&v,  int num){
  return v.segment(v.size() - num, num);
}
开发者ID:Prokopp,项目名称:graphchi-cpp,代码行数:3,代码来源:eigen_wrapper.hpp


示例10: diag

inline mat diag(vec & v){
  return v.asDiagonal();
}
开发者ID:Prokopp,项目名称:graphchi-cpp,代码行数:3,代码来源:eigen_wrapper.hpp


示例11: transmiter

	transmiter()
	{
		Parser p(std::string("config.txt"));
		DPCCH_NBits=p.get_int("DPCCH_NBits");
		
		HS_DPCCH_NBits=p.get_int("HS_DPCCH_NBits");
		E_DPCCH_NBits=p.get_int("E_DPCCH_NBits");
		E_DPDCH1_NData=p.get_int("E_DPDCH1_NData");
		E_DPDCH2_NData=p.get_int("E_DPDCH2_NData");
		E_DPDCH3_NData=p.get_int("E_DPDCH3_NData");
		E_DPDCH4_NData=p.get_int("E_DPDCH4_NData");
		SF=p.get_int("SF");
		SF_EDPDCH2=p.get_int("SF_EDPDCH2");
		SF_EDPDCH3=p.get_int("SF_EDPDCH3");
		DPCCH_SLOT0=p.get_int("DPCCH_SLOT0");
		DPCCH_SLOT1=p.get_int("DPCCH_SLOT1");
		DPCCH_SLOT2=p.get_int("DPCCH_SLOT2");
		DPCCH_SLOT3=p.get_int("DPCCH_SLOT3");
		DPCCH_SLOT4=p.get_int("DPCCH_SLOT4");
		DPCCH_SLOT5=p.get_int("DPCCH_SLOT5");
		DPCCH_SLOT6=p.get_int("DPCCH_SLOT6");
		DPCCH_SLOT7=p.get_int("DPCCH_SLOT7");
		DPCCH_SLOT8=p.get_int("DPCCH_SLOT8");
		DPCCH_SLOT9=p.get_int("DPCCH_SLOT9");
		DPCCH_SLOT10=p.get_int("DPCCH_SLOT10");
		DPCCH_SLOT11=p.get_int("DPCCH_SLOT11");
		DPCCH_SLOT12=p.get_int("DPCCH_SLOT12");				
		DPCCH_SLOT13=p.get_int("DPCCH_SLOT13");
		DPCCH_SLOT14=p.get_int("DPCCH_SLOT14");
		 
		betaDPCCH=p.get_int("betaDPCCH");
		betaE_DPDCH1=p.get_int("betaE_DPDCH1");
		betaE_DPDCH2=p.get_int("betaE_DPDCH2");
		betaE_DPDCH3=p.get_int("betaE_DPDCH3");
		betaE_DPDCH4=p.get_int("betaE_DPDCH4");
		betaE_DPCCH=p.get_int("betaE_DPCCH");
		betaE_HS_DPCCH=p.get_int("betaE_HS_DPCCH");
	
		betaDPCCHlin=pow10(betaDPCCH/10.0);
		betaE_DPDCH1lin=pow10(betaE_DPDCH1/10.0);
		betaE_DPDCH2lin=pow10(betaE_DPDCH2/10.0);
		betaE_DPDCH3lin=pow10(betaE_DPDCH3/10.0);
		betaE_DPDCH4lin=pow10(betaE_DPDCH4/10.0);
		betaE_DPCCHlin=pow10(betaE_DPCCH/10.0);
		betaE_HS_DPCCHlin=pow10(betaE_HS_DPCCH/10.0);

		OVSF=wcdma_spreading_codes (SF);
		OVSF4=wcdma_spreading_codes(SF_EDPDCH3);
		OVSF2=wcdma_spreading_codes(SF_EDPDCH2);

		OVSF256_0.set_length(SF,false);
		OVSF256_1.set_length(SF,false);
		OVSF256_33.set_length(SF,false);
		OVSF256_64.set_length(SF,false);
		
		OVSF4_1.set_length(SF_EDPDCH3,false);
		OVSF4_3.set_length(SF_EDPDCH3,false);
		OVSF2_1.set_length(SF_EDPDCH2,false);

		for(int i=0;i<OVSF.cols();i++)
		{
		OVSF256_0[i]=OVSF(0,i);
		OVSF256_1[i]=OVSF(1,i);
		OVSF256_33[i]=OVSF(33,i);
		OVSF256_64[i]=OVSF(64,i);
		
		}
		for(int i=0;i<OVSF4.cols();i++)
		{
			OVSF4_1[i]=OVSF4(1,i);
		
		
		}

		for(int i=0;i<OVSF2.cols();i++)
		{
			OVSF2_1[i]=OVSF2(1,i);
		}
		bvec DPCCH0=dec2bin(DPCCH_SLOT0,true);
		bvec DPCCH1=dec2bin(DPCCH_SLOT1,true);
		bvec DPCCH2=dec2bin(DPCCH_SLOT2,true);
		bvec DPCCH3=dec2bin(DPCCH_SLOT3,true);
		bvec DPCCH4=dec2bin(DPCCH_SLOT4,true);
		bvec DPCCH5=dec2bin(DPCCH_SLOT5,true);
		bvec DPCCH6=dec2bin(DPCCH_SLOT6,true);
		bvec DPCCH7=dec2bin(DPCCH_SLOT7,true);
		bvec DPCCH8=dec2bin(DPCCH_SLOT8,true);
		bvec DPCCH9=dec2bin(DPCCH_SLOT9,true);
		bvec DPCCH10=dec2bin(DPCCH_SLOT10,true);
		bvec DPCCH11=dec2bin(DPCCH_SLOT11,true);
		bvec DPCCH12=dec2bin(DPCCH_SLOT12,true);
		bvec DPCCH13=dec2bin(DPCCH_SLOT13,true);
		bvec DPCCH14=dec2bin(DPCCH_SLOT14,true);
		
		DPCCH.set_length(DPCCH_NBits,false);
		bvec conDPCCH0=concat(DPCCH0,DPCCH1,DPCCH2,DPCCH3,DPCCH4);
		bvec conDPCCH1=concat(DPCCH5,DPCCH6,DPCCH7,DPCCH8,DPCCH9);
		bvec conDPCCH2=concat(DPCCH10,DPCCH11,DPCCH12,DPCCH13,DPCCH14);
		DPCCH=concat(conDPCCH0,conDPCCH1,conDPCCH2);

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


示例12: clear

 void clear(void) {
   hs.clear();
 }
开发者ID:Amit-DU,项目名称:dht,代码行数:3,代码来源:filestore.C


示例13: generateIf

void generateIf(){
	int pl=tempCode.size();
	if(DEBUG)printf("Generuje if w linii %d\n", pl);
}
开发者ID:rybycy,项目名称:JfttCompiler,代码行数:4,代码来源:translate.c


示例14: generateWhile

void generateWhile(){
	int pl=tempCode.size();
	if(DEBUG)printf("Generuej while w linii %d\n", pl);	
	labeler();
}
开发者ID:rybycy,项目名称:JfttCompiler,代码行数:5,代码来源:translate.c


示例15: generateDivision

void generateDivision(){
	char temp[50];
		int mod=0;
		//c=0, d=1
		addCodeLine("LOAD " + op_temp_b);
		addCodeLine("STORE " + op_temp_c);
		//jezeli b=0 to skaczemy 
		//addCodeLine("JZ " + tempCode.size()+66);
		sprintf(temp, "JZ %d", tempCode.size()+mod+66);addCodeLine(temp);
		addCodeLine("ZERO");
		addCodeLine("STORE " + op_temp_c);
		addCodeLine("INC");
		addCodeLine("STORE " + op_temp_d);
		
		//jesli b parzyste -> skacz (czyt. jezeli b+1 nieparzyste -> skacz)
		// ********** 0 *********
		int label[7];
		label[0] = tempCode.size();
		addCodeLine("LOAD " + op_temp_b);
		//addCodeLine("INC");
		// dopokia b+1 jest nieparzyste (b jest parzyste)
		sprintf(temp, "JODD %d", tempCode.size()+mod+17);addCodeLine(temp);
		addCodeLine("LOAD " + op_temp_d);
		addCodeLine("SHL");
		addCodeLine("STORE " + op_temp_d);
		
		//jezeli a+1 nieparzyste -> 2
		addCodeLine("LOAD " + op_temp_a);
		addCodeLine("INC");
		sprintf(temp, "JODD %d", tempCode.size()+mod+4);addCodeLine(temp);
		addCodeLine("LOAD " + op_temp_d);
		addCodeLine("INC");
		addCodeLine("STORE " + op_temp_d);
		// ************ 2 **********
		
		addCodeLine("LOAD " + op_temp_a);
		addCodeLine("SHR");
		addCodeLine("STORE " + op_temp_a);
		addCodeLine("LOAD " + op_temp_b);
		addCodeLine("SHR");
		addCodeLine("STORE " + op_temp_b);
		sprintf(temp, "JUMP %d", label[0]);addCodeLine(temp);
		

		// **************** 1
		label[1]=tempCode.size();
		addCodeLine("LOAD " + op_temp_b);
		addCodeLine("SUB " + op_temp_a);
		sprintf(temp, "JG %d", tempCode.size()+mod+5);addCodeLine(temp); //3
		addCodeLine("LOAD " + op_temp_b);
		addCodeLine("SHL");
		addCodeLine("STORE " + op_temp_b);
		sprintf(temp, "JUMP %d", label[1]);addCodeLine(temp); //1
		
		// ************* 3
		label[3]=tempCode.size();
		addCodeLine("LOAD " + op_temp_b);
		sprintf(temp, "JODD %d", tempCode.size()+mod+16);addCodeLine(temp); //4
		addCodeLine("LOAD " + op_temp_c);
		addCodeLine("SHL");
		addCodeLine("STORE " + op_temp_c);
		addCodeLine("LOAD " + op_temp_b);
		addCodeLine("SHR");
		addCodeLine("STORE " + op_temp_b);
		addCodeLine("SUB " + op_temp_a);
		sprintf(temp, "JG %d", tempCode.size()+mod+7);addCodeLine(temp); // -> 5
		addCodeLine("LOAD " + op_temp_c);
		addCodeLine("INC");
		addCodeLine("STORE " + op_temp_c);
		addCodeLine("LOAD " + op_temp_a);
		addCodeLine("SUB " + op_temp_b);
		addCodeLine("STORE " + op_temp_a);
		// ****************** 5
		sprintf(temp, "JUMP %d", label[3]);addCodeLine(temp); // ->3
		// jezeli d>0 (r>0) to rob; jesli rowna- skacz
		// ***************** 4
		label[4]=tempCode.size();
		addCodeLine("LOAD " + op_temp_d);
		sprintf(temp, "JZ %d", tempCode.size()+mod+14);addCodeLine(temp); // -> 6
		addCodeLine("LOAD " + op_temp_a);
		addCodeLine("SHL");
		addCodeLine("STORE " + op_temp_a);
		addCodeLine("LOAD " + op_temp_d);
		addCodeLine("INC");
		sprintf(temp, "JODD %d", tempCode.size()+mod+4);addCodeLine(temp); // -> 7
		addCodeLine("LOAD " + op_temp_a);
		addCodeLine("INC");
		addCodeLine("STORE " + op_temp_a);
		// ************* 7
		addCodeLine("LOAD " + op_temp_d);
		addCodeLine("SHR");
		addCodeLine("STORE " + op_temp_d);
		sprintf(temp, "JUMP %d", label[4]);addCodeLine(temp); // -> 4
		// **************** 6
		addCodeLine("LOAD " + op_temp_a);
		addCodeLine("SHR");
		addCodeLine("STORE " + op_temp_a);
		addCodeLine("STORE " + op_temp_b); //reszta w b
		addCodeLine("LOAD " + op_temp_c); // przepisac wynik z c do a 
		addCodeLine("STORE " + op_temp_a);
//.........这里部分代码省略.........
开发者ID:rybycy,项目名称:JfttCompiler,代码行数:101,代码来源:translate.c


示例16: labeler

void labeler(){
	if(DEBUG)addCodeLine("---ETYKIETA---");
	int line=tempCode.size()-1;
	labelStack.push_back(line);
	if(DEBUG)printf("Tymczasowy label w linii %d\n", line);
}
开发者ID:rybycy,项目名称:JfttCompiler,代码行数:6,代码来源:translate.c


示例17:

	vco() { y0.set_length(2);  
			y0(0) = 0.0; y0(1)= 0.0;   
			acc = 0.0; } ;
开发者ID:maki63,项目名称:c_sci,代码行数:3,代码来源:csim_vco.hpp


示例18: maymove

 bool maymove() const { return timeinair || physstate < PHYS_FLOOR || vel.squaredlen() > 1e-4f || deltapos.squaredlen() > 1e-4f; } 
开发者ID:Croydon,项目名称:code,代码行数:1,代码来源:ents.hpp


示例19: for

 ~VSolver(void) { for (int i = 0; i < clauses.size(); i++) delete clauses[i]; }
开发者ID:Sealos,项目名称:AI,代码行数:1,代码来源:Main_debug.C


示例20: len

 virtual int len(void) {
   return hs.size() * sha1::hashsize;
 }
开发者ID:Amit-DU,项目名称:dht,代码行数:3,代码来源:filestore.C



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ vec1类代码示例发布时间:2022-05-31
下一篇:
C++ vdrefptr类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap