本文整理汇总了C++中Coord::err方法的典型用法代码示例。如果您正苦于以下问题:C++ Coord::err方法的具体用法?C++ Coord::err怎么用?C++ Coord::err使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Coord
的用法示例。
在下文中一共展示了Coord::err方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
vnode_impl::update_coords (Coord uc, float ud)
{
// warn << myID << " --- starting update -----\n";
Coord v = uc;
float rmt_err = uc.err ();
float actual = ud;
float expect = me_->coords ().distance_f (uc);
if (actual >= 0 && actual < 1000000) { //ignore timeouts
//track our prediction error
update_error (actual, expect, rmt_err);
// Work on a copy (including the updated error).
Coord coords = me_->coords ();
// force magnitude: > 0 --> stretched
float grad = expect - actual;
v.vector_sub (coords);
float len = v.plane_norm ();
while (len < 0.0001) {
for (unsigned int i = 0; i < Coord::NCOORD; i++)
v.coords[i] = (double)(random () % 400 - 200) / 1.0;
//if (USING_HT) v.ht += fabs((double)(random () % 10 - 5) / 10.0);
len = v.plane_norm ();
}
len = v.norm ();
float unit = 1.0 / sqrtf (len);
// scalar_mult(v, unit) is unit force vector
// times grad gives the scaled force vector
v.scalar_mult (unit*grad);
//timestep is the scaled ratio of our prediction error
// and the remote node's prediction error
float pred_err = coords.err ();
float timestep;
if (pred_err > 0 && rmt_err > 0)
timestep = 0.1 * (pred_err)/(pred_err + rmt_err);
else if (pred_err > 0)
timestep = 0.0;
else
timestep = 1.0;
v.scalar_mult (timestep);
//flip sign on height
v.ht = -v.ht;
coords.vector_add (v);
#ifdef VIVALDI_DEBUG
char b[1024];
snprintf (b, 1024, "coord hop: %f - %f = %f ; len=%f ts=%f (%f %f)\n",
expect, actual, grad, len, timestep, pred_err, rmt_err);
warn << b;
coords.print ("coords ");
uc.print ("uc ");
warn << "----------------\n";
#endif
if (coords.ht <= 100) coords.ht = 100;
me_->set_coords (coords);
} else {
char b[32];
snprintf (b, 32, "%f", actual);
trace << "COORD: ignored actual of " << b << "\n";
}
}