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

C++ vec_t类代码示例

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

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



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

示例1: curr_pid

rc_t
lg_tag_chunks_h::update(uint4_t start_byte, const vec_t& data) const
{
    FUNC(lg_tag_chunks_h::update);
    uint4_t amount; // amount to update on page
    uint4_t pid_count = start_byte/lgdata_p::data_sz; // first page
    uint4_t data_size = data.size();

    lpid_t curr_pid(_page.pid().vol(), _cref.store, 0);
    uint4_t offset = start_byte%lgdata_p::data_sz;
    uint4_t num_bytes = 0;
    while (num_bytes < data_size) {
        amount = MIN(lgdata_p::data_sz-offset, data_size-num_bytes);
        curr_pid.page = _pid(pid_count); 
        lgdata_p lgdata;
        W_DO( lgdata.fix(curr_pid, LATCH_EX) );
        W_DO(lgdata.update(offset, data, num_bytes, amount));
        offset = 0;
        num_bytes += amount;
        pid_count++;
    }
    // verify last page touched is same as calculated last page
    w_assert9(pid_count-1 == (start_byte+data.size()-1)/lgdata_p::data_sz);
    return RCOK;
}
开发者ID:glycerine,项目名称:shore-mt,代码行数:25,代码来源:lgrec.cpp


示例2: intersect_vertex_rect

bool intersect_vertex_rect (const vec_t &v, const rect_t &r) {
    if (r.left < v.x () && r.right > v.x ()) {
        if (r.top > v.y () && r.bottom < v.y ()) {
            return true;
        }
    }
    return false;
}
开发者ID:mapleyustat,项目名称:papaya,代码行数:8,代码来源:intersect.cpp


示例3: feat_trade_region

feature feat_trade_region(vec_t trade_list)
{
	feature feat;
	if (trade_list.size() > 0)
		feat.push_back(trade_list[trade_list.size() - 1].timeStamp - trade_list[0].timeStamp);
	else
		feat.push_back(0);
	return feat;
}
开发者ID:KaiQiangSong,项目名称:ebdata,代码行数:9,代码来源:feature.hpp


示例4: V

void V(const vec_t &a, int b, int c, vec_t &d)
{
	int	i;

	DBG(<<"*******BEGIN TEST("  << b << "," << c << ")");
	for(i=0; i<a.count(); i++) {
		DBG(<<"vec["<<i<<"]=("
			<<::dec((unsigned int)a.ptr(i)) <<"," <<a.len(i) <<")");
	}

	for(int l = 0; l<100; l++) {
		if(c > (int) a.size()) break;
		a.mkchunk(b, c, d);

#ifdef DEBUG
	cout <<"returning  :";
	for(i=0; i<d.count(); i++) {
		cout <<"result["<<i<<"]=("
			<<::dec((unsigned int)d.ptr(i)) <<"," <<d.len(i) <<")" << endl;
	}
	for(i=0; i<d.count(); i++) {
		for(int j=0; j< (int)d.len(i); j++) {
			cout << *(char *)(d.ptr(i)+j);
		}
	} cout << endl;
#endif
		c+=b;
	}
	DBG(<<"*******END TEST");
}
开发者ID:glycerine,项目名称:shore-mt,代码行数:30,代码来源:vectors.C


示例5: click

