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

C++ ivec类代码示例

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

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



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

示例1: getentboundingbox

bool getentboundingbox(extentity &e, ivec &o, ivec &r)
{
    switch(e.type)
    {
        case ET_EMPTY:
            return false;
        case ET_MAPMODEL:
        {
            model *m = loadmodel(NULL, e.attr[1]);
            if(m)
            {
                vec center, radius;
                m->boundbox(center, radius);
                rotatebb(center, radius, e.attr[0]);

                o = e.o;
                o.add(center);
                r = radius;
                r.add(1);
                o.sub(r);
                r.mul(2);
                break;
            }
        }
        // invisible mapmodels use entselradius
        default:
            o = e.o;
            o.sub(entselradius);
            r.x = r.y = r.z = entselradius*2;
            break;
    }
    return true;
}
开发者ID:Kid-Matthew,项目名称:lamiae,代码行数:33,代码来源:world.cpp


示例2:

std::complex<double> operator*(const ivec &a, const cvec &b)
{
  it_assert_debug(a.size() == b.size(), "operator*(): sizes does not match");
  std::complex<double> temp = 0;
  for (int i = 0;i < a.size();i++) {temp += (double)a(i) * b(i);}
  return temp;
}
开发者ID:c304728539,项目名称:itpp-fastica,代码行数:7,代码来源:operators.cpp


示例3: getentboundingbox

bool getentboundingbox(extentity &e, ivec &o, ivec &r)
{
    switch(e.type)
    {
        case ET_EMPTY:
            return false;
        case ET_MAPMODEL:
        {
            LogicEntityPtr entity = LogicSystem::getLogicEntity(e); // INTENSITY
            model *m = entity.get() ? entity->getModel() : NULL; // INTENSITY
            if(m)
            {
                vec center, radius;
                m->boundbox(0, center, radius, entity.get()); // INTENSITY: entity
                rotatebb(center, radius, e.attr1);
                o = e.o;
                o.add(center);
                r = radius;
                r.add(1);
                o.sub(r);
                r.mul(2);
                break;
            }
        }
        // invisible mapmodels use entselradius
        default:
            o = e.o;
            o.sub(GETIV(entselradius));
            r.x = r.y = r.z = GETIV(entselradius)*2;
            break;
    }
    return true;
}
开发者ID:zot,项目名称:CubeCreate,代码行数:33,代码来源:world.cpp


示例4: assert_ivec

static
void assert_ivec(const ivec &expected, const ivec &actual)
{
  ASSERT_EQ(expected.length(), actual.length());
  for (int n = 0; n < expected.length(); ++n)
  {
    ASSERT_EQ(expected[n], actual[n]);
  }
}
开发者ID:snikulov,项目名称:mirror.itpp,代码行数:9,代码来源:histogram_test.cpp


示例5: temp

cvec operator+(const std::complex<double> &s, const ivec &v)
{
  it_assert_debug(v.size() > 0, "operator+(): Vector of zero length");

  cvec temp(v.size());
  for (int i = 0;i < v.size();i++) {
    temp(i) = s + std::complex<double>(v(i));
  }
  return temp;
}
开发者ID:c304728539,项目名称:itpp-fastica,代码行数:10,代码来源:operators.cpp


示例6: r_search

	void r_search(Node *root, const interval<T>& i, ivec& vec, int mode) {
		if (root == NULL) return;

		if (mode == OVERLAP && root->m_interval->overlaps(i)) vec.push_back(*(root->m_interval));
		if (mode == CONTAIN && root->m_interval->contains(i)) vec.push_back(*(root->m_interval));
		if (mode == CONTAINED && i.contains(*(root->m_interval))) vec.push_back(*(root->m_interval));

		if (root->left != NULL && i.overlaps(root->left->min, root->left->max))
			r_search(root->left, i, vec, mode);
		if (root->right != NULL && i.overlaps(root->right->min, root->right->max))
			r_search(root->right, i, vec, mode);
	}
开发者ID:zoid,项目名称:zclib,代码行数:12,代码来源:interval_tree.cpp


