void test_deleter_value_category() { typedef typename std::conditional<IsArray, A[], A>::type VT; using TD1 = TrackingDeleter<1>; using TD2 = TrackingDeleter<2>; TD1 d1; TD2 d2; { // Test non-reference deleter conversions using U1 = std::unique_ptr<VT, TD1 >; using U2 = std::unique_ptr<VT, TD2 >; U2 u2; u2.get_deleter().reset(); U1 u1(std::move(u2)); assert(checkArg<TD2&&>(u1.get_deleter())); } { // Test assignment from non-const ref using U1 = std::unique_ptr<VT, TD1 >; using U2 = std::unique_ptr<VT, TD2& >; U2 u2(nullptr, d2); U1 u1(std::move(u2)); assert(checkArg<TD2&>(u1.get_deleter())); } { // Test assignment from const ref using U1 = std::unique_ptr<VT, TD1 >; using U2 = std::unique_ptr<VT, TD2 const& >; U2 u2(nullptr, d2); U1 u1(std::move(u2)); assert(checkArg<TD2 const&>(u1.get_deleter())); } }
main() { eoUniform<float> u1(-2.5,3.5); eoUniform<double> u2(0.003, 0 ); eoUniform<unsigned long> u3( 10000U, 10000000U); std::cout << "u1\t\tu2\t\tu3" << std::endl; for ( unsigned i = 0; i < 100; i ++) { std::cout << u1() << "\t" << u2() << "\t" << u3() << std::endl; } }
int main() { int n; unnamed1 u1(n); u1(); // OK unnamed2 u2(n); u2(); // OK //unnamed3 u3(n); u3(); // Error std::cout << n << "\n"; // "10" lambdas(); }
static void tf512_decrypt(const void* c, const void* i, void* o) { const struct tf512_key_schedule_t* s = c; uint64_t o0, o1, o2, o3, o4, o5, o6, o7; const uint64_t* t = s->t; const uint64_t* k = s->k; o0 = _get_uint64_l(i)-k[0]; o1 = _get_uint64_l(i+8)-k[1]; o2 = _get_uint64_l(i+16)-k[2]; o3 = _get_uint64_l(i+24)-k[3]; o4 = _get_uint64_l(i+32)-k[4]; o5 = _get_uint64_l(i+40)-k[5]-t[0]; o6 = _get_uint64_l(i+48)-k[6]-t[1]; o7 = _get_uint64_l(i+56)-k[7]-18; u2(8,0,1,2,3,4,2,5,0,6,17), u1(7,8,0,1,2,3,1,4,2,5,16); u2(6,7,8,0,1,2,0,3,1,4,15), u1(5,6,7,8,0,1,2,2,0,3,14); u2(4,5,6,7,8,0,1,1,2,2,13), u1(3,4,5,6,7,8,0,0,1,1,12); u2(2,3,4,5,6,7,2,8,0,0,11), u1(1,2,3,4,5,6,1,7,2,8,10); u2(0,1,2,3,4,5,0,6,1,7,9), u1(8,0,1,2,3,4,2,5,0,6,8); u2(7,8,0,1,2,3,1,4,2,5,7), u1(6,7,8,0,1,2,0,3,1,4,6); u2(5,6,7,8,0,1,2,2,0,3,5), u1(4,5,6,7,8,0,1,1,2,2,4); u2(3,4,5,6,7,8,0,0,1,1,3), u1(2,3,4,5,6,7,2,8,0,0,2); u2(1,2,3,4,5,6,1,7,2,8,1), u1(0,1,2,3,4,5,0,6,1,7,0); _put_uint64_l(o, o0); _put_uint64_l(o+8, o1); _put_uint64_l(o+16, o2); _put_uint64_l(o+24, o3); _put_uint64_l(o+32, o4); _put_uint64_l(o+40, o5); _put_uint64_l(o+48, o6); _put_uint64_l(o+56, o7); }
static double Sdebye1(double q, double L, double b) { double arg = u1(q,L,b); return Sdebye_kernel(arg); }
ApproximateES(size_t _N, double _lambda_min, double _lambda_max, EnergyMinimizer* _m , float* _x0 = NULL, size_t _max_iter = 10000, int _verbosity = 0, float* _x1 = NULL): kmc(_lambda_min, _lambda_max), lambda_min(_lambda_min), lambda_max(_lambda_max), N(_N), minimizer(_m), max_iter(_max_iter), verbosity(_verbosity) { e1 = e2 = e3 = 0; short_array x0( new float[N] ); short_array x1( new float[N] ); for(size_t i = 0; i < N; i++) // copy { if(_x0 != NULL ) x0[i] = _x0[i]; else x0[i] = 0; if(_x1 != NULL ) x1[i] = _x1[i]; else x1[i] = x0[i]; } Undefined u1(lambda_min, x0, x0); Undefined u2(lambda_max, x1, x1); Lambda.push(u1); Lambda.push(u2); labelings.push_back( x0 ); labelings.push_back( x1 ); }
void scan3d::triangulate_stereo(const cv::Mat & K1, const cv::Mat & kc1, const cv::Mat & K2, const cv::Mat & kc2, const cv::Mat & Rt, const cv::Mat & T, const cv::Point2d & p1, const cv::Point2d & p2, cv::Point3d & p3d, double * distance) { //to image camera coordinates cv::Mat inp1(1, 1, CV_64FC2), inp2(1, 1, CV_64FC2); inp1.at<cv::Vec2d>(0, 0) = cv::Vec2d(p1.x, p1.y); inp2.at<cv::Vec2d>(0, 0) = cv::Vec2d(p2.x, p2.y); cv::Mat outp1, outp2; cv::undistortPoints(inp1, outp1, K1, kc1); cv::undistortPoints(inp2, outp2, K2, kc2); assert(outp1.type()==CV_64FC2 && outp1.rows==1 && outp1.cols==1); assert(outp2.type()==CV_64FC2 && outp2.rows==1 && outp2.cols==1); const cv::Vec2d & outvec1 = outp1.at<cv::Vec2d>(0,0); const cv::Vec2d & outvec2 = outp2.at<cv::Vec2d>(0,0); cv::Point3d u1(outvec1[0], outvec1[1], 1.0); cv::Point3d u2(outvec2[0], outvec2[1], 1.0); //to world coordinates cv::Point3d w1 = u1; cv::Point3d w2 = cv::Point3d(cv::Mat(Rt*(cv::Mat(u2) - T))); //world rays cv::Point3d v1 = w1; cv::Point3d v2 = cv::Point3d(cv::Mat(Rt*cv::Mat(u2))); //compute ray-ray approximate intersection p3d = approximate_ray_intersection(v1, w1, v2, w2, distance); }
T f1(T t1, U u1, int i1) { T t2 = i1; t2 = i1 + u1; ++u1; u1++; int i2 = u1; i1 = t1[u1]; i1 *= t1; i1(u1, t1); // error u1(i1, t1); U u2 = (T)i1; static_cast<void>(static_cast<U>(reinterpret_cast<T>( dynamic_cast<U>(const_cast<T>(i1))))); new U(i1, t1); new int(t1, u1); new (t1, u1) int; delete t1; dummy d1 = sizeof(t1); // expected-error {{no viable conversion}} dummy d2 = offsetof(T, foo); // expected-error {{no viable conversion}} dummy d3 = __alignof(u1); // expected-error {{no viable conversion}} i1 = typeid(t1); // expected-error {{assigning to 'int' from incompatible type 'const std::type_info'}} return u1; }
int main() { UserDatabase db; User u1(&db); User u2(&db); try{ u1.AddFriend(u2); } catch (...){} std::cout << "u1 countFriends: " << u1.countFriends() << "\n"; std::cout << "u1 fCount : " << u1.fCount << "\n"; try{ u2.AddFriendGuarded(u1); } catch (...){} std::cout << "u2 countFriends: " << u2.countFriends() << "\n"; std::cout << "u2 fCount : " << u2.fCount << "\n"; DoStandaloneFunctionTests(); DoMemberFunctionTests( u1 ); #if defined(__BORLANDC__) || defined(_MSC_VER) system("PAUSE"); #endif }
void Quad10_2D_SUPG :: computeGradUMatrix(FloatMatrix &answer, GaussPoint *gp, TimeStep *tStep) { FloatArray dnx(4), dny(4), u, u1(4), u2(4); FloatMatrix dn; answer.resize(2, 2); answer.zero(); this->computeVectorOfVelocities(VM_Total, tStep, u); velocityInterpolation.evaldNdx( dn, gp->giveNaturalCoordinates(), FEIElementGeometryWrapper(this) ); for ( int i = 1; i <= 4; i++ ) { dnx.at(i) = dn.at(i, 1); dny.at(i) = dn.at(i, 2); u1.at(i) = u.at(2 * i - 1); u2.at(i) = u.at(2 * i); } answer.at(1, 1) = u1.dotProduct(dnx); answer.at(1, 2) = u1.dotProduct(dny); answer.at(2, 1) = u2.dotProduct(dnx); answer.at(2, 2) = u2.dotProduct(dny); }
// Exact solution. double exact_sln_fn_1(double x, double y, double z, double &dx, double &dy, double &dz) { dx = -2 * x * (1 - y*y) * (1 - z*z); dy = -2 * (1 - x*x) * y * (1 - z*z); dz = -2 * (1 - x*x) * (1 - y*y) * z; return u1(x, y, z); }
void testGenerate() { vmime::utility::url u1("proto", "host", 12345, "path", "user", "password"); VASSERT_EQ( "1", "proto://*****:*****@host:12345/path", static_cast <vmime::string>(u1) ); vmime::utility::url u2("proto", "host"); VASSERT_EQ("2", "proto://host", static_cast <vmime::string>(u2)); vmime::utility::url u3("proto", "host"); u3.getParams()["p1"] = "v1"; VASSERT_EQ( "3.1", "proto://host/?p1=v1", static_cast <vmime::string>(u3) ); u3.getParams()["p2"] = "v2"; VASSERT_EQ( "3.2", "proto://host/?p1=v1&p2=v2", static_cast <vmime::string>(u3) ); // Test special characters u3.getParams().clear(); u3.getParams()["&"] = "="; VASSERT_EQ( "3.3", "proto://host/?%26=%3D", static_cast <vmime::string>(u3) ); }
T f2(T x, T y, T z) { T ddxx = 2 * (1 - x*x) * y*y * (1 - y*y) * z*z * (1 - z*z) - 10 * x*x * y*y * (1 - y*y) * z*z * (1 - z*z); T ddyy = 2 * x*x * (1 - x*x) * (1 - y*y) * z*z * (1 - z*z) - 10 * x*x * (1 - x*x) * y*y * z*z * (1 - z*z); T ddzz = 2 * x*x * (1 - x*x) * y*y * (1 - y*y) * (1 - z*z) - 10 * x*x * (1 - x*x) * y*y * (1 - y*y) * z*z; return -(ddxx + ddyy + ddzz) + u1(x, y, z); }
float predictOccupancy(int N) { if( (b_entry_event + b_exit_event)<20.0) { return 0.5f; } ///Testing float ps = getOccStaticLikelihood(); if(ps>0.6) return 0.9; ///end testing float Po = computeShortTermOccupancy(); float Lex = exitL(); float Len = entryL(); Eigen::Matrix2f P; P(0,0) = (1.0-Len); P(0,1) = Len; P(1,0) = Lex; P(1,1) = (1-Lex); Eigen::Vector2f u1(1.0-Po, Po); for(int i=0; i<N; i++) P = P*P; Eigen::Vector2f u = u1.transpose() *P; return u(1); }
void testParse4() { // Test parameters vmime::utility::url u1("", ""); VASSERT_EQ("1.1", true, parseHelper(u1, "proto://host/path?p1=v1&p2=v2")); VASSERT_EQ("1.2", "v1", u1.getParams()["p1"]); VASSERT_EQ("1.3", "v2", u1.getParams()["p2"]); VASSERT_EQ("1.4", "/path", u1.getPath()); vmime::utility::url u2("", ""); VASSERT_EQ("2.1", true, parseHelper(u2, "proto://host/path?p1=v1&p2")); VASSERT_EQ("2.2", "v1", u2.getParams()["p1"]); VASSERT_EQ("2.3", "p2", u2.getParams()["p2"]); VASSERT_EQ("2.4", "/path", u2.getPath()); vmime::utility::url u3("", ""); VASSERT_EQ("3.1", true, parseHelper(u3, "proto://host/?p1=v1&p2=v2")); VASSERT_EQ("3.2", "v1", u3.getParams()["p1"]); VASSERT_EQ("3.3", "v2", u3.getParams()["p2"]); VASSERT_EQ("3.4", "", u3.getPath()); vmime::utility::url u4("", ""); VASSERT_EQ("4.1", true, parseHelper(u4, "proto://host/path?p1=%3D&%3D=v2")); VASSERT_EQ("4.2", "=", u4.getParams()["p1"]); VASSERT_EQ("4.3", "v2", u4.getParams()["="]); VASSERT_EQ("4.4", "/path", u4.getPath()); }
// Exact solutions. double exact_sln_fn_1(double x, double y, double z, double &dx, double &dy, double &dz) { dx = 2 * x; dy = 2 * y; dz = 2 * z; return u1(x, y, z); }
void write_transformed_weak_form(EquationArray const & weak_form, latex_logger<InterfaceType> & log) { // Restriction to the discrete space log << "\\section{Discrete Approximation by Finite Elements}\n"; log << "The discrete approximation to the continuous problem is obtained by a Galerkin approach:\n"; log << "\\begin{align}\n"; log << " u_h = \\sum_j \\alpha_j \\varphi_j \n"; log << "\\end{align}\n"; log << "with trial functions $\\varphi_j$.\n"; //log << "Thus, instead of solving for the continuous function $u$, only the coefficients $\\alpha_i$ need to be computed.\n"; log << "In a Galerkin approach, test functions $v$ are also chosen from a finite-dimensional space:\n"; log << "\\begin{align}\n"; log << " v_h = \\sum_i \\beta_i \\psi_i \n"; log << "\\end{align}\n"; log << "Due to integral transformations, it is sufficient to define the trial and test functions on the reference cell.\n"; log << "After transformation to the reference cell, the weak form on a cell reads\n"; // give new name to local variables: viennamath::variable xi(0); viennamath::variable eta(1); viennamath::variable nu(2); log.translator().customize(xi, "\\xi"); log.translator().customize(eta, "\\eta"); log.translator().customize(nu, "\\nu"); viennamath::function_symbol u0(0, viennamath::unknown_tag<>()); viennamath::function_symbol u1(1, viennamath::unknown_tag<>()); viennamath::function_symbol u2(2, viennamath::unknown_tag<>()); viennamath::function_symbol v0(0, viennamath::test_tag<>()); viennamath::function_symbol v1(1, viennamath::test_tag<>()); viennamath::function_symbol v2(2, viennamath::test_tag<>()); log.translator().customize(u0, "\\tilde{u}_0"); log.translator().customize(u1, "\\tilde{u}_1"); log.translator().customize(u2, "\\tilde{u}_2"); log.translator().customize(v0, "\\tilde{v}_0"); log.translator().customize(v1, "\\tilde{v}_1"); log.translator().customize(v2, "\\tilde{v}_2"); // [JW] switched to $ math expressions, otherwise the equation is cut // off at the right page border ... // //log << "\\begin{align}\n"; log << "\\newline\\newline$\n"; for (typename EquationArray::const_iterator it = weak_form.begin(); it != weak_form.end(); ++it) log << log.translator()(*it) << " \\ . \n"; //log << "\\end{align}\n"; log << "$\\newline\\newline\n"; // //log << "write transformed weak form\n"; }
// '@' symbol in the username part void testParse5() { vmime::utility::url u1("", ""); VASSERT_EQ("1", true, parseHelper(u1, "imap://[email protected]:[email protected]")); VASSERT_EQ("2", "*****@*****.**", u1.getUsername()); VASSERT_EQ("3", "password", u1.getPassword()); VASSERT_EQ("4", "myserver.com", u1.getHost()); }
double Solver::Func_g(double t, double x, double y) { #ifdef __TASK3__ return 0; #endif return (double)(1+u1(t,x,y)* (-2*M_PI*sin(2*M_PI*x))/(cos(2*M_PI*x)+1.5) +u2(t,x,y)*(2*M_PI*cos(2*M_PI*y)) /(sin(2*M_PI*y)+1.5)+2*M_PI*cos(2*M_PI*x)*sin(2*M_PI*y)*exp(t) +2*M_PI*cos(2*M_PI*y)*sin(2*M_PI*x)*exp(-t)); }
/* * Creates a new tile with a random x/y position, width, height, and color, * and adds it to the given tile list. */ void MainWindow::addRandomTile(TileList &tlist) { Tile tile; std::random_device rd; // possibly use the same random numbers every time for testing static std::default_random_engine e(RANDOM ? rd() : 42); std::uniform_int_distribution<unsigned> u1(MIN_COLOR, MAX_COLOR); std::uniform_int_distribution<unsigned> u2(MIN_SIZE, MAX_SIZE); tile.width = u2(e); tile.height = u2(e); std::uniform_int_distribution<unsigned> u3(0, SCENE_WIDTH - tile.width - 1); std::uniform_int_distribution<unsigned> u4(0, SCENE_HEIGHT - tile.height - 1); tile.x = u3(e); tile.y = u4(e); tile.r = u1(e); tile.g = u1(e); tile.b = u1(e); tlist.addTile(tile); }
double Solver::Func_v1(double t, double x, double y, double p_ro, double mu) { #ifdef __TASK3__ return 0; #endif return (double)( u1(t,x,y)*(1 + 2*M_PI*cos(2*M_PI*x)*sin(2*M_PI*y)*exp(t)) + u2(t,x,y)*2*M_PI*sin(2*M_PI*x)* cos(2*M_PI*y)*exp(t) + p_ro*(-2*M_PI*sin(2*M_PI*x))/(cos(2*M_PI*x)+1.5) -mu*exp(-gg(t,x,y))*(4./3.* (-4)*M_PI*M_PI*sin(2*M_PI*x)*sin(2*M_PI*y)*exp(t) - 4*M_PI*M_PI*sin(2*M_PI*x)*sin(2*M_PI*y)*exp(t) + 4./3.*M_PI*M_PI*cos(2*M_PI*x)*cos(2*M_PI*y)*exp(-t) )); }
void testParse3() { // Test decoding vmime::utility::url u1("", ""); VASSERT_EQ("1.1", true, parseHelper(u1, "pro%12to://user%34:pass%56word@ho%78st:12345/pa%abth/")); VASSERT_EQ("1.2", "pro%12to", u1.getProtocol()); // protocol should not be decoded VASSERT_EQ("1.3", "user\x34", u1.getUsername()); VASSERT_EQ("1.4", "pass\x56word", u1.getPassword()); VASSERT_EQ("1.5", "ho\x78st", u1.getHost()); VASSERT_EQ("1.6", 12345, u1.getPort()); VASSERT_EQ("1.7", "/pa\xabth/", u1.getPath()); }
bool __cacl_tbn(xvec3* pTangents , t3DObject* pObject , tFace& face) { xvec3 normal[3]; xvec3 Tangent; xvec3 p[3]; assign(normal[0],pObject->pNormals[face.vertIndex[0]]); assign(normal[1],pObject->pNormals[face.vertIndex[1]]); assign(normal[2],pObject->pNormals[face.vertIndex[2]]); assign(p[0],pObject->pVerts[face.vertIndex[0]]); assign(p[1],pObject->pVerts[face.vertIndex[1]]); assign(p[2],pObject->pVerts[face.vertIndex[2]]); xvec2 uv[3]; assign(uv[0] , pObject->pTexVerts[face.coordIndex[0]]); assign(uv[1] , pObject->pTexVerts[face.coordIndex[1]]); assign(uv[2] , pObject->pTexVerts[face.coordIndex[2]]); xvec3 e1 = p[1] - p[0]; xvec3 e2 = p[2] - p[0]; xvec2 u1 ( uv[1].s - uv[0].s , uv[1].t - uv[0].t ); xvec2 u2 ( uv[2].s - uv[0].s , uv[2].t - uv[0].t ); float det = ( u1.s * u2.t - u2.s * u1.t); if(det == 0.0f) { Tangent = e1; } else { Tangent = u2.t * e1 - u1.t * e2; } //从Normal 和 Tangent里重新计算出Tangent,因为面的Tangent和顶点的Normal可能不垂直 xvec3 final_tangent; for(int i = 0 ;i < 3 ; ++i) { xvec3 binormal = normal[i].cp(Tangent); final_tangent = binormal.cp(normal[i]); final_tangent.normalize(); pTangents[face.vertIndex[i]].x += final_tangent.x; pTangents[face.vertIndex[i]].y += final_tangent.y; pTangents[face.vertIndex[i]].z += final_tangent.z; } return true; }
int sc_main (int argc, char *argv[]) { sc_signal<bool> clear, left_in, right_in; sc_signal<sc_uint<SEL_WIDTH> > sel_op; sc_signal<sc_uint<WIDTH> > data_in, usr_out, expected_usr_out; // Generate clock: sc_clock clock ("usr_clock", 2); // Instantiate design under test before applying stimulus: usr u1 ("usr_u1"); u1.clk (clock); u1.clr (clear); u1.lin (left_in); u1.rin (right_in); u1.select (sel_op); u1.par_in (data_in); u1.q(usr_out); // Instantiate read vectors: read_vectors rv ("read_vectors_rv"); rv.read_clk (clock); rv.read_clear(clear); rv.read_left_in (left_in); rv.read_right_in (right_in); rv.read_sel_op (sel_op); rv.read_data_in (data_in); rv.read_usr_out (expected_usr_out); // Instantiate checking module: check_results cr1 ("check_results_cr1"); cr1.check_clk (clock); cr1.expected_out (expected_usr_out); cr1.actual_out (usr_out); // Tracing: sc_trace_file *tf = sc_create_wif_trace_file ("usrout"); sc_trace (tf, clock, "clock"); sc_trace (tf, clear, "clear"); sc_trace (tf, left_in, "left_in"); sc_trace (tf, right_in, "right_in"); sc_trace (tf, sel_op, "sel_op"); sc_trace (tf, data_in, "data_in"); sc_trace (tf, usr_out, "usr_out"); sc_start (-1); // Run forever. However simulation // stops because of sc_stop() method in module read_vectors. sc_close_wif_trace_file (tf); return (0); }
void OmniRobot::init() { period = 200; xw = 75.0; //mm yw = 75.0; //mm Dw = 50.0; //mm vector<float> u1 (2); u1(0) = c1; u1(1) = c1; vector<float> u2 (2); u2(0) = c1; u2(1) = -c1; vector<float> u3 (2); u3(0) = c1; u3(1) = c1; vector<float> u4 (2); u4(0) = c1; u4(1) = -c1; vector<float> n1 (2); n1(0) = c1; n1(1) = -c1; vector<float> n2 (2); n2(0) = -c1; n2(1) = -c1; vector<float> n3 (2); n3(0) = c1; n3(1) = -c1; vector<float> n4 (2); n4(0) = -c1; n4(1) = -c1; vector<float> b1 (2); b1(0) = xw; b1(1) = yw; vector<float> b2 (2); b2(0) = xw; b2(1) = -yw; vector<float> b3 (2); b3(0) = -xw; b3(1) = -yw; vector<float> b4 (2); b4(0) = -xw; b4(1) = yw; Mt(0,0) = n1(0); Mt(0,1) = n1(1); Mt(0,2) = b1(0)*u1(0) + b1(1)*u1(1); Mt(1,0) = n2(0); Mt(1,1) = n2(1); Mt(1,2) = b2(0)*u2(0) + b2(1)*u2(1); Mt(2,0) = n3(0); Mt(2,1) = n3(1); Mt(2,2) = b3(0)*u3(0) + b3(1)*u3(1); Mt(3,0) = n4(0); Mt(3,1) = n3(1); Mt(3,2) = b4(0)*u4(0) + b4(1)*u4(1); Mt = -1 * Mt; cmd(0) = 0.0; cmd(1) = 0.0; cmd(2) = 0.0; pwm(0) = 0.0; pwm(1) = 0.0; pwm(2) = 0.0; pwm(3) = 0.0; omniState = INIT_MODE; movementMode = ROTATE_MODE; power = 20; pplus = 1; }
void SDTestObject::test<3>() // construction via scalar values // tests both constructor and initialize forms { SDCleanupCheck check; LLSD b1(true); ensureTypeAndValue("construct boolean", b1, true); LLSD b2 = true; ensureTypeAndValue("initialize boolean", b2, true); LLSD i1(42); ensureTypeAndValue("construct int", i1, 42); LLSD i2 =42; ensureTypeAndValue("initialize int", i2, 42); LLSD d1(1.2); ensureTypeAndValue("construct double", d1, 1.2); LLSD d2 = 1.2; ensureTypeAndValue("initialize double", d2, 1.2); LLUUID newUUID; newUUID.generate(); LLSD u1(newUUID); ensureTypeAndValue("construct UUID", u1, newUUID); LLSD u2 = newUUID; ensureTypeAndValue("initialize UUID", u2, newUUID); LLSD ss1(std::string("abc")); ensureTypeAndValue("construct std::string", ss1, "abc"); LLSD ss2 = std::string("abc"); ensureTypeAndValue("initialize std::string",ss2, "abc"); LLSD sl1(std::string("def")); ensureTypeAndValue("construct std::string", sl1, "def"); LLSD sl2 = std::string("def"); ensureTypeAndValue("initialize std::string", sl2, "def"); LLSD sc1("ghi"); ensureTypeAndValue("construct const char*", sc1, "ghi"); LLSD sc2 = "ghi"; ensureTypeAndValue("initialize const char*",sc2, "ghi"); LLDate aDay("2001-10-22T10:11:12.00Z"); LLSD t1(aDay); ensureTypeAndValue("construct LLDate", t1, aDay); LLSD t2 = aDay; ensureTypeAndValue("initialize LLDate", t2, aDay); LLURI path("http://slurl.com/secondlife/Ambleside/57/104/26/"); LLSD p1(path); ensureTypeAndValue("construct LLURI", p1, path); LLSD p2 = path; ensureTypeAndValue("initialize LLURI", p2, path); const char source[] = "once in a blue moon"; std::vector<U8> data; copy(&source[0], &source[sizeof(source)], back_inserter(data)); LLSD x1(data); ensureTypeAndValue("construct vector<U8>", x1, data); LLSD x2 = data; ensureTypeAndValue("initialize vector<U8>", x2, data); }
forceinline int ValSelMed::val(const Space&, SetView x, int) { UnknownRanges<SetView> u1(x); unsigned int i = Iter::Ranges::size(u1) / 2; UnknownRanges<SetView> u2(x); int med = (u2.min()+u2.max()) / 2; ++u2; if (!u2()) { return med; } UnknownRanges<SetView> u3(x); while (i >= u3.width()) { i -= u3.width(); ++u3; } return u3.min() + static_cast<int>(i); }
int main() { std::cout << "\nTesting AuthXml Library"; std::cout << "\n=======================\n\n"; std::cout << " Creating a couple new users\n\n"; userList ulst; user u1("user1","pass1",1); user u2("user2","pass2",2); user u3("admin","password",0); ulst.addUser(u1); ulst.addUser(u2); ulst.addUser(u3); std::cout << "Finding user1's access level, should be 1: " << ulst.getUserByUsername("user1").getAccesslevel() << "\n"; std::cout << "Finding user2's access level, should be 2: " << ulst.getUserByUsername("user2").getAccesslevel() << "\n"; AuthXml::writeXml("test.xml",ulst); std::cout << "----------------------------------\n"; std::string line; std::ifstream xmlFile ("test.xml"); std::string infile; if (xmlFile.is_open()) { while ( xmlFile.good() ) { std::getline(xmlFile,line); infile += line; } xmlFile.close(); } std::cout << infile << std::endl; XmlReader rdr(infile); userList ulst2 = AuthXml::readXml(rdr); std::cout << "\nPrinting user list\n"; std::cout << "----------------------------------\n"; ulst2.prettyPrintUserList(); return 0; }
latex_logger(std::string const & filename) : stream_(filename.c_str()), filename_(filename), something_written(false) { viennamath::function_symbol u0(0, viennamath::unknown_tag<>()); viennamath::function_symbol u1(1, viennamath::unknown_tag<>()); viennamath::function_symbol u2(2, viennamath::unknown_tag<>()); viennamath::function_symbol v0(0, viennamath::test_tag<>()); viennamath::function_symbol v1(1, viennamath::test_tag<>()); viennamath::function_symbol v2(2, viennamath::test_tag<>()); translator_.customize(u0, "u_0"); translator_.customize(u1, "u_1"); translator_.customize(u2, "u_2"); translator_.customize(v0, "v_0"); translator_.customize(v1, "v_1"); translator_.customize(v2, "v_2"); }
void test_nn() { cout << "========= TEST_NN =========" << endl; VectorXd u1(3), u2(3), v1(3), v2(3); u1 << 1,0,0; u2 << 0,1,0; v1 << 1,0,1; v2 << 1,0,-1; MatrixXd A(3,3); A = u1*v1.transpose() + 0.5*u2*v2.transpose(); cout << "Original:" << endl << A << endl; // Since sigma_min = 0.5, this should shrink entries but not alter // zero/non-zero pattern nn_projection(A,0.1); cout << "Projected 0.1:" << endl << A << endl; // This should zero entries corresponding to u2*v2.transpose nn_projection(A,0.7); cout << "Projected 0.7:" << endl << A << endl; }