本文整理汇总了C++中W函数的典型用法代码示例。如果您正苦于以下问题:C++ W函数的具体用法?C++ W怎么用?C++ W使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了W函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: svd
Eigen::MatrixXd Reconstruction3D::computeP( const std::vector<std::pair<Eigen::Vector2d, Eigen::Vector2d>>& points,
const Eigen::MatrixXd& E)
{
Eigen::JacobiSVD< Eigen::MatrixXd, Eigen::FullPivHouseholderQRPreconditioner > svd(E, Eigen::ComputeFullU | Eigen::ComputeFullV);
Eigen::MatrixXd U = svd.matrixU();
Eigen::MatrixXd Vt = svd.matrixV().transpose();
Eigen::MatrixXd W(3, 3);
W << 0.0, -1.0, 0.0,
1.0, 0.0, 0.0,
0.0, 0.0, 1.0;
Eigen::VectorXd u3 = U.col(2);
//std::cout << "--- Computing P Matrix: " << std::endl
// << "E: " << std::endl << E << std::endl << std::endl
// << "U: " << std::endl << U << std::endl << std::endl
// << "D: " << std::endl << svd.singularValues() << std::endl << std::endl
// << "Vt: " << std::endl << Vt << std::endl << std::endl
// << "W: " << std::endl << W << std::endl << std::endl
// << "u3 :" << u3 << std::endl << std::endl;
Eigen::MatrixXd P0(Eigen::MatrixXd::Identity(3, 4)); // Just K0: no translation or rotation.
Eigen::MatrixXd UWVt = U * W * Vt; // P without translation part.
Eigen::MatrixXd P1(3, 4);
P1.block(0, 0, 3, 3) = UWVt;
P1.block(0, 3, 3, 1) = u3;
Eigen::MatrixXd bestP1 = P0;
int numCorrectSolutions = 0;
if (checkP(points, P0, P1))
{
++numCorrectSolutions;
bestP1 = P1;
}
P1.block(0, 3, 3, 1) = -u3;
if (checkP(points, P0, P1))
{
++numCorrectSolutions;
bestP1 = P1;
}
UWVt = U * W.transpose() * Vt;
P1.block(0, 0, 3, 3) = UWVt;
P1.block(0, 3, 3, 1) = u3;
if (checkP(points, P0, P1))
{
++numCorrectSolutions;
bestP1 = P1;
}
P1.block(0, 3, 3, 1) = -u3;
if (checkP(points, P0, P1))
{
++numCorrectSolutions;
bestP1 = P1;
}
std::cout << "Number of correct solutions: " << numCorrectSolutions << std::endl << std::endl;
if (numCorrectSolutions < 1)
std::cerr << "[Error] : None of the results for P1 was accepted!" << std::endl << std::endl;
else if (numCorrectSolutions > 1)
std::cerr << "[Error] : More than one solution found : " << numCorrectSolutions << std::endl << std::endl;
// else
// std::cerr << "[Info] : Solution found for P: \n" << bestP1 << std::endl << std::endl;
return bestP1;
}
示例2: W
(((b0##UL << 0x0)|(b1##UL << 0x1)|(b2##UL << 0x2)|(b3##UL << 0x3) | \
(b4##UL << 0x4)|(b5##UL << 0x5)|(b6##UL << 0x6)|(b7##UL << 0x7) | \
(b8##UL << 0x8)|(b9##UL << 0x9)|(ba##UL << 0xa)|(bb##UL << 0xb) | \
(bc##UL << 0xc)|(bd##UL << 0xd)|(be##UL << 0xe)|(bf##UL << 0xf)) \
<< (row % 32))
/*
* Undefined/reserved opcodes, conditional jump, Opcode Extension
* Groups, and some special opcodes can not boost.
* This is non-const and volatile to keep gcc from statically
* optimizing it out, as variable_test_bit makes gcc think only
* *(unsigned long*) is used.
*/
static volatile u32 twobyte_is_boostable[256 / 32] = {
/* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
/* ---------------------------------------------- */
W(0x00, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0) | /* 00 */
W(0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1) , /* 10 */
W(0x20, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | /* 20 */
W(0x30, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) , /* 30 */
W(0x40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 40 */
W(0x50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) , /* 50 */
W(0x60, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1) | /* 60 */
W(0x70, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1) , /* 70 */
W(0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | /* 80 */
W(0x90, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 90 */
W(0xa0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1) | /* a0 */
W(0xb0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1) , /* b0 */
W(0xc0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1) | /* c0 */
W(0xd0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1) , /* d0 */
W(0xe0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1) | /* e0 */
W(0xf0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0) /* f0 */
示例3: W
/**
* Evaluate the components of the acceleration due to gravity and the
* centrifugal acceleration in geocentric coordinates.
*
* @param[in] lon the geographic longitude (degrees).
* @param[out] gX the \e X component of the acceleration
* (m s<sup>−2</sup>).
* @param[out] gY the \e Y component of the acceleration
* (m s<sup>−2</sup>).
* @param[out] gZ the \e Z component of the acceleration
* (m s<sup>−2</sup>).
* @return \e W = \e V + Φ the sum of the gravitational and
* centrifugal potentials (m<sup>2</sup> s<sup>−2</sup>).
**********************************************************************/
Math::real W(real lon, real& gX, real& gY, real& gZ) const {
real clam, slam;
CircularEngine::cossin(lon, clam, slam);
return W(clam, slam, gX, gY, gZ);
}
示例4: leap_gesture_equal
int leap_gesture_equal(leap_gesture_ref gesture, leap_gesture_ref other)
{
return W(gesture) == W(other);
}
示例5: do_kneel
int do_kneel(string str)
{
W("No, you don't feel at ease here, and you have no desire to call on " +
"whatever being it is that is worshipped here.\n");
return 1;
}
示例6: leap_gesture_gesture_state
leap_gesture_state leap_gesture_gesture_state(leap_gesture_ref gesture)
{
return leap_gesture_state(W(gesture).state());
}
示例7: leap_gesture_duration_seconds
float leap_gesture_duration_seconds(leap_gesture_ref gesture)
{
return W(gesture).durationSeconds();
}
示例8: atan2
Real Quat::GetPitch() const
{
return atan2( 2 * ( Y() * Z() + W() * X() ), W() * W() - X() * X() - Y() * Y() + Z() * Z() );
}
示例9: TestStores2
void TestStores2()
{
B(s10, Stream storage, 0) W(s10a);
W(s10b);
W(s10c);
{
// s10a is original
// s10b is a copy, random access
// s10c is a serialized copy
c4_StringProp p1 ("p1");
c4_ViewProp p2 ("p2");
c4_IntProp p3 ("p3");
{
c4_Storage s1 ("s10a", 1);
s1.SetStructure("a[p1:S,p2[p3:I]]");
c4_View v1 = s1.View("a");
v1.Add(p1 ["one"]);
v1.Add(p1 ["two"]);
c4_View v2 = p2 (v1[0]);
v2.Add(p3 [1]);
v2 = p2 (v1[1]);
v2.Add(p3 [11]);
v2.Add(p3 [22]);
v1.InsertAt(1, p1 ["three"]);
v2 = p2 (v1[1]);
v2.Add(p3 [111]);
v2.Add(p3 [222]);
v2.Add(p3 [333]);
s1.Commit();
}
{
c4_Storage s1 ("s10a", 0);
c4_Storage s2 ("s10b", 1);
s2.SetStructure("a[p1:S,p2[p3:I]]");
s2.View("a") = s1.View("a");
s2.Commit();
}
{
c4_Storage s3 ("s10b", 0);
c4_FileStream fs1 (fopen("s10c", "wb"), true);
s3.SaveTo(fs1);
}
{
c4_Storage s1 ("s10c", 0); // new after 2.01: serialized is no longer special
c4_View v1 = s1.View("a");
A(v1.GetSize() == 3);
c4_View v2 = p2 (v1[0]);
A(v2.GetSize() == 1);
c4_View v3 = p2 (v1[1]);
A(v3.GetSize() == 3);
c4_View v4 = p2 (v1[2]);
A(v4.GetSize() == 2);
}
{
c4_Storage s1;
c4_FileStream fs1 (fopen("s10c", "rb"), true);
s1.LoadFrom(fs1);
c4_View v1 = s1.View("a");
A(v1.GetSize() == 3);
c4_View v2 = p2 (v1[0]);
A(v2.GetSize() == 1);
c4_View v3 = p2 (v1[1]);
A(v3.GetSize() == 3);
c4_View v4 = p2 (v1[2]);
A(v4.GetSize() == 2);
}
{
c4_Storage s1 ("s10c", 1);
c4_View v1 = s1.View("a");
A(v1.GetSize() == 3);
c4_View v2 = p2 (v1[0]);
A(v2.GetSize() == 1);
c4_View v3 = p2 (v1[1]);
A(v3.GetSize() == 3);
c4_View v4 = p2 (v1[2]);
A(v4.GetSize() == 2);
v1.Add(p1 ["four"]);
s1.Commit();
}
{
c4_Storage s1 ("s10c", 0);
c4_View v1 = s1.View("a");
A(v1.GetSize() == 4);
c4_View v2 = p2 (v1[0]);
A(v2.GetSize() == 1);
c4_View v3 = p2 (v1[1]);
A(v3.GetSize() == 3);
c4_View v4 = p2 (v1[2]);
A(v4.GetSize() == 2);
c4_View v5 = p2 (v1[3]);
A(v5.GetSize() == 0);
}
}
D(s10a);
D(s10b);
//.........这里部分代码省略.........
示例10: Quat
Quat Quat::operator-() const
{
return Quat( W(), -X(), -Y(), -Z() );
}
示例11: gen_list
/*{{{ gen_list -- generate a clip list*/
static int gen_list(WINDOW *window)
{
WINDOW *win = window;
struct rect_list *list = NULL, *prev = (struct rect_list *)0;
int x_cnt = 2, y_cnt = 2;
int i, j;
int count = 0;
int skip; /* covered by another window - skip patch */
int hold; /* hold for coalescing */
/* build arrays of window coordinates: intersecting win's above win */
x[0] = W(borderwid) + W(x0);
y[0] = W(borderwid) + W(y0);
x[1] = W(borderwid) + W(x0) + BIT_WIDE(W(window));
y[1] = W(borderwid) + W(y0) + BIT_HIGH(W(window));
for (win = active; win != window; win = W(next)) {
if (!(in_win(win, x[0], y[0], x[1], y[1])))
continue;
if (W(x0) >= x[0] && W(x0) <= x[1])
x[x_cnt++] = W(x0);
if (W(y0) >= y[0] && W(y0) <= y[1])
y[y_cnt++] = W(y0);
if (W(x0) + BIT_WIDE(W(border)) >= x[0] && W(x0) + BIT_WIDE(W(border)) <= x[1])
x[x_cnt++] = W(x0) + BIT_WIDE(W(border));
if (W(y0) + BIT_HIGH(W(border)) >= y[0] && W(y0) + BIT_HIGH(W(border)) <= y[1])
y[y_cnt++] = W(y0) + BIT_HIGH(W(border));
if (y_cnt >= MAX_COORDS || x_cnt >= MAX_COORDS)
break;
}
/* sort window coordinate lists */
qsort(x, x_cnt, sizeof(int), cmp);
qsort(y, y_cnt, sizeof(int), cmp);
x_cnt--;
y_cnt--;
/* build list of covering rectangles */
for (j = 0; j < y_cnt; j++) {
if (y[j] == y[j + 1]) /* avoid zero-height patches */
continue;
for (hold = x_cnt, i = 0; i < x_cnt; i++) {
if (x[i] == x[i + 1]) /* avoid zero-width patches */
continue;
/* see if patch is visible */
for (skip = 0, win = active; win != window; win = W(next))
if (in_win(win, x[i], y[j], x[i + 1], y[j + 1])) {
skip++;
break;
}
/* visible, add patch to list, or append to previous patch */
if (!skip) {
if (i == hold) { /* coalescing across */
list->rect.wide += x[i + 1] - x[i];
hold++;
} else { /* flush held rect */
count++; /* only for debugging */
list = malloc(sizeof(struct rect_list));
list->rect.x = x[i] - W(x0);
list->rect.y = y[j] - W(y0);
list->rect.wide = x[i + 1] - x[i];
list->rect.high = y[j + 1] - y[j];
list->next = NULL;
if (prev)
prev->next = list;
if (!W(clip_list)) /* set initial rectangle */
W(clip_list) = (char *)list;
prev = list;
hold = i + 1; /* next 'i' to check for coalescing */
}
}
}
}
/* look at rect list DEBUG code, commented out!
for(list=(struct rect_list *) W(clip_list);list;list = list->next) {
int x = list->rect.x,
y = list->rect.y,
wide = list->rect.wide,
high = list->rect.high;
in_mouseoff( x, y, wide, high );
//.........这里部分代码省略.........
示例12: main
// main function
int main(int argc, const char * argv[])
{
gettimeofday(&start_timeval_rd1, NULL);
SparseMatrix<double> Gx_a(NX,NA);
Gx_a.resize(NX,NA);
SparseMatrix<double> Gx_b(NX,NB);
Gx_b.resize(NX,NB);
SparseMatrix<double> Gx_c(NX,NC);
Gx_c.resize(NX,NC);
Gx_a.makeCompressed();
Gx_b.makeCompressed();
Gx_c.makeCompressed();
// reading the partitions
Gx_a = read_G_sparse((char *) FILE_GA , "GX_A" ,NX, NA);
Gx_b = read_G_sparse((char *) FILE_GB , "GX_B" ,NX, NB);
Gx_c = read_G_sparse((char *) FILE_GC , "GX_C" ,NX, NC);
gettimeofday(&stop_timeval_rd1, NULL);
measure_stop_rd1 = stop_timeval_rd1.tv_usec + (timestamp_t)stop_timeval_rd1.tv_sec * 1000000;
measure_start_rd1 = start_timeval_rd1.tv_usec + (timestamp_t)start_timeval_rd1.tv_sec * 1000000;
time_rd1 = (measure_stop_rd1 - measure_start_rd1) / 1000000.0L;
printf("Exec Time reading matrices before preproc = %5.25e (Seconds)\n",time_rd1);
// initialize W, Z_B,Z_C, mu_a, mu_b, mu_c;
SparseMatrix<double> W(NA,KHID); W.resize(NA,KHID); W.makeCompressed();
SparseMatrix<double> Z_B(NA,NB); Z_B.resize(NA,NB); Z_B.makeCompressed();
SparseMatrix<double> Z_C(NA,NC); Z_C.resize(NA,NC); Z_C.makeCompressed();
VectorXd mu_a(NA);
VectorXd mu_b(NB);
VectorXd mu_c(NC);
cout << "----------------------------Before whitening--------------------------" << endl;
gettimeofday(&start_timeval_pre, NULL); // measuring start time for pre processing
second_whiten(Gx_a,Gx_b,Gx_c,W,Z_B,Z_C,mu_a,mu_b,mu_c);
// whitened datapoints
SparseMatrix<double> Data_a_G = W.transpose() * Gx_a.transpose();
VectorXd Data_a_mu = W.transpose() * mu_a;
SparseMatrix<double> Data_b_G = W.transpose() * Z_B * Gx_b.transpose();
VectorXd Data_b_mu = W.transpose() * Z_B * mu_b;
SparseMatrix<double> Data_c_G = W.transpose() * Z_C * Gx_c.transpose();
VectorXd Data_c_mu = W.transpose() * Z_C * mu_c;
gettimeofday(&stop_timeval_pre, NULL); // measuring stop time for pre processing
measure_stop_pre = stop_timeval_pre.tv_usec + (timestamp_t)stop_timeval_pre.tv_sec * 1000000;
measure_start_pre = start_timeval_pre.tv_usec + (timestamp_t)start_timeval_pre.tv_sec * 1000000;
time_pre = (measure_stop_pre - measure_start_pre) / 1000000.0L;
printf("time taken by preprocessing = %5.25e (Seconds)\n",time_pre);
cout << "----------------------------After whitening---------------------------" << endl;
// stochastic updates
VectorXd lambda(KHID);
MatrixXd phi_new(KHID,KHID);
cout << "------------------------------Before tensor decomposition----------------" << endl;
gettimeofday(&start_timeval_stpm, NULL); // measuring start time for stochastic updates
tensorDecom_alpha0(Data_a_G,Data_a_mu,Data_b_G,Data_b_mu,Data_c_G,Data_c_mu,lambda,phi_new);
gettimeofday(&stop_timeval_stpm, NULL); // measuring stop time for stochastic updates
cout << "after tensor decomposition" << endl;
measure_stop_stpm = stop_timeval_stpm.tv_usec + (timestamp_t)stop_timeval_stpm.tv_sec * 1000000;
measure_start_stpm = start_timeval_stpm.tv_usec + (timestamp_t)start_timeval_stpm.tv_sec * 1000000;
time_stpm = (measure_stop_stpm - measure_start_stpm) / 1000000.0L;
cout << "------------------------------After tensor decomposition----------------" << endl;
printf("time taken by stochastic tensor decomposition = %5.25e (Seconds)\n",time_stpm);
//cout << phi_new << endl; // optionally print eigenvectors
cout << "the eigenvalues are:" << endl;
cout << lambda << endl;
// post processing
cout << "------------Reading Gb_a, Gc_a---------"<<endl;
gettimeofday(&start_timeval_rd2, NULL);
#ifdef CalErrALL
// read the matrix Gab and Gac
SparseMatrix<double> Gb_a(NB,NA);Gb_a.resize(NB,NA);
SparseMatrix<double> Gc_a(NC,NA);Gc_a.resize(NC,NA);
Gb_a = read_G_sparse((char *) FILE_Gb_a, "GB_A" ,NB, NA); Gb_a.makeCompressed();
Gc_a = read_G_sparse((char *) FILE_Gc_a ,"GC_A" ,NC, NA); Gc_a.makeCompressed();
// releasing memory of Gx_a, Gx_b, Gx_c;
Gx_b.resize(0,0);Gx_c.resize(0,0);
#endif
MatrixXd Inv_Lambda = (pinv_vector(lambda)).asDiagonal();
SparseMatrix<double> inv_lam_phi = (Inv_Lambda.transpose() * phi_new.transpose()).sparseView();
gettimeofday(&stop_timeval_rd2, NULL);
measure_stop_rd2 = stop_timeval_rd2.tv_usec + (timestamp_t)stop_timeval_rd2.tv_sec * 1000000;
measure_start_rd2 = start_timeval_rd2.tv_usec + (timestamp_t)start_timeval_rd2.tv_sec * 1000000;
time_rd2 = (measure_stop_rd2 - measure_start_rd2) / 1000000.0L;
cout << "------------After reading Gb_a, Gc_a---------"<<endl;
printf("time taken for reading matrices after post processing = %5.25e (Seconds)\n",time_rd2);
cout << "---------------------------Computing pi matrices-----------------------------" << endl;
gettimeofday(&start_timeval_post, NULL); // measuring start time for post processing
SparseMatrix<double> pi_x(KHID,NX);pi_x.reserve(KHID*NX);pi_x.makeCompressed();
SparseMatrix<double> pi_x_tmp1 = inv_lam_phi * W.transpose();
#ifdef CalErrALL
//.........这里部分代码省略.........
示例13: leap_gesture_id
int32_t leap_gesture_id(leap_gesture_ref gesture)
{
return W(gesture).id();
}
示例14: SW
static int16 SW(t_value arg1, t_value arg2)
{
return W(arg1,arg2);
}
示例15: leap_gesture_gesture_type
leap_gesture_type leap_gesture_gesture_type(leap_gesture_ref gesture)
{
return leap_gesture_type(W(gesture).type());
}