本文整理汇总了C++中vec_t类的典型用法代码示例。如果您正苦于以下问题:C++ vec_t类的具体用法?C++ vec_t怎么用?C++ vec_t使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了vec_t类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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");
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例11:
large::large( bool neg, const vec_t& val )
{
if( val.size() > 0 )
{
_neg = neg;
_val = val;
}
else
{
_neg = false;
}
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}