void click(float x,float y) {
    uint64_t start = high_precision_time();
    const float
    unit_x = (2.0f*(x/screen->w))-1.0f,
    unit_y = 1.0f-(y/screen->h);
#if 0
    const vec_t near(world()->unproject(vec_t(unit_x,unit_y,-1))),
          far(world()->unproject(vec_t(unit_x,unit_y,1)));
#else
    GLint vp[4];
    double p[16], mv[16], a,b,c,d,e,f;
    glGetIntegerv(GL_VIEWPORT,vp);
    glGetDoublev(GL_PROJECTION_MATRIX,p);
    glGetDoublev(GL_MODELVIEW_MATRIX,mv);
    gluUnProject(x,screen->h-y,0,mv,p,vp,&a,&b,&c);
    gluUnProject(x,screen->h-y,1,mv,p,vp,&d,&e,&f);
    const vec_t near(a,b,c), far(d,e,f);
#endif
    ray = ray_t(near,far-near);
    std::cout << std::endl << "(" << x << "," << y << ") (" << unit_x << ',' << unit_y << ") " << ray << std::endl;
    world_t::hits_t hits;
    world()->intersection(ray,~0,hits);
    uint64_t ns = high_precision_time()-start;
    std::cout << std::endl << "click(" << x << "," << y << ") (" << unit_x << ',' << unit_y << ") " << ray << " (" << ns << " ns) "<<hits.size()<< std::endl;
    selection = false;
    for(world_t::hits_t::iterator i=hits.begin(); i!=hits.end(); i++) {
        vec_t pt;
        start = high_precision_time();
        bool hit = i->obj->refine_intersection(ray,pt);
        ns = high_precision_time()-start;
        if(hit) {
            std::cout << "hit " << pt << " ";
            if(!selection ||
                    (pt.distance_sqrd(ray.o)<selected_point.distance_sqrd(ray.o))) {
                selection = true;
                selected_point = pt;
                std::cout << "BEST ";
            }
        } else
            std::cout << "miss ";
        std::cout << *i << " (" << ns << " ns)" << std::endl;
    }
    if(selection) std::cout << "SELECTION: " << selected_point << std::endl;
    // the slow way
    if(terrain()) {
        terrain_t::test_hits_t test;
        start = high_precision_time();
        terrain()->intersection(ray,test);
        ns = high_precision_time()-start;
        std::cout << "(slow check: " << ns << " ns)" << std::endl;
        for(terrain_t::test_hits_t::iterator i=test.begin(); i!=test.end(); i++)
            std::cout << "TEST " <<
                      (i->obj->sphere_t::intersects(ray)?"+":"-") <<
                      (i->obj->aabb_t::intersects(ray)?"+":"-") <<
                      *i->obj << i->hit << std::endl;
        vec_t surface;
        if(selection && terrain()->surface_at(selected_point,surface))
            std::cout << "(surface_at " << surface << " - " << selected_point << " = " << (selected_point-surface) << ")" << std::endl;
    }
}
开发者ID:williame,项目名称:GlestNG,代码行数:60,代码来源:glestng.cpp


示例6: get_track_distglobal_statistics

feature get_track_distglobal_statistics(vec_t trade_list)
{
	vec_d Dist;
	size_t len = trade_list.size();
	for (size_t i = 0; i + 1< len; ++i )
		Dist.push_back(dist_global(trade_list[i].addr, trade_list[i + 1].addr));
	return get_statistics_feature(Dist);
}
开发者ID:KaiQiangSong,项目名称:ebdata,代码行数:8,代码来源:feature.hpp


示例7: get_Gap_statistics

feature get_Gap_statistics(vec_t trade_list)
{
	vec_d Gap;
	size_t len = trade_list.size();
	for (size_t i = 0; i + 1 < len; ++i)
		Gap.push_back(trade_list[i + 1].timeStamp.get_time() - trade_list[i].timeStamp.get_time());
	return get_statistics_feature(Gap);
}
开发者ID:KaiQiangSong,项目名称:ebdata,代码行数:8,代码来源:feature.hpp


示例8: get_dist2_statistics

feature get_dist2_statistics(vec_t trade_list)
{
	vec_d Dist;
	size_t len = trade_list.size();
	for (size_t i = 0; i + 1 < len; ++i)
		for (size_t j = i + 1; j < len; ++j)
			Dist.push_back(dist2(trade_list[i].addr, trade_list[j].addr));
	return get_statistics_feature(Dist);
}
开发者ID:KaiQiangSong,项目名称:ebdata,代码行数:9,代码来源:feature.hpp


示例9: feat_trade_distglobal_total

