本文整理汇总了C++中mat::assign方法的典型用法代码示例。如果您正苦于以下问题:C++ mat::assign方法的具体用法?C++ mat::assign怎么用?C++ mat::assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mat
的用法示例。
在下文中一共展示了mat::assign方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gen
void gen(int kk, mat &a, vec &b)
{
const int m = kk+2;
b.assign(m, 1<<kk);
a.assign(m,vec(m,0));
a[0][0] = a[0][1] = 1;
for (int i = 1; i < m; i++) {
int kkk = kk-i+1;
for (int j = 0; j <= kkk; j++) a[i][j+1] = c[kkk][j];
}
}
示例2: move_func
//.........这里部分代码省略.........
#if AVGSPEED
pnew = p + (v+vnew)/2 * _dt; // position
#else
pnew = p + v * _dt; // position
#endif
abnew = ab + abi; // acc bias
wbnew = wb + wbi; // gyro bias
gnew = g; // gravity does not change
// normalize quaternion
ublasExtra::normalizeJac(qnew, QNORM_qnew);
ublasExtra::normalize(qnew);
// Put it all together - this is the output state
unsplitState(pnew, qnew, vnew, abnew, wbnew, gnew, _xnew);
// Now on to the Jacobian...
// Identity is a good place to start since overall structure is like this
// var | p q v ab wb g
// pos | 0 3 7 10 13 16
// -------+----------------------------------------------------
//#if AVGSPEED
// p 0 | I VNEW_q*dt/2 I*dt -R*dt*dt/2 0 I*dt*dt/2
//#else
// p 0 | I 0 I*dt 0 0 0
//#endif
// q 3 | 0 QNEW_q 0 0 QNEW_wb 0
// v 7 | 0 VNEW_q I -R*dt 0 I*dt
// ab 10 | 0 0 0 I 0 0
// wb 13 | 0 0 0 0 I 0
// g 16 | 0 0 0 0 0 I
_XNEW_x.assign(identity_mat(state.size()));
// Fill in XNEW_v: VNEW_g and PNEW_v = I * dt
identity_mat I(3);
Idt = I * _dt;
mat Iz; if (g_size == 1) { Iz.resize(3,1); Iz.clear(); Iz(2,0)=1; } else { Iz = I; }
mat Izdt = Iz * _dt;
subrange(_XNEW_x, 0, 3, 7, 10) = Idt;
#if AVGSPEED
subrange(_XNEW_x, 0, 3, 16, 16+g_size) = Izdt*_dt/2;
#endif
subrange(_XNEW_x, 7, 10, 16, 16+g_size) = Izdt;
// Fill in QNEW_q
// qnew = qold ** qwdt ( qnew = q1 ** q2 = qProd(q1, q2) in rtslam/quatTools.hpp )
qProd_by_dq1(qwdt, QNEW_q);
subrange(_XNEW_x, 3, 7, 3, 7) = prod(QNORM_qnew, QNEW_q);
// Fill in QNEW_wb
// QNEW_wb = QNEW_qwdt * QWDT_wdt * WDT_w * W_wb
// = QNEW_qwdt * QWDT_w * W_wb
// = QNEW_qwdt * QWDT_w * (-1)
qProd_by_dq2(q, QNEW_qwdt);
// Here we get the derivative of qwdt wrt wtrue, so we consider dt = 1 and call for the derivative of v2q() with v = w*dt
// v2q_by_dv(wtrue, QWDT_w);
v2q_by_dv(wtrue*_dt, QWDT_w); QWDT_w *= _dt;
QNEW_w = prod ( QNEW_qwdt, QWDT_w);
subrange(_XNEW_x, 3, 7, 13, 16) = -prod(QNORM_qnew,QNEW_w);
// Fill VNEW_q
// VNEW_q = d(R(q)*v) / dq
rotate_by_dq(q, am-ab, VNEW_q); VNEW_q *= _dt;
subrange(_XNEW_x, 7, 10, 3, 7) = VNEW_q;