示例7: Train

void ClassifierMLP::Train(std::vector< fvec > samples, ivec labels)
{
	u32 sampleCnt = samples.size();
	if(!sampleCnt) return;
	DEL(mlp);
	dim = samples[0].size();

	CvMat *layers;
//	if(neuronCount == 3) neuronCount = 2; // don't ask me why but 3 neurons mess up everything...

	if(!layerCount || neuronCount < 2)
	{
		layers = cvCreateMat(2,1,CV_32SC1);
		cvSet1D(layers, 0, cvScalar(dim));
		cvSet1D(layers, 1, cvScalar(1));
	}
	else
	{
		layers = cvCreateMat(2+layerCount,1,CV_32SC1);
		cvSet1D(layers, 0, cvScalar(dim));
		cvSet1D(layers, layerCount+1, cvScalar(1));
		FOR(i, layerCount) cvSet1D(layers, i+1, cvScalar(neuronCount));
	}

	u32 *perm = randPerm(sampleCnt);

	CvMat *trainSamples = cvCreateMat(sampleCnt, dim, CV_32FC1);
	CvMat *trainLabels = cvCreateMat(labels.size(), 1, CV_32FC1);
	CvMat *sampleWeights = cvCreateMat(samples.size(), 1, CV_32FC1);
	FOR(i, sampleCnt)
	{
		FOR(d, dim) cvSetReal2D(trainSamples, i, d, samples[perm[i]][d]);
		cvSet1D(trainLabels, i, cvScalar(labels[perm[i]]));
		cvSet1D(sampleWeights, i, cvScalar(1));
	}
开发者ID:barak,项目名称:mldemos,代码行数:35,代码来源:classifierMLP.cpp


示例8: set_data

void cofdm_map::set_data(ivec x)
{
cvec qv;
bvec ce;
int K = x.length();
int i;

	ce.set_length(K); ce.ones();
	#if (DEBUG_LEVEL == 3)
	cout << "***** cofdm_map::set_data *****" << endl;	
	cout << "K=" << K << endl;
	cout << "ce=" << ce << endl;
	cout << "x=" << x << endl;
	cout << "data_carriers=" << data_carriers << endl;
	#endif

	if( K == data_carriers.length() ) {
		qv = qammod.process(ce,x);
		#if (DEBUG_LEVEL == 3)
		cout << "qv=" << qv << endl;
		#endif
		for (i=0; i<K; i++) {
			y0(data_carriers(i))=qv(i);
		}
	}
	else {
		throw sci_exception("cofdm_map::set_data - x.size() <> data_carriers.size()=", data_carriers.length());
	}

	#if (DEBUG_LEVEL == 3)
	cout << "y0(piltos)  y0(zeros) migh have rubbish" << endl;
	cout << "y0=" << y0 << endl;
	cout << "+++++ cofdm_map::set_data +++++" << endl;	
	#endif
}
开发者ID:maki63,项目名称:c_sci,代码行数:35,代码来源:csim_cofdm_map.cpp


示例9: TSP

ivec TSP(const ivec& purchases)
{
	if (purchases.size()<2) return ivec(purchases);
	ivec cur = purchases;
	ivec best = cur;
	double bdist = pathCost(cur);
	double cdist = bdist;
	for(double t=10; t>.1; t*=.999) {
		size_t a = rand()%(cur.size()-1);
		size_t b = rand()%(cur.size()-1);
		if (b>=a) ++b;
		else swap(a,b);

		int ca=cur[a], cb=cur[b];
		double da = a ? itemDist[cur[a-1]][cb] -  itemDist[cur[a-1]][ca] : startDist[cb] - startDist[ca];
		double db = b<cur.size()-1 ? itemDist[ca][cur[b+1]] - itemDist[cb][cur[b+1]] : endDist[ca] - endDist[cb];
		double d = da+db;
		if (d<0 || randf()<exp(-d/t)) {
			reverse(cur.begin()+a,cur.begin()+b+1);
			cdist = pathCost(cur);
			if (cdist < bdist) {
				best = cur;
				bdist = cdist;
			}
		}
	}
	return best;
}
开发者ID:sisu,项目名称:stsp,代码行数:28,代码来源:tsp.cpp


示例10: bpsk_sym_err

int bpsk_sym_err(bvec bv_src, ivec iv_dem) {
	int err = 0;
	for(int i=0; i<iv_dem.size(); i++) {
		if(bv_src(i)!=iv_dem(i))
			err++;
	}
	return err;
}
开发者ID:jhnsnshen,项目名称:pnc,代码行数:8,代码来源:mrc_pnc.cpp


示例11: expectedTotalCost

double expectedTotalCost(const ivec& path)
{
    double r=0;
    for(size_t i=1; i<path.size(); ++i) {
//		r += dist[path[i-1]][path[i]];
        int a = path[i-1], b = path[i];
        int n = lower_bound(conn[a].begin(),conn[a].end(),b)-conn[a].begin();
        assert(conn[a][n]==b);
        r += edgeDist[a][n];
//		if (final) cout<<"lol "<<a<<' '<<b<<' '<<n<<' '<<edgeDist[a][n]<<'\n';
    }
    if (final) cout<<path<<'\n'<<"length cost "<<r<<'\n';
    r *= LENGTH_FACTOR;

    double rr=0;

    vector<double> pdist;
    for(size_t k=0; k<samples.size(); ++k) {
        vector<int>& v = samples[k];
        int n = v.size();
        pdist.resize(n);
        for(int i=0; i<n; ++i) {
            int a = v[i];
            double d=1e100;
            for(size_t j=0; j<path.size(); ++j)
                d = min(d, dist[a][path[j]]);
            pdist[i] = d;
//			if (final) cout<<"pdist "<<k<<' '<<a<<": "<<d<<'\n';
        }

        for(int i=0; i<n; ++i)
            for(int j=0; j<i; ++j) {
                int x=v[i], y=v[j];
//				cout<<"asdasd "<<tsps[a].dists<<'\n';
                tsps[k].dists[i][j] = tsps[k].dists[j][i] = min(dist[x][y], pdist[i]+pdist[j]);
            }

        double cr = tsps[k].calc();
        if (robustOpt) rr = max(rr, cr);
        else rr += probs[k] * cr;

        if (final) cout<<"tsp cost "<<k<<": "<<cr<<'\n';
    }
    return r + rr;
}
开发者ID:sisu,项目名称:stsp,代码行数:45,代码来源:tspCost.cpp


示例12: set

void gfx::set(int qvalue, const ivec &invalues)
{
  //    it_assert0(qvalue>0, "gfx::set, out of range");
  degree=invalues.length()-1;
  coeffs.set_size(degree+1);
  for (int i=0;i<degree+1;i++)
	coeffs[i].set(qvalue,invalues[i]);
  q=qvalue;
}
开发者ID:mbillingr,项目名称:tools4bci-unibuild,代码行数:9,代码来源:gfx.cpp


示例13: qam_sym_err

int qam_sym_err(bvec bv_src, ivec iv_dem) {
	int err = 0;
	for(int i=0, k=0; i<iv_dem.size(); i++, k+=2) {
		int src = (bv_src(k).value()<<1) + bv_src(k+1).value();
		if(src!=iv_dem(i))
			err++;
	}
	return err;
}
开发者ID:jhnsnshen,项目名称:pnc,代码行数:9,代码来源:mrc_pnc.cpp


示例14: temp

CFix operator*(const cfixvec &a, const ivec &b)
{
  it_assert_debug(a.size() == b.size(), "operator+(): sizes do not match");
  CFix temp(0);
  for (int i = 0; i < a.size(); i++) {
    temp += a(i) * b(i);
  }
  return temp;
}
开发者ID:c304728539,项目名称:itpp-fastica,代码行数:9,代码来源:fix_operators.cpp


示例15: max_to_all

ivec max_to_all(const ivec &pt) {
  int in[5], out[5];
  for (int i=0; i<5; ++i) in[i] = out[i] = pt.in_direction(direction(i));
#ifdef HAVE_MPI
  MPI_Allreduce(&in,&out,5,MPI_INT,MPI_MAX,mycomm);
#endif
  ivec ptout(pt.dim);
  for (int i=0; i<5; ++i) ptout.set_direction(direction(i), out[i]);
  return ptout;
}
开发者ID:Arthur-Thijssen,项目名称:MEEP-actt,代码行数:10,代码来源:mympi.cpp


示例16: extract_score

//gene_idx is for a single gene (otherwise it should be imat rather than ivec)
void extract_score(fvec &S, const fvec &score0, 
const ivec &gene_idx){
  
	int ns = gene_idx.size();//number of SNPs in a gene
		
	S = fvec(ns);
	for(int j = 0; j < ns; ++j){
		int J = gene_idx[j];
		S[j] = score0[J];
	}
	
}
开发者ID:yfyang86,项目名称:ARTP3,代码行数:13,代码来源:artp3.cpp


示例17: ivec

void Triangles::setNodes(ivec n)
{
    int size = n.size();
    nodes = ivec(size);

    for (int i = 0; i < size; i++)
    {
        nodes[i] = n[i];
    }

    return;
}
开发者ID:nixz,项目名称:covise,代码行数:12,代码来源:Triangles.cpp


示例18: process

cvec qam_mod::process(bvec ce, ivec x)
{
 cvec y;	
 int N;
 ivec iv;
 cvec cv;

	#if (DEBUG_LEVEL==3)
	cout << "***** qam_mod::process *****" << endl;	
	cout << "ce=" << ce << endl;
	cout << "x=" << x << endl;
	sleep(1000);
	#endif

	iv.set_length(1);
	cv.set_length(1);
	N=ce.length();
	y.set_length(N);
	if (x.length()!=N) {
		throw sci_exception("qam_mod::process - ce.size <> x.size", x.length() );
	}	
	for (int i=0; i<N; i++) {
		if ( bool(ce[i])) {
			iv[0]  = x[i];
			cv = modulate(iv);
			y0 = scale * cv[0];
		}
		y[i]=y0;
	}

	#if (DEBUG_LEVEL==3)
	cout << "y=" << y << endl;
	cout << "+++++ qam_mod::process +++++" << endl;	
	sleep(1000);
	#endif

	return (y);
}
开发者ID:maki63,项目名称:c_sci,代码行数:38,代码来源:csim_qam_mod.cpp


示例19: match_one

void match_one (svec a, svec b, ivec& ret) {

  si_map A;
  svec inter;

  for(int i=0; i < a.size(); i++) A[a[i]] = i;

  std::sort(a.begin(), a.end());
  std::sort(b.begin(), b.end());

  std::set_intersection(a.begin(), a.end(), b.begin(), b.end(),
        std::back_inserter(inter));
  ret.resize(inter.size());
  for(int i=0; i < inter.size(); i++) ret[i] = A[inter[i]];
}
开发者ID:justinpenz,项目名称:mrgsolve,代码行数:15,代码来源:mrgsolve.cpp


示例20: match_both

void match_both (svec a, svec b, ivec& ai, ivec& bi) {

  si_map A;
  si_map B;
  svec inter;

  int i = 0;

  for(i=0; i < a.size(); i++) A[a[i]] = i;
  for(i=0; i < b.size(); i++) B[b[i]] = i;

  std::sort(a.begin(), a.end());
  std::sort(b.begin(), b.end());

  std::set_intersection(a.begin(), a.end(), b.begin(), b.end(),
        std::back_inserter(inter));

  ai.resize(inter.size());
  for(i=0; i < inter.size(); i++) ai[i] = A[inter[i]];

  bi.resize(inter.size());
  for(i=0; i < inter.size(); i++) bi[i] = B[inter[i]];

}
开发者ID:justinpenz,项目名称:mrgsolve,代码行数:24,代码来源:mrgsolve.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ ivec2类代码示例发布时间:2022-05-31
下一篇:
C++ iter类代码示例发布时间: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