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; } }
/** * Returns the probability of the cell having dynamics after 2^N * Observations. The larger the N, and higher the value, the more "Semi-static" * is the cell. Note that the filter returns * 0.5 >= P <=1.0 and P = 0.0 only if there is not enough evidence about the * Behaviour */ float computeSemiStaticLikelihood(int N) { if( (b_entry_event + b_exit_event)<20.0 ) { return 0.0f; } Eigen::Matrix2f P; Eigen::Vector2f u2(0, 1.0); Eigen::Vector2f u3(1.0, 0); float Lex = exitL(); float Len = entryL(); Eigen::Vector2f P2,P3; P(0,0) = (1.0-Len); P(0,1) = Len; P(1,0) = Lex; P(1,1) = (1-Lex); for(int i=0; i<N; i++) P = P*P; P2 = u2.transpose() * P; P3 = u3.transpose() * P; float Po = P2(1); float Pu = binaryBayesUpdate(Po, P3(0)); normalizeProb(Pu); return Pu; }
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) ); }
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()); }
void tst_GeoCpp::testVector() { CVector3d u3(1, 2, 3); CVector3d v3(5, 8, 9); QCOMPARE(u3, CVector3d(1, 2, 3)); //QCOMPARE(u3.length(), 3.74166); QCOMPARE(u3.x(), 1.0); QCOMPARE(u3.y(), 2.0); QCOMPARE(u3.z(), 3.0); u3.setX(5); QCOMPARE(u3, CVector3d(5, 2, 3)); QCOMPARE(u3.x(), 5.0); QCOMPARE(u3.y(), 2.0); QCOMPARE(u3.z(), 3.0); QCOMPARE(v3, CVector3d(5, 8, 9)); QCOMPARE(-v3, CVector3d(-5, -8, -9)); QCOMPARE(u3 + v3, CVector3d(10, 10, 12)); QCOMPARE(u3 - v3, CVector3d(0, -6, -6)); QCOMPARE(u3 * 2, CVector3d(10, 4, 6)); QCOMPARE(2 * u3, CVector3d(10, 4, 6)); u3[2] = 456; QCOMPARE(u3, CVector3d(5, 2, 456)); QCOMPARE(u3.x(), 5.0); QCOMPARE(u3.y(), 2.0); QCOMPARE(u3.z(), 456.0); }
int main() { const unit<1,0> u1; const unit<2,0> u2; unit<-1,0> u3( u1 / u2 ); unit< 3,0> u4( u1 * u2 ); }
/* * 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); }
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; }
/* SnmpUInt32( void); SnmpUInt32 (const unsigned long i); SnmpUInt32( const SnmpUInt32 &c); virtual ~SnmpUInt32(); virtual SmiUINT32 get_syntax(); SnmpUInt32& operator=( const unsigned long i); SnmpUInt32& operator=( const SnmpUInt32 &uli); operator unsigned long(); virtual char *to_string(); virtual SnmpSyntax *clone() const; SnmpSyntax& operator=( SnmpSyntax &val); int valid() const; */ static void TestUnsignedInteger32() { // constructors SnmpUInt32 u1; ACE_ASSERT(u1 == def); SnmpUInt32 u2(l); ACE_ASSERT(u2 == l); SnmpUInt32 u3(nl); ACE_ASSERT(u3 == nl); SnmpUInt32 u4(ul); ACE_ASSERT(u4 == ul); SnmpUInt32 u5(i); ACE_ASSERT(u5 == i); SnmpUInt32 u6(ni); ACE_ASSERT(u6 == ni); SnmpUInt32 u7(ui); ACE_ASSERT(u7 == ui); SnmpUInt32 *u8 = new SnmpUInt32(u5); ACE_ASSERT(u8 != 0); delete u8; ACE_DEBUG ((LM_DEBUG, "(%P|%t) u1(\"\") [%u]\n", (unsigned long)u1)); ACE_DEBUG ((LM_DEBUG, "(%P|%t) u2(\"%u\") [%u]\n", l, (unsigned long)u2)); ACE_DEBUG ((LM_DEBUG, "(%P|%t) u3(\"%u\") [%u]\n", nl, (unsigned long)u3)); ACE_DEBUG ((LM_DEBUG, "(%P|%t) u4(\"%u\") [%u]\n", ul, (unsigned long)u4)); ACE_DEBUG ((LM_DEBUG, "(%P|%t) u5(\"%u\") [%u]\n", i, (unsigned long)u5)); ACE_DEBUG ((LM_DEBUG, "(%P|%t) u6(\"%u\") [%u]\n", ni, (unsigned long)u6)); ACE_DEBUG ((LM_DEBUG, "(%P|%t) u7(\"%u\") [%u]\n", ui, (unsigned long)u7)); // assignent u1 = u2; // obj ACE_ASSERT(u1 == u2); u1 = u1; // self ACE_ASSERT(u1 == u1); u1 = def; // unsigned long ACE_ASSERT(u1 == def); u1 = us; // unsigned short ACE_ASSERT(u1 == us); u1 = si; // unsigned short ACE_ASSERT(u1 == si); }
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; }
void testParse2() { // Now, test some ill-formed URLs // -- missing protocol vmime::utility::url u1("", ""); VASSERT_EQ("1", false, parseHelper(u1, "://host")); // -- port can contain only digits vmime::utility::url u2("", ""); VASSERT_EQ("2", false, parseHelper(u2, "proto://host:abc123")); // -- no host specified vmime::utility::url u3("", ""); VASSERT_EQ("3", false, parseHelper(u3, "proto:///path")); // -- no protocol separator (://) vmime::utility::url u4("", ""); VASSERT_EQ("4", false, parseHelper(u4, "protohost/path")); }
TEST(sql_Book_on_shelf, all_base_operations) { soci::session sql(dal::soci_session_factory(), true); sql.begin(); dal::BookOnShelf r(sql); boost::uuids::random_generator gen; bl::db_id b1( gen()); bl::db_id b2( gen()); bl::db_id b3( gen()); bl::db_id s1( gen()); bl::db_id s2( gen()); bl::db_id s3( gen()); std::pair<bl::db_id, bl::db_id> u1(b1,s1); std::pair<bl::db_id, bl::db_id> u2(b2,s2); std::pair<bl::db_id, bl::db_id> u3(b2,s3); std::pair<bl::db_id, bl::db_id> u4(b3,s2); EXPECT_EQ(0,r.count()); r.insert(u1); r.insert(u2); r.insert(u3); r.insert(u4); EXPECT_EQ(4,r.count()); std::list<std::pair<bl::db_id, bl::db_id> > result; result = r.rows_shelfs_for_book(b1.id()); EXPECT_EQ(1,result.size()); std::pair<bl::db_id, bl::db_id> from_data_base(result.front()); EXPECT_TRUE( u1 == from_data_base); result = r.rows_book_on_shelf( s1.id()); EXPECT_EQ(1,result.size()); from_data_base = result.front(); EXPECT_TRUE( u1 == from_data_base); EXPECT_EQ(1,r.count_shelf(s1.id())); EXPECT_EQ(1,r.count_books(b1.id())); EXPECT_EQ(1,r.count_books(b3.id())); EXPECT_EQ(2,r.count_shelf(s2.id())); EXPECT_EQ(2,r.count_books(b2.id())); r.del_book_records(b2.id()); EXPECT_EQ(0,r.count_books(b2.id())); EXPECT_EQ(1,r.count_shelf(s2.id())); r.del_shelf_records(s2.id()); EXPECT_EQ(0,r.count_shelf(s2.id())); EXPECT_EQ(1,r.count()); r.delete_all_rows(); EXPECT_EQ(0,r.count()); try { r.insert(u1); r.insert(u1);//must throw EXPECT_TRUE(false); } catch (...) { } sql.rollback(); }
int main() { bi::endian_log = false; // make sure some simple things work bi::big32_t o1(1); bi::big32_t o2(2L); bi::big32_t o3(3LL); bi::big64_t o4(1); // use cases; if BOOST_ENDIAN_LOG is defined, will output to clog info on // what overloads and conversions are actually being performed. bi::endian_log = true; std::clog << "set up test values\n"; bi::big32_t big(12345); bi::ulittle16_t ulittle(10); bi::big64_t result; std::clog << "\nresult = +big\n"; result = +big; std::clog << "\nresult = -big\n"; result = -big; std::clog << "\n++big\n"; ++big; std::clog << "\nresult = big++\n"; result = big++; std::clog << "\n--big\n"; --big; std::clog << "\nbig--\n"; big--; std::clog << "\nresult = big * big\n"; result = big * big; std::clog << "\nresult = big * big\n"; result = big * big; std::clog << "\nresult = big * ulittle\n"; result = big * ulittle; std::clog << "\nbig *= ulittle\n"; big *= ulittle; std::clog << "\nresult = ulittle * big\n"; result = ulittle * big; std::clog << "\nresult = big * 5\n"; result = big * 5; std::clog << "\nbig *= 5\n"; big *= 5; std::clog << "\nresult = 5 * big\n"; result = 5 * big; std::clog << "\nresult = ulittle * 5\n"; result = ulittle * 5; std::clog << "\nresult = 5 * ulittle\n"; result = 5 * ulittle; std::clog << "\nresult = 5 * 10\n"; result = 5 * 10; std::clog << "\n"; bi::endian_log = false; // test from Roland Schwarz that detected ambiguities unsigned u; bi::ulittle32_t u1; bi::ulittle32_t u2; u = 1; u1 = 1; u2 = u1 + u; // one more wrinkle bi::ulittle16_t u3(3); u3 = 3; u2 = u1 + u3; // perform the indicated test on ~60*60 operand types op_test<default_construct>(); op_test<construct>(); // includes copy construction op_test<initialize>(); op_test<assign>(); op_test<relational>(); op_test<op_plus>(); op_test<op_star>(); return 0; }
int main() { std::cout.setf(std::ios_base::boolalpha); std::polynomial<double> P({0.0, 1.0, 2.0, 3.0}); std::cout << "P = " << P << std::endl; std::cout << "+P = " << +P << std::endl; std::cout << "-P = " << -P << std::endl; std::cout << "P = " << P << std::endl; std::cout << "degree(P) = " << P.degree() << std::endl; std::polynomial<double> Q({2.0, 1.0}); std::cout << "Q = " << Q << std::endl; std::cout << "degree(Q) = " << Q.degree() << std::endl; std::cout << "P + Q = " << P + Q << std::endl; std::cout << "P - Q = " << P - Q << std::endl; std::cout << "P * Q = " << P * Q << std::endl; std::cout << "P / Q = " << P / Q << std::endl; std::cout << "P % Q = " << P % Q << std::endl; double b = 5.0; std::cout << "b = " << b << std::endl; std::cout << "P + b = " << P + b << std::endl; std::cout << "P - b = " << P - b << std::endl; std::cout << "P * b = " << P * b << std::endl; std::cout << "P / b = " << P / b << std::endl; std::cout << "P % b = " << P % b << std::endl; double a = 2.0; std::cout << "a = " << a << std::endl; std::cout << "a + Q = " << a + Q << std::endl; std::cout << "a - Q = " << a - Q << std::endl; std::cout << "a * Q = " << a * Q << std::endl; std::cout << "a / Q = " << a / Q << std::endl; std::cout << "a % Q = " << a % Q << std::endl; std::polynomial<double> B;// = b; B = b; std::cout << "B = " << B << std::endl; std::cout << "P % B = " << P % B << std::endl; Q = {0.0, -2.0, 4.0, -6.0, 8.0, -12.0}; std::cout << "Q = " << Q << std::endl; std::polynomial<double> P2; P2 = P; std::cout << "P2 = " << P2 << std::endl; std::cout << "P2 == P = " << (P2 == P) << std::endl; for (int i = 0; i <= 100; ++i) { double x = i * 0.1; std::cout << "P(" << x << ") = " << P(x) << std::endl; } std::polynomial<std::complex<double>> CP({std::complex<double>(0.0, -1.0), std::complex<double>(1.0, -2.0), std::complex<double>(2.0, -3.0), std::complex<double>(3.0, -4.0)}); std::cout << "CP = " << CP << std::endl; std::cout << "CP * CP = " << CP * CP << std::endl; std::polynomial<int> IP({0, 1, 2, 3}); std::cout << "IP = " << IP << std::endl; std::cout << "IP * IP = " << IP * IP << std::endl; std::array<double, 10> arr; P.eval(1.0, arr); std::cout << "P(" << 1.0 << ") ="; for (int i = 0; i < arr.size(); ++i) std::cout << " " << arr[i]; std::cout << std::endl; P.eval(1.0, arr.begin(), arr.end()); std::cout << "P(" << 1.0 << ") ="; for (auto iarr = arr.cbegin(); iarr != arr.cend(); ++iarr) std::cout << " " << *iarr; std::cout << std::endl; std::istringstream is("(-2.0, -1.0, 0.0)"); std::polynomial<double> R; is >> R; std::cout << "R = " << R << std::endl; std::istringstream is2("(5.0)"); std::polynomial<double> S; is2 >> S; std::cout << "S = " << S << std::endl; std::istringstream is3("42.0"); std::polynomial<double> T; is3 >> T; std::cout << "T = " << T << std::endl; std::polynomial<double> u({1.0, 3.0, 3.0, 1.0}); std::polynomial<double> v({1.0, 1.0}); std::polynomial<double> q, r; std::divmod(u, v, q, r); std::cout << "u = " << u << std::endl; std::cout << "v = " << v << std::endl; std::cout << "q = " << q << std::endl; std::cout << "r = " << r << std::endl; std::polynomial<double> u1({1.0, -3.0, 3.0, -1.0}); std::polynomial<double> v1({1.0, -2.0, 1.0}); std::polynomial<double> q1, r1; std::divmod(u1, v1, q1, r1); std::cout << "u1 = " << u1 << std::endl; std::cout << "v1 = " << v1 << std::endl; std::cout << "q1 = " << q1 << std::endl; std::cout << "r1 = " << r1 << std::endl; std::polynomial<double> u2({1.0, 1.0}); std::polynomial<double> v2({1.0, 3.0, 3.0, 1.0}); std::polynomial<double> q2, r2; std::divmod(u2, v2, q2, r2); std::cout << "u2 = " << u2 << std::endl; std::cout << "v2 = " << v2 << std::endl; std::cout << "q2 = " << q2 << std::endl; std::cout << "r2 = " << r2 << std::endl; std::polynomial<double> u3({1.0, 0.0, 0.0, 1.0}); std::polynomial<double> v3({1.0, 3.0, 3.0, 1.0}); std::polynomial<double> q3, r3; std::divmod(u3, v3, q3, r3); std::cout << "u3 = " << u3 << std::endl; std::cout << "v3 = " << v3 << std::endl; std::cout << "q3 = " << q3 << std::endl; std::cout << "r3 = " << r3 << std::endl; std::cout << "P = " << P << std::endl; std::cout << "P' = " << P.derivative() << std::endl; std::cout << "I = " << P.integral(42.0) << std::endl; //std::array<double, 5> aaa{{1.1, 2.2, 3.3, 4.4, 5.5}}; //std::cout << "aaa = " << std::polynomial_eval(aaa, 3.13149) << std::endl; }
void test() { //tests DRMatrix m1(DRMatrix::identity()); float mat[] = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; if(memcmp(m1, mat, sizeof(float)*16) != 0) LOG_WARNING("matrix identity isn't valid"); DRMatrix m2 = m1.rotationX(30.0f); DRMatrix m3 = DRMatrix::axis(DRVector3(1.0f, 0.0f, 0.0f), DRVector3(0.0f, 1.0f, 0.0f), DRVector3(0.0f, 0.0f, 1.0)); if(memcmp(m1, m3, sizeof(float)*16) != 0) LOG_WARNING("matrix axis isn't valid"); DREngineLog.writeMatrixToLog(m1); DREngineLog.writeMatrixToLog(m2); DREngineLog.writeMatrixToLog(m3); DRVector3 rot1(1.0f, 0.0f, 0.0f); m2 = DRMatrix::rotationY(90.0f); rot1 = rot1.transformCoords(m2); DREngineLog.writeVector3ToLog(rot1, "1/0/0 90 Grad um y-Achse rotiert"); rot1 = rot1.transformCoords(m2.invert()); DREngineLog.writeVector3ToLog(rot1, "zurueckrotiert, 1/0/0 erwartet!"); DREngineLog.writeToLog("RekursionTest: %d", rekursionTest(0)); //Speicher test /* LOG_INFO("Speichertest"); std::list<void*> pointer; void* t = NULL; u32 count = 0; do { t = malloc(16384); if(t) pointer.push_back(t); count++; if(count > 192073) break; } while(t); DRLog.writeToLog("count: %d, %u kByte wurden reserviert!", count, count*16384/1024); for(std::list<void*>::iterator it = pointer.begin(); it != pointer.end(); it++) free(*it); pointer.clear(); //* */ // Unit test printf("\n"); Unit parsec(1.0, PARSEC); Unit lj = parsec.convertTo(LIGHTYEAR); DREngineLog.writeToLog("%s -> %s", parsec.print().data(), lj.print().data()); lj = Unit(1.0, LIGHTYEAR); parsec = lj.convertTo(PARSEC); DREngineLog.writeToLog("%s -> %s", lj.print().data(), parsec.print().data()); Unit ae = lj.convertTo(AE); DREngineLog.writeToLog("%s -> %s", lj.print().data(), ae.print().data()); ae = parsec.convertTo(AE); DREngineLog.writeToLog("%s -> %s", parsec.print().data(), ae.print().data()); parsec = ae.convertTo(PARSEC); DREngineLog.writeToLog("%s -> %s", ae.print().data(), parsec.print().data()); Unit m = parsec.convertTo(M); DREngineLog.writeToLog("%s -> %s", parsec.print().data(), m.print().data()); Unit kpc(1.0, KILOPARSEC); m = kpc.convertTo(M); DREngineLog.writeToLog("%s -> %s", kpc.print().data(), m.print().data()); m = Unit(1.0, M); kpc = m.convertTo(KILOPARSEC); DREngineLog.writeToLog("%s -> %s", m.print().data(), kpc.print().data()); printf("\n"); Unit aes(0.005, AE); DREngineLog.writeToLog("%s -> %s", aes.print().data(), aes.convertTo(KM).print().data()); //Vector Unit Test Vector3Unit u1(100, 200, 70, M), u2(1, 0, 0, KILOPARSEC), u3(100, 20, 17, LIGHTYEAR); u1.print("u1"); u2.print("u2"); u3.print("u3"); u1 *= Unit(20, KM); u1.print("u1* 20 km"); Vector3Unit(u1 + u2).print("u1+u2"); Vector3Unit(u2+u3).print("u2+u3"); Vector3Unit(u1*Unit(1, LIGHTYEAR)).print("u1*1 Lichtjahr"); DRVector3 v(1.0f, 7.0f, 2.0f); DREngineLog.writeVector3ToLog(v, "init"); v = v.normalize(); DREngineLog.writeVector3ToLog(v, "normalized"); v *= 7.0f; DREngineLog.writeVector3ToLog(v, "multiplikator"); // ---------------------------------- ReferenzHolder Test -------------------------------- DREngineLog.writeToLog("DRIndexReferenzHolder test"); DRIndexReferenzHolder referenzHolder(10); uint tests[10]; tests[0] = referenzHolder.getFree(); referenzHolder.add(tests[0]); tests[1] = referenzHolder.getFree(); DREngineLog.writeToLog("index1 (0): %d, index2 (1): %d", tests[0], tests[1]); referenzHolder.remove(tests[0]); tests[2] = referenzHolder.getFree(); referenzHolder.remove(tests[1]); tests[3] = referenzHolder.getFree(); DREngineLog.writeToLog("index3 (2): %d, index4 (1): %d", tests[2], tests[3]); for(int i = 0; i < 5; i++) tests[4+i] = referenzHolder.getFree(); referenzHolder.remove(tests[7]); tests[9] = referenzHolder.getFree(); DREngineLog.writeToLog("index10: (6): %d", tests[9]); DRTextureManager::Instance().test(); // Random Test }
int cpp_main(int, char * []) { be::endian_log = false; // make sure some simple things work be::big_int32_t o1(1); be::big_int32_t o2(2L); be::big_int32_t o3(3LL); be::big_int64_t o4(1); // use cases; if BOOST_ENDIAN_LOG is defined, will output to clog info on // what overloads and conversions are actually being performed. be::endian_log = true; std::clog << "set up test values\n"; be::big_int32_t big(12345); be::little_uint16_t little_u(10); be::big_int64_t result; // this is the use case that is so irritating that it caused the endian // constructors to be made non-explicit std::clog << "\nf(1234) where f(big_int32_t)\n"; f_big_int32_t(1234); std::clog << "\nresult = big\n"; result = big; std::clog << "\nresult = +big\n"; result = +big; std::clog << "\nresult = -big\n"; result = -big; std::clog << "\n++big\n"; ++big; std::clog << "\nresult = big++\n"; result = big++; std::clog << "\n--big\n"; --big; std::clog << "\nbig--\n"; big--; std::clog << "\nresult = big * big\n"; result = big * big; std::clog << "\nresult = big * big\n"; result = big * big; std::clog << "\nresult = big * little_u\n"; result = big * little_u; std::clog << "\nbig *= little_u\n"; big *= little_u; std::clog << "\nresult = little_u * big\n"; result = little_u * big; std::clog << "\nresult = big * 5\n"; result = big * 5; std::clog << "\nbig *= 5\n"; big *= 5; std::clog << "\nresult = 5 * big\n"; result = 5 * big; std::clog << "\nresult = little_u * 5\n"; result = little_u * 5; std::clog << "\nresult = 5 * little_u\n"; result = 5 * little_u; std::clog << "\nresult = 5 * 10\n"; result = 5 * 10; std::clog << "\n"; // test from Roland Schwarz that detected ambiguities; these ambiguities // were eliminated by BOOST_MINIMAL_INTEGER_COVER_OPERATORS unsigned u; be::little_uint32_t u1; be::little_uint32_t u2; u = 9; u1 = 1; std::clog << "\nu2 = u1 + u\n"; u2 = u1 + u; std::clog << "\n"; // one more wrinkle be::little_uint16_t u3(3); u3 = 3; std::clog << "\nu2 = u1 + u3\n"; u2 = u1 + u3; std::clog << "\n"; be::endian_log = false; // perform the indicated test on ~60*60 operand types op_test<default_construct>(); op_test<construct>(); // includes copy construction op_test<initialize>(); op_test<assign>(); op_test<relational>(); op_test<op_plus>(); op_test<op_star>(); return 0; }
void TestBandMatrixArith_D1() { std::vector<tmv::BandMatrixView<T> > b; std::vector<tmv::BandMatrixView<std::complex<T> > > cb; MakeBandList(b,cb); const int N = b[0].rowsize(); tmv::Matrix<T> a1(N,N); for (int i=0; i<N; ++i) for (int j=0; j<N; ++j) a1(i,j) = T(3+i-5*j); tmv::Matrix<std::complex<T> > ca1(N,N); for (int i=0; i<N; ++i) for (int j=0; j<N; ++j) ca1(i,j) = std::complex<T>(3+i-5*j,4-8*i-j); tmv::UpperTriMatrix<T,tmv::NonUnitDiag|tmv::RowMajor> u1(a1); tmv::UpperTriMatrix<std::complex<T>,tmv::NonUnitDiag|tmv::RowMajor> cu1(ca1); tmv::UpperTriMatrixView<T> u1v = u1.view(); tmv::UpperTriMatrixView<std::complex<T> > cu1v = cu1.view(); tmv::UpperTriMatrix<T,tmv::NonUnitDiag> u1x = u1v; tmv::UpperTriMatrix<std::complex<T>,tmv::NonUnitDiag> cu1x = cu1v; #if (XTEST & 2) tmv::UpperTriMatrix<T,tmv::UnitDiag|tmv::RowMajor> u2(a1); tmv::UpperTriMatrix<T,tmv::NonUnitDiag|tmv::ColMajor> u3(a1); tmv::UpperTriMatrix<T,tmv::UnitDiag|tmv::ColMajor> u4(a1); tmv::LowerTriMatrix<T,tmv::NonUnitDiag|tmv::RowMajor> l1(a1); tmv::LowerTriMatrix<T,tmv::UnitDiag|tmv::RowMajor> l2(a1); tmv::LowerTriMatrix<T,tmv::NonUnitDiag|tmv::ColMajor> l3(a1); tmv::LowerTriMatrix<T,tmv::UnitDiag|tmv::ColMajor> l4(a1); tmv::UpperTriMatrix<std::complex<T>,tmv::UnitDiag|tmv::RowMajor> cu2(ca1); tmv::UpperTriMatrix<std::complex<T>,tmv::NonUnitDiag|tmv::ColMajor> cu3(ca1); tmv::UpperTriMatrix<std::complex<T>,tmv::UnitDiag|tmv::ColMajor> cu4(ca1); tmv::LowerTriMatrix<std::complex<T>,tmv::NonUnitDiag|tmv::RowMajor> cl1(ca1); tmv::LowerTriMatrix<std::complex<T>,tmv::UnitDiag|tmv::RowMajor> cl2(ca1); tmv::LowerTriMatrix<std::complex<T>,tmv::NonUnitDiag|tmv::ColMajor> cl3(ca1); tmv::LowerTriMatrix<std::complex<T>,tmv::UnitDiag|tmv::ColMajor> cl4(ca1); tmv::UpperTriMatrixView<T> u2v = u2.view(); tmv::UpperTriMatrixView<T> u3v = u3.view(); tmv::UpperTriMatrixView<T> u4v = u4.view(); tmv::LowerTriMatrixView<T> l1v = l1.view(); tmv::LowerTriMatrixView<T> l2v = l2.view(); tmv::LowerTriMatrixView<T> l3v = l3.view(); tmv::LowerTriMatrixView<T> l4v = l4.view(); tmv::UpperTriMatrixView<std::complex<T> > cu2v = cu2.view(); tmv::UpperTriMatrixView<std::complex<T> > cu3v = cu3.view(); tmv::UpperTriMatrixView<std::complex<T> > cu4v = cu4.view(); tmv::LowerTriMatrixView<std::complex<T> > cl1v = cl1.view(); tmv::LowerTriMatrixView<std::complex<T> > cl2v = cl2.view(); tmv::LowerTriMatrixView<std::complex<T> > cl3v = cl3.view(); tmv::LowerTriMatrixView<std::complex<T> > cl4v = cl4.view(); #endif for(size_t i=START;i<b.size();i++) { if (showstartdone) { std::cerr<<"Start loop "<<i<<std::endl; std::cerr<<"bi = "<<b[i]<<std::endl; } tmv::BandMatrixView<T> bi = b[i]; tmv::BandMatrixView<std::complex<T> > cbi = cb[i]; TestMatrixArith4(bi,cbi,u1v,cu1v,"Band/UpperTri"); TestMatrixArith5(bi,cbi,u1v,cu1v,"Band/UpperTri"); TestMatrixArith6x(bi,cbi,u1v,cu1v,"Band/UpperTri"); #if (XTEST & 2) TestMatrixArith4(bi,cbi,l1v,cl1v,"Band/LowerTri"); TestMatrixArith5(bi,cbi,l1v,cl1v,"Band/LowerTri"); TestMatrixArith6x(bi,cbi,l1v,cl1v,"Band/LowerTri"); TestMatrixArith4(bi,cbi,u2v,cu2v,"Band/UpperTri"); TestMatrixArith5(bi,cbi,u2v,cu2v,"Band/UpperTri"); TestMatrixArith6x(bi,cbi,u2v,cu2v,"Band/UpperTri"); TestMatrixArith4(bi,cbi,l2v,cl2v,"Band/LowerTri"); TestMatrixArith5(bi,cbi,l2v,cl2v,"Band/LowerTri"); TestMatrixArith6x(bi,cbi,l2v,cl2v,"Band/LowerTri"); TestMatrixArith4(bi,cbi,u3v,cu3v,"Band/UpperTri"); TestMatrixArith5(bi,cbi,u3v,cu3v,"Band/UpperTri"); TestMatrixArith6x(bi,cbi,u3v,cu3v,"Band/UpperTri"); TestMatrixArith4(bi,cbi,l3v,cl3v,"Band/LowerTri"); TestMatrixArith5(bi,cbi,l3v,cl3v,"Band/LowerTri"); TestMatrixArith6x(bi,cbi,l3v,cl3v,"Band/LowerTri"); TestMatrixArith4(bi,cbi,u4v,cu4v,"Band/UpperTri"); TestMatrixArith5(bi,cbi,u4v,cu4v,"Band/UpperTri"); TestMatrixArith6x(bi,cbi,u4v,cu4v,"Band/UpperTri"); TestMatrixArith4(bi,cbi,l4v,cl4v,"Band/LowerTri"); TestMatrixArith5(bi,cbi,l4v,cl4v,"Band/LowerTri"); TestMatrixArith6x(bi,cbi,l4v,cl4v,"Band/LowerTri"); #endif } }
void testParse1() { // Test some valid constructions vmime::utility::url u1("", ""); VASSERT_EQ("1.1", true, parseHelper(u1, "protocol://*****:*****@host:12345/path/")); VASSERT_EQ("1.2", "protocol", u1.getProtocol()); VASSERT_EQ("1.3", "user", u1.getUsername()); VASSERT_EQ("1.4", "password", u1.getPassword()); VASSERT_EQ("1.5", "host", u1.getHost()); VASSERT_EQ("1.6", 12345, u1.getPort()); VASSERT_EQ("1.7", "/path/", u1.getPath()); vmime::utility::url u2("", ""); VASSERT_EQ("2.1", true, parseHelper(u2, "protocol://user@host:12345/path/")); VASSERT_EQ("2.2", "protocol", u2.getProtocol()); VASSERT_EQ("2.3", "user", u2.getUsername()); VASSERT_EQ("2.4", "", u2.getPassword()); VASSERT_EQ("2.5", "host", u2.getHost()); VASSERT_EQ("2.6", 12345, u2.getPort()); VASSERT_EQ("2.7", "/path/", u2.getPath()); vmime::utility::url u3("", ""); VASSERT_EQ("3.1", true, parseHelper(u3, "protocol://host:12345/path/")); VASSERT_EQ("3.2", "protocol", u3.getProtocol()); VASSERT_EQ("3.3", "", u3.getUsername()); VASSERT_EQ("3.4", "", u3.getPassword()); VASSERT_EQ("3.5", "host", u3.getHost()); VASSERT_EQ("3.6", 12345, u3.getPort()); VASSERT_EQ("3.7", "/path/", u3.getPath()); vmime::utility::url u4("", ""); VASSERT_EQ("4.1", true, parseHelper(u4, "protocol://host/path/")); VASSERT_EQ("4.2", "protocol", u4.getProtocol()); VASSERT_EQ("4.3", "", u4.getUsername()); VASSERT_EQ("4.4", "", u4.getPassword()); VASSERT_EQ("4.5", "host", u4.getHost()); VASSERT_EQ("4.6", vmime::utility::url::UNSPECIFIED_PORT, u4.getPort()); VASSERT_EQ("4.7", "/path/", u4.getPath()); vmime::utility::url u5("", ""); VASSERT_EQ("5.1", true, parseHelper(u5, "protocol://host/")); VASSERT_EQ("5.2", "protocol", u5.getProtocol()); VASSERT_EQ("5.3", "", u5.getUsername()); VASSERT_EQ("5.4", "", u5.getPassword()); VASSERT_EQ("5.5", "host", u5.getHost()); VASSERT_EQ("5.6", vmime::utility::url::UNSPECIFIED_PORT, u4.getPort()); VASSERT_EQ("5.7", "", u5.getPath()); vmime::utility::url u6("", ""); VASSERT_EQ("6.1", true, parseHelper(u4, "protocol://host/path/file")); VASSERT_EQ("6.2", "protocol", u4.getProtocol()); VASSERT_EQ("6.3", "", u4.getUsername()); VASSERT_EQ("6.4", "", u4.getPassword()); VASSERT_EQ("6.5", "host", u4.getHost()); VASSERT_EQ("6.6", vmime::utility::url::UNSPECIFIED_PORT, u4.getPort()); VASSERT_EQ("6.7", "/path/file", u4.getPath()); }
void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); gluLookAt(r*cos(c*du), h, r*sin(c*du), 0, 0, 0, 0, 3, 0); //head position;eye direction(0.0,0.0,0.0),original point;(0.0,1.0,0.0),head above direction¡£ //cylinder a(1, 15, 0, 90, 0, 0, 5, 0); //r,h,xangle yangle zangle, module position(xx yy zz) //sphere b(3, 100, 100, 0, 0, 0, 0, 2.5, 0); //r,xangle yangle zangle, module position(xx yy zz) //cube c(5, 10, 0, 0, 1, 1, 1); //length xangle yangle zangle, module position(xx yy zz) //rectangularpyramid d(4, 0, 0, 0, 0, 2, 0); //length xangle yangle zangle, module position(xx yy zz) //triangularpyramid f(2, 0, 0, 0, 8, 8, 8);//length xangle yangle zangle, module position(xx yy zz) //f.draw(); sphere sp(3, 100, 100, 0, 0, -2, 0, 8, 0); cylinder cy(3, 5, 0, 90, 0, -3, 9, -10); cube cu(3, 0, 0, 0, 0, 8, 10); triangularpyramid tr(2, 0, 0, 0, 0, -6, 8); rectangularpyramid rec(2, 0, 0, 0, 0, -6, -8); cylinder k1(0.3, 2, 90, 0, 0, 0, 0, 0); cylinder k2(0.3, 2, -90, 0, 0, 0, 0, 0); cylinder k3(0.3, 2, -45, 0, 0, 0, 0, 0); cylinder k4(0.3, 2.5, 45, 0, 0, 0, 0, 0); cylinder u1(0.3, 2, 90, 0, 0, 0, 0, 3); cylinder u2(0.3, 1.5, -90, 0, 0, 0, 0, 3); cylinder u3(0.3, 2, 0, 0, 0, 0, -1.8, 3); cylinder u4(0.3, 2, 90, 0, 0, 0, 0, 5); cylinder u5(0.3, 1.5, -90, 0, 0, 0, 0, 5); cylinder g1(0.3, 2, -90, 0, 0, 0, -0.5, 6.4); cylinder g2(0.3, 1.5, -90, 0, 0, 0, -0.5, 6.4); cylinder g3(0.3, 2, 0, 0, 0, 0, -0.3, 6.4); cylinder g4(0.3, 2, 0, 0, 0, 0, 1.3, 6.4); cylinder g5(0.3, 2, 90, 0, 0, 0, 0, 8.4); cylinder g6(0.3, 1.5, -90, 0, 0, 0, 0, 8.4); cylinder g7(0.3, 2, 0, 0, 0, 0, -1.8, 6.4); cylinder e1(0.3, 1.8, -90, 0, 0, 0, -0.2, 10); cylinder e2(0.3, 1.8, 90, 0, 0, 0, -0.2, 10); cylinder e3(0.3, 2, 0, 0, 0, 0, -0.3, 10); cylinder e4(0.3, 2, 0, 0, 0, 0, 1.3, 10); cylinder e5(0.3, 2, 0, 0, 0, 0, -1.8, 10); cylinder r1(0.3, 1.8, -90, 0, 0, 0, -0.2, 13.5); cylinder r2(0.3, 1.8, 90, 0, 0, 0, -0.2, 13.5); cylinder r3(0.3, 2, 0, 0, 0, 0, -0.3, 13.5); cylinder r4(0.3, 1.2, 0, 0, 0, 0, 1.3, 13.5); cylinder r5(0.3, 1.7, 60, 0, 0, 0, 1.3, 14.5); cylinder r6(0.3, 2.5, 45, 0, 0, 0, 0, 13.5); cylinder c1(0.3, 2, 90, 0, 0, 0, 0, -15); cylinder c2(0.3, 2, -90, 0, 0, 0, 0, -15); cylinder c3(0.3, 3, 0, 0, 0, 0, -1.8, -15); cylinder c4(0.3, 3, 0, 0, 0, 0, 1.8, -15); cylinder plus1(0.3,3.5, 0, 0, 0, 0, 0, -11); cylinder plus2(0.3, 4, 90, 0, 0, 0, 2, -9.2); cylinder plus3(0.3, 3.5, 0, 0, 0, 0, 0, -6); cylinder plus4(0.3, 4, 90, 0, 0, 0, 2, -4.2); cy.draw(); sp.draw(); cu.draw(); tr.draw(); rec.draw(); k1.draw(); k2.draw(); k3.draw(); k4.draw(); u1.draw(); u2.draw(); u3.draw(); u4.draw(); u5.draw(); g1.draw(); g2.draw(); g3.draw(); g4.draw(); g5.draw(); g6.draw(); g7.draw(); e1.draw(); e2.draw(); e3.draw(); e4.draw(); e5.draw(); r1.draw(); r2.draw(); r3.draw(); r4.draw(); r5.draw(); r6.draw(); c1.draw(); c2.draw(); c3.draw(); c4.draw(); plus1.draw(); plus2.draw(); plus3.draw(); plus4.draw(); glFlush(); }