feature feat_trade_distglobal_total(vec_t trade_list)
{
	feature feat;
	size_t len = trade_list.size();
	double sum = 0;
	for (size_t i = 0; i + 1 < len; ++i)
		sum += dist_global(trade_list[i].addr, trade_list[i + 1].addr);
	feat.push_back(sum);
	return feat;
}
开发者ID:KaiQiangSong,项目名称:ebdata,代码行数:10,代码来源:feature.hpp


示例10: feat_trade_location_avg

feature feat_trade_location_avg(vec_t trade_list)
{
	feature feat;
	size_t len = trade_list.size();
	feature distVec;
	for (size_t i = 0; i + 1 < len; ++i)
		for (size_t j = i + 1; j < len; ++j)
			distVec.push_back(dist2(trade_list[i].addr, trade_list[j].addr));

	return feat;
}
开发者ID:KaiQiangSong,项目名称:ebdata,代码行数:11,代码来源:feature.hpp


示例11:

large::large( bool neg, const vec_t& val )
{
  if( val.size() > 0 )
  {
    _neg = neg;
    _val = val;
  }
  else
  {
    _neg = false;
  }
}
开发者ID:paiv,项目名称:largenum,代码行数:12,代码来源:large.cpp


示例12: feat_trade_distglobal_max

feature feat_trade_distglobal_max(vec_t trade_list)
{
	feature feat;
	size_t len = trade_list.size();
	double maxDist = 0;
	for (size_t i = 0; i + 1 < len; ++i)
		for (size_t j = i + 1; j < len; ++j)
			if (dist_global(trade_list[i].addr, trade_list[j].addr) > maxDist)
				maxDist = dist_global(trade_list[i].addr, trade_list[j].addr);
	feat.push_back(maxDist);
	return feat;
}
开发者ID:KaiQiangSong,项目名称:ebdata,代码行数:12,代码来源:feature.hpp


示例13: SGD_QN

 SGD_QN(vec_t& w, double lambda, index_t skip, double t0)
 : _w(w), _dim(w.nrows()), _lambda(lambda), _skip(skip)
 , _r_lb(lambda), _r_ub(100.0 * lambda)
 , _v(_dim), _B(_dim)
 , _time(t0), _count(skip), _updateB(false)
 {
     // initialize B
     
     zero(_v);
     
     double vB0 = 1.0 / (_lambda * (t0 + 1));
     fill(_B, vB0);
 }
开发者ID:gongfuPanada,项目名称:pli-toolbox,代码行数:13,代码来源:sgdqn_cimp.cpp


示例14: FUNC

rc_t
lgdata_p::append(const vec_t& data, uint4_t start, uint4_t amount)
{
    FUNC(lgdata_p::append);

    // new vector at correct start and with correct size
    if(data.is_zvec()) {
        const zvec_t amt_vec_tmp(amount);            
        W_DO(splice(0, (slot_length_t) tuple_size(0), 0, amt_vec_tmp));
    } else {
        vec_t new_data(data, u4i(start), u4i(amount));
        w_assert9(amount == new_data.size());
        W_DO(splice(0, (slot_length_t) tuple_size(0), 0, new_data));
    }
    return RCOK;
}
开发者ID:glycerine,项目名称:shore-mt,代码行数:16,代码来源:lgrec.cpp


示例15: t

double	sphere_t::hits(const vec_t& pos, const vec_t& dir, vec_t& hit, vec_t& N)
{
	vec_t	pc;
	double	a = 1.0, b, c;
	double	d, t(-1.0), t0(-1.0), t1(-1.0);
	double  precision = 0.000001;

  assert(cookie == OBJ_COOKIE);

  // get vector from sphere center to ray base (pos - center)
  pc = pos - center;

  // compute coeffs for quadratic formula, a should be 1.0 if dir normalized
  a = dir.dot(dir);
  b = 2.0 * pc.dot(dir);
  c = pc.dot(pc) - radius * radius;

  // determine the discriminant from the quadratic formula
  d = b*b - 4.0*a*c;

  // if discriminant positive, solve for t
  if(d > 0) {
    // t is the distance from ray's base to hit on sphere, calculate both 
    // roots but take the smaller one. Only calculate both if the object is
    // transparent.
    
    t0 = (-b - sqrt(d)) / (2.0 * a);
    t1 = (-b + sqrt(d)) / (2.0 * a);

    if((t0 < t1) && (t0 > 0.00001)) t = t0;
    else t = t1;

    // since dir is a unit vector, scaling by t creates a vector that reaches
    // the hit point on the sphere from the ray's base; adding to the base
    // gets us onto the sphere surface
    hit = pos + t * dir;

    // the final step is to compute the normal at the surface---for a sphere
    // the normal is simply a vector pointing from the center to the hit point
  //N = (hit - center).norm();
    N = 1.0/radius * (hit - center);
  }

  return(t);
}
开发者ID:daburch,项目名称:212RayTracer,代码行数:45,代码来源:sphere.cpp


示例16: convert_image

void convert_image(const std::string &imagefilename,
                   double minv,
                   double maxv,
                   int w,
                   int h,
                   vec_t &data) {
  image<> img(imagefilename, image_type::rgb);
  image<> resized = resize_image(img, w, h);
  data.resize(resized.width() * resized.height() * resized.depth());
  for (size_t c = 0; c < resized.depth(); ++c) {
    for (size_t y = 0; y < resized.height(); ++y) {
      for (size_t x = 0; x < resized.width(); ++x) {
        data[c * resized.width() * resized.height() + y * resized.width() + x] =
          (maxv - minv) * (resized[y * resized.width() + x + c]) / 255.0 + minv;
      }
    }
  }
}
开发者ID:dreadlord1984,项目名称:tiny-cnn,代码行数:18,代码来源:test.cpp


示例17: convert_image

void convert_image(const std::string &imagefilename,
                   double minv,
                   double maxv,
                   int w,
                   int h,
                   vec_t &data) {
  cv::Mat img = cv::imread(imagefilename);
  if (img.data == nullptr) return;  // cannot open, or it's not an image
  cv::Mat resized;
  cv::resize(img, resized, cv::Size(w, h), .0, .0);
  data.resize(w * h * resized.channels(), minv);
  for (int c = 0; c < resized.channels(); ++c) {
    for (int y = 0; y < resized.rows; ++y) {
      for (int x = 0; x < resized.cols; ++x) {
        data[c * w * h + y * w + x] =
          resized.data[y * resized.step[0] + x * resized.step[1] + c];
      }
    }
  }
}
开发者ID:reunanen,项目名称:tiny-cnn,代码行数:20,代码来源:test.cpp


示例18: memset

// to insert records for plp-part and plp-leaf
rc_t  el_filler_utest::fill_el(vec_t& el, const lpid_t& leaf)
{
  cout << "Creating record " << j << endl;

  char* dummy = new char[_rec_size];
  memset(dummy, '\0', _rec_size);
  vec_t data(dummy, _rec_size); 
  {
    w_ostrstream o(dummy, _rec_size);
    o << j << ends;
    w_assert1(o.c_str() == dummy);
  }
  
  // header contains record #
  int i = j;
  const vec_t hdr(&i, sizeof(i));
  
  rc_t rc = ss_m::find_page_and_create_mrbt_rec(_fid, leaf, hdr, _rec_size, data, rid, false, false);
  cout << " rid: " << rid << endl;

  el.put((char*)(&rid), sizeof(rid_t));
  
  return rc;
}
开发者ID:mengqingzhong,项目名称:shore-mt,代码行数:25,代码来源:mrbtrees_test.cpp


示例19: feat_trade_amount

feature feat_trade_amount(vec_t trade_list)
{
	feature feat;
	feat.push_back(trade_list.size());
	return feat;
}
开发者ID:KaiQiangSong,项目名称:ebdata,代码行数:6,代码来源:feature.hpp


示例20: print

      void print(const vec_t &v)
      {
	thrust::copy(v.begin(), v.end(), std::ostream_iterator<typename vec_t::value_type>(std::cerr, "\t"));
	std::cerr << std::endl;
      }
开发者ID:azimniak,项目名称:libcloudphxx,代码行数:5,代码来源:thrust.hpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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