void LongLongTestCase::Multiplication() { for ( size_t n = 0; n < ITEMS; n++ ) { wxLongLong a = RAND_LL(); wxLongLong b = RAND_LL(); wxLongLong c = a*b; wxLongLong a1(a.GetHi(), a.GetLo()); wxLongLong b1(b.GetHi(), b.GetLo()); wxLongLong c1 = a1*b1; CPPUNIT_ASSERT( c1 == c ); #if wxUSE_LONGLONG_WX wxLongLongWx a2(a.GetHi(), a.GetLo()); wxLongLongWx b2(b.GetHi(), b.GetLo()); wxLongLongWx c2 = a2*b2; CPPUNIT_ASSERT( c2 == c ); #endif #if wxUSE_LONGLONG_NATIVE wxLongLongNative a3(a.GetHi(), a.GetLo()); wxLongLongNative b3(b.GetHi(), b.GetLo()); wxLongLongNative c3 = a3*b3; CPPUNIT_ASSERT( c3 == c ); #endif } }
int main() { dump(); for (int i=0;i<500;i++) { { flop = !flop; blockWipedPool().wipe(); if (i%10==0) blockWipedPool().clear(); BP b1(new A1); BP b2(new A2); BP b3(new A3); dump(); { BP bb1(b1->clone()); BP bb2(b2->clone()); BP bb3(b3->clone()); dump(); } dump("after clone destr"); BP b11(new A1); BP b22(new A2); BP b23(new A2); dump(); b1.reset(); b2.reset(); b3.reset(); dump("after first destr"); } dump(); { std::vector<BP> v(233); for_each(v.begin(),v.end(),&gen); dump("after 233 alloc"); v.resize(123); dump("after 110 distr"); } dump(); for (int i=0;i<3;i++){ std::vector<BP> v(2432); for_each(v.begin(),v.end(),&gen); std::vector<BP> v1(3213); for_each(v1.begin(),v1.end(),&gen); { std::vector<BP> d; d.swap(v); } // alloc disalloc std::vector<BP> vs(514); for_each(vs.begin(),vs.end(),&gen); for_each(vs.begin(),vs.end(),&gen); } dump("loop end"); } return 0; }
void convertHFShowerLibrary() { TFile *nF=new TFile("david.root","RECREATE","hiThere",1); TTree *nT=new TTree("HFSimHits","HF simple tree"); std::vector<float> *parts=new std::vector<float>(); std::vector<float> *partsHad=new std::vector<float>(); nT->Branch("emParticles", &parts); nT->GetBranch("emParticles")->SetBasketSize(1); nT->Branch("hadParticles", &partsHad); nT->GetBranch("hadParticles")->SetBasketSize(1); TDirectory *target=gDirectory; TFile *oF=TFile::Open("HFShowerLibrary_npmt_noatt_eta4_16en_v3_orig.root"); TTree *t=(TTree*)oF->Get("HFSimHits"); TTreeReader fReader(t); TTreeReaderArray<Float_t> b1(fReader, "emParticles.position_.fCoordinates.fX"); TTreeReaderArray<Float_t> b2(fReader, "emParticles.position_.fCoordinates.fY"); TTreeReaderArray<Float_t> b3(fReader, "emParticles.position_.fCoordinates.fZ"); TTreeReaderArray<Float_t> b4(fReader, "emParticles.lambda_"); TTreeReaderArray<Float_t> b5(fReader, "emParticles.time_"); TTreeReaderArray<Float_t> h1(fReader, "hadParticles.position_.fCoordinates.fX"); TTreeReaderArray<Float_t> h2(fReader, "hadParticles.position_.fCoordinates.fY"); TTreeReaderArray<Float_t> h3(fReader, "hadParticles.position_.fCoordinates.fZ"); TTreeReaderArray<Float_t> h4(fReader, "hadParticles.lambda_"); TTreeReaderArray<Float_t> h5(fReader, "hadParticles.time_"); target->cd(); while ( fReader.Next() ) { parts->clear(); unsigned int s=b1.GetSize(); parts->resize(5*s); for ( unsigned int i=0; i<b1.GetSize(); i++) { (*parts)[i]=(b1[i]); (*parts)[i+1*s]=(b2[i]); (*parts)[i+2*s]=(b3[i]); (*parts)[i+3*s]=(b4[i]); (*parts)[i+4*s]=(b5[i]); } partsHad->clear(); s=h1.GetSize(); partsHad->resize(5*s); for ( unsigned int i=0; i<h1.GetSize(); i++) { (*partsHad)[i]=(h1[i]); (*partsHad)[i+1*s]=(h2[i]); (*partsHad)[i+2*s]=(h3[i]); (*partsHad)[i+3*s]=(h4[i]); (*partsHad)[i+4*s]=(h5[i]); } nT->Fill(); } nT->Write(); nF->Close(); }
int main(int argc, char **argv) { int i=0; if (Fl::args(argc,argv,i,arg) < argc) Fl::fatal("Options are:\n -2 = 2 windows\n -f = startup fullscreen\n%s",Fl::help); Fl_Single_Window window(300,300+30*NUMB); window.end(); shape_window sw(10,10,window.w()-20,window.h()-30*NUMB-20); #if HAVE_GL sw.mode(FL_RGB); #endif Fl_Window *w; if (twowindow) { // make it's own window sw.resizable(&sw); w = &sw; window.set_modal(); // makes controls stay on top when fullscreen pushed argc--; sw.show(); } else { // otherwise make a subwindow window.add(sw); window.resizable(&sw); w = &window; } window.begin(); int y = window.h()-30*NUMB-5; Fl_Hor_Slider slider(50,y,window.w()-60,30,"Sides:"); slider.clear_flag(FL_ALIGN_MASK); slider.set_flag(FL_ALIGN_LEFT); slider.callback(sides_cb,&sw); slider.value(sw.sides); slider.step(1); slider.range(3,40); y+=30; Fl_Toggle_Light_Button b1(50,y,window.w()-60,30,"Double Buffered"); b1.callback(double_cb,&sw); y+=30; Fl_Toggle_Light_Button b3(50,y,window.w()-60,30,"FullScreen"); b3.callback(fullscreen_cb,w); y+=30; Fl_Button eb(50,y,window.w()-60,30,"Exit"); eb.callback(exit_cb); y+=30; if (initfull) {b3.set(); b3.do_callback();} window.end(); window.show(argc,argv); return Fl::run(); }
/* Public functions */ void VGCRectangleTest::run(){ VGCRectangle r0; VGCAssert(VGCVector(0, 0) == r0.getPosition()); VGCAssert(0 == r0.getWidth()); VGCAssert(0 == r0.getHeight()); r0.setPosition(VGCVector(1, 2)); VGCAssert(VGCVector(1, 2) == r0.getPosition()); r0.setWidth(1); VGCAssert(1 == r0.getWidth()); r0.setHeight(2); VGCAssert(2 == r0.getHeight()); VGCRectangle r1(VGCVector(1, 2), 1, 2); VGCAssert(VGCVector(1, 2) == r1.getPosition()); VGCAssert(1 == r1.getWidth()); VGCAssert(2 == r1.getHeight()); VGCRectangle r2(r1); VGCAssert(VGCVector(1, 2) == r2.getPosition()); VGCAssert(1 == r2.getWidth()); VGCAssert(2 == r2.getHeight()); VGCRectangle r3; r3 = r2; VGCAssert(VGCVector(1, 2) == r3.getPosition()); VGCAssert(1 == r3.getWidth()); VGCAssert(2 == r3.getHeight()); VGCRectangle r4(VGCVector(1, 2), 2, 3); VGCAssert(r4.isInside(VGCVector(1, 2))); VGCAssert(r4.isInside(VGCVector(2, 2))); VGCAssert(r4.isInside(VGCVector(1, 3))); VGCAssert(r4.isInside(VGCVector(2, 3))); VGCAssert(r4.isInside(VGCVector(1, 4))); VGCAssert(r4.isInside(VGCVector(2, 4))); VGCAssert(!r4.isInside(VGCVector(0, 3))); VGCAssert(!r4.isInside(VGCVector(2, 5))); VGCRectangle a0(VGCVector(0, 0), 0, 0); VGCRectangle a1(VGCVector(0, 0), 0, 1); VGCRectangle a2(VGCVector(0, 0), 1, 0); VGCRectangle a3(VGCVector(0, 1), 0, 0); VGCRectangle b0(VGCVector(0, 0), 0, 0); VGCRectangle b1(VGCVector(0, 0), 0, 1); VGCRectangle b2(VGCVector(0, 0), 1, 0); VGCRectangle b3(VGCVector(0, 1), 0, 0); VGCAssert(a0 == b0); VGCAssert(a1 == b1); VGCAssert(a2 == b2); VGCAssert(a3 == b3); VGCAssert(a0 != a1); VGCAssert(a0 != a2); VGCAssert(a0 != a3); }
void foo() { int val; int *p = &val; A a1(p); A a2, a3; a2 = a3 = a1; B b1, b2(2), b3(3); b1 = b2 + b3; }
//----------------------------------------------------------------------- // e x t r a c t T r i a n g l e s //----------------------------------------------------------------------- btTriangleMesh* TMeshShape::extractTriangles(IMesh* mesh, bool removeDupVertices) { vector3df p1, p2, p3; // 32 bit indices, 3 component vertices - allows for use in decomposition. btTriangleMesh* triMesh = new btTriangleMesh(true, false); u32 bufCount = mesh->getMeshBufferCount(); for(u32 i=0;i<bufCount;i++) { IMeshBuffer* mbuf = mesh->getMeshBuffer(i); void* vp = mbuf->getVertices(); E_VERTEX_TYPE vtype = mbuf->getVertexType(); S3DVertex *vstd = (S3DVertex*) vp; S3DVertex2TCoords *v2t = (S3DVertex2TCoords*) vp; S3DVertexTangents *vtan = (S3DVertexTangents*)vp; const u16* ip = mbuf->getIndices(); u32 ic = mbuf->getIndexCount(); u32 fi = 0; while(fi < ic) { S3DVertex *v1,*v2,*v3; switch(vtype) { case EVT_2TCOORDS: v1 = &v2t[ip[fi++]]; v2 = &v2t[ip[fi++]]; v3 = &v2t[ip[fi++]]; break; case EVT_TANGENTS: v1 = &vtan[ip[fi++]]; v2 = &vtan[ip[fi++]]; v3 = &vtan[ip[fi++]]; break; default: v1 = &vstd[ip[fi++]]; v2 = &vstd[ip[fi++]]; v3 = &vstd[ip[fi++]]; break; } p1 = v1->Pos; p2 = v2->Pos; p3 = v3->Pos; btVector3 b1(p1.X, p1.Y, p1.Z); btVector3 b2(p2.X, p2.Y, p2.Z); btVector3 b3(p3.X, p3.Y, p3.Z); triMesh->addTriangle(b1,b2,b3,removeDupVertices); } } return triMesh; }
void test_non_contiguous() { BuffAggr b3(6, false); uint32_t off = 0; for ( uint32_t i=0; i<7; i++) { uint8_t *buf = create_buf(i+4); b3.set_buf(buf, off, i+4); off += i + 4 + 10; } b3.print(); }
void test4() { BigData b1("9999999999999999999999999999999"); BigData b2("9999999999999999999999999999991"); cout<<b1-b2<<endl; BigData b3("33333333333333"); BigData b4("9999999999999999999999999999999"); cout<<b3-b4<<endl; BigData b5("9999999999999999999999999999991"); BigData b6("9999999999999999999999999999999"); cout<<b5-b6<<endl; }
void display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); GLint viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); double aspect = (double)viewport[2] / (double)viewport[3]; gluPerspective(fovy, aspect, clipNear, clipFar); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0, 0, z, x, y, 0, 0, 1, 0); if (success) { drawFaces(); if (drawAABB) { Eigen::Vector3d max = boundingBox.max; Eigen::Vector3d min = boundingBox.min; Eigen::Vector3d extent = boundingBox.extent; Eigen::Vector3d b2(min.x() + extent.x(), min.y(), min.z()); Eigen::Vector3d b3(min.x() + extent.x(), min.y() + extent.y(), min.z()); Eigen::Vector3d b4(min.x(), min.y() + extent.y(), min.z()); Eigen::Vector3d b5(max.x() - extent.x(), max.y() - extent.y(), max.z()); Eigen::Vector3d b6(max.x(), max.y() - extent.y(), max.z()); Eigen::Vector3d b8(max.x() - extent.x(), max.y(), max.z()); drawBox(min, b2, b3, b4, b5, b6, max, b8); } else { std::vector<Eigen::Vector3d> orientedPoints = boundingBox.orientedPoints; Eigen::Vector3d b1 = orientedPoints[0] + orientedPoints[2] + orientedPoints[4]; Eigen::Vector3d b2 = orientedPoints[1] + orientedPoints[2] + orientedPoints[4]; Eigen::Vector3d b3 = orientedPoints[1] + orientedPoints[2] + orientedPoints[5]; Eigen::Vector3d b4 = orientedPoints[0] + orientedPoints[2] + orientedPoints[5]; Eigen::Vector3d b5 = orientedPoints[0] + orientedPoints[3] + orientedPoints[4]; Eigen::Vector3d b6 = orientedPoints[1] + orientedPoints[3] + orientedPoints[4]; Eigen::Vector3d b8 = orientedPoints[0] + orientedPoints[3] + orientedPoints[5]; Eigen::Vector3d b7 = orientedPoints[1] + orientedPoints[3] + orientedPoints[5]; drawBox(b1, b2, b3, b4, b5, b6, b7, b8); } } glutSwapBuffers(); }
bool yarp::os::impl::HttpCarrier::write(Protocol& proto, SizedWriter& writer) { DummyConnector con; con.setTextMode(true); for (size_t i=writer.headerLength(); i<writer.length(); i++) { con.getWriter().appendBlock(writer.data(i),writer.length(i)); } Bottle b; b.read(con.getReader()); ConstString body = b.find("web").toString(); if (body.length()!=0) { ConstString header; header += NetType::toHexString(body.length()).c_str(); header += "\r\n"; Bytes b2((char*)header.c_str(),header.length()); proto.os().write(b2); Bytes b3((char*)body.c_str(),body.length()); proto.os().write(b3); proto.os().write('\r'); proto.os().write('\n'); } else { ConstString txt = b.toString() + "\r\n"; ConstString header; header += NetType::toHexString(txt.length()).c_str(); header += "\r\n"; Bytes b2((char*)header.c_str(),header.length()); proto.os().write(b2); Bytes b3((char*)txt.c_str(),txt.length()); proto.os().write(b3); proto.os().write('\r'); proto.os().write('\n'); } proto.os().flush(); return proto.os().isOk(); }
int main() { std::string s = "bonjour"; Buffer b1(s); Buffer b2(s); Buffer b3(std::string("bonjour")); std::cout << s << std::endl; std::cout << b1.donnees_ << std::endl; std::cout << b2.donnees_ << std::endl; std::cout << b3.donnees_ << std::endl; }
void test_single_dest() { // push only tbb::flow::graph g; tbb::flow::source_node<T> src(g, source_body<T>() ); test_push_receiver<T> dest; tbb::flow::make_edge( src, dest ); g.wait_for_all(); for (int i = 0; i < N; ++i ) { ASSERT( dest.get_count(i) == 1, NULL ); } // push only tbb::atomic<int> counters3[N]; tbb::flow::source_node<T> src3(g, source_body<T>() ); function_body<T> b3( counters3 ); tbb::flow::function_node<T,bool> dest3(g, tbb::flow::unlimited, b3 ); tbb::flow::make_edge( src3, dest3 ); g.wait_for_all(); for (int i = 0; i < N; ++i ) { int v = counters3[i]; ASSERT( v == 1, NULL ); } // push & pull tbb::flow::source_node<T> src2(g, source_body<T>() ); tbb::atomic<int> counters2[N]; function_body<T> b2( counters2 ); tbb::flow::function_node<T,bool> dest2(g, tbb::flow::serial, b2 ); tbb::flow::make_edge( src2, dest2 ); #if TBB_PREVIEW_FLOW_GRAPH_FEATURES ASSERT(src2.successor_count() == 1, NULL); typename tbb::flow::source_node<T>::successor_vector_type my_succs; src2.copy_successors(my_succs); ASSERT(my_succs.size() == 1, NULL); #endif g.wait_for_all(); for (int i = 0; i < N; ++i ) { int v = counters2[i]; ASSERT( v == 1, NULL ); } // test copy constructor tbb::flow::source_node<T> src_copy(src); test_push_receiver<T> dest_c; ASSERT( src_copy.register_successor(dest_c), NULL ); g.wait_for_all(); for (int i = 0; i < N; ++i ) { ASSERT( dest_c.get_count(i) == 1, NULL ); } }
void level_three() { vector<DPipe> DirectPipes(13); vector<DoublePipe> DoublePipes(13); vector<CrossPipe> CrossPipes(2); DPipe a0(50,SCREEN_HEIGHT-50,100,40); DoublePipe b0(150,SCREEN_HEIGHT-50,70,40); DPipe a1(150,SCREEN_HEIGHT-150,100,40); DoublePipe b1(150,SCREEN_HEIGHT-250,70,40); DPipe a2(250,SCREEN_HEIGHT-350,100,40); DoublePipe b2(350,SCREEN_HEIGHT-250,70,40); DPipe a3(350,SCREEN_HEIGHT-350,100,40); DPipe a4(350,SCREEN_HEIGHT-150,100,40); DoublePipe b3(250,SCREEN_HEIGHT-450,70,40); DoublePipe b4(350,SCREEN_HEIGHT-450,70,40); CrossPipe c0(250,SCREEN_HEIGHT-250,100,40); DPipe a5(550,SCREEN_HEIGHT-50,100,40); DoublePipe b5(250,SCREEN_HEIGHT-150,70,40); DoublePipe b6(450,SCREEN_HEIGHT-50,70,40); DoublePipe b7(650,SCREEN_HEIGHT-150,70,40); DPipe a6(550,SCREEN_HEIGHT-50,100,40); DPipe a7(550,SCREEN_HEIGHT-150,100,40); DoublePipe b8(750,SCREEN_HEIGHT-50,70,40); DPipe a8(550,SCREEN_HEIGHT-250,100,40); DoublePipe b9(750,SCREEN_HEIGHT-350,70,40); CrossPipe c1(450,SCREEN_HEIGHT-150,100,40); DoublePipe b10(350,SCREEN_HEIGHT-450,70,40); DPipe a9(750,SCREEN_HEIGHT-150,100,40); DPipe a10(750,SCREEN_HEIGHT-250,100,40); DoublePipe b11(450,SCREEN_HEIGHT-250,70,40); DoublePipe b12(650,SCREEN_HEIGHT-250,70,40); DPipe a11(650,SCREEN_HEIGHT-50,100,40); DPipe a12(850,SCREEN_HEIGHT-350,100,40); DirectPipes[0] = a0; DoublePipes[0] = b0; DirectPipes[1] = a1; DoublePipes[1] = b1; DirectPipes[2] = a2; DoublePipes[2] = b2; DirectPipes[3] = a3; DoublePipes[3] = b3; DirectPipes[4] = a4; DoublePipes[4] = b4; DirectPipes[5] = a5; DoublePipes[5] = b5; DirectPipes[6] = a6; DoublePipes[6] = b6; DirectPipes[7] = a7; DoublePipes[7] = b7; DirectPipes[8] = a8; DoublePipes[8] = b8; DirectPipes[9] = a9; DoublePipes[9] = b9; DirectPipes[10] = a10; DoublePipes[10] = b10; DirectPipes[11] = a11; DoublePipes[11] = b11; DirectPipes[12] = a12; DoublePipes[12] = b12; CrossPipes[0] = c0; CrossPipes[1] = c1; Water a(20,SCREEN_HEIGHT-50,40,40); }
void test_rw_aggr_buf() { BuffAggr b3(6, false); uint32_t off = 0; for ( uint32_t i=1; i<3; i++) { uint8_t *buf = create_buf(i+4); b3.set_buf(buf, off, i+4); off += i+4; } b3.print(); uint8_t *buf = create_buf(2); b3.set_buf(buf, 2, 2); b3.print(); }
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; }
/* the Zero-keyed h function (used by the key setup routine) */ u32 h(u32 X, u32 L[4], int k) { BYTE y0, y1, y2, y3; BYTE z0, z1, z2, z3; y0 = b0(X); y1 = b1(X); y2 = b2(X); y3 = b3(X); switch(k) { case 4: y0 = Q1[y0] ^ b0(L[3]); y1 = Q0[y1] ^ b1(L[3]); y2 = Q0[y2] ^ b2(L[3]); y3 = Q1[y3] ^ b3(L[3]); case 3: y0 = Q1[y0] ^ b0(L[2]); y1 = Q1[y1] ^ b1(L[2]); y2 = Q0[y2] ^ b2(L[2]); y3 = Q0[y3] ^ b3(L[2]); case 2: y0 = Q1[ Q0 [ Q0[y0] ^ b0(L[1]) ] ^ b0(L[0]) ]; y1 = Q0[ Q0 [ Q1[y1] ^ b1(L[1]) ] ^ b1(L[0]) ]; y2 = Q1[ Q1 [ Q0[y2] ^ b2(L[1]) ] ^ b2(L[0]) ]; y3 = Q0[ Q1 [ Q1[y3] ^ b3(L[1]) ] ^ b3(L[0]) ]; } /* inline the MDS matrix multiply */ z0 = multEF[y0] ^ y1 ^ multEF[y2] ^ mult5B[y3]; z1 = multEF[y0] ^ mult5B[y1] ^ y2 ^ multEF[y3]; z2 = mult5B[y0] ^ multEF[y1] ^ multEF[y2] ^ y3; z3 = y0 ^ multEF[y1] ^ mult5B[y2] ^ mult5B[y3]; return BYTES_TO_U32(z0, z1, z2, z3); }
void TestSymDiv_E2(tmv::DivType dt, PosDefCode pdc) { const int N = 10; std::vector<tmv::SymMatrixView<T> > s; std::vector<tmv::SymMatrixView<std::complex<T> > > cs; MakeSymList(s,cs,pdc); tmv::Matrix<T> a1(N,N); for (int i=0; i<N; ++i) for (int j=0; j<N; ++j) a1(i,j) = T(1-3*i+j); a1.diag().addToAll(T(10)*N); a1 /= T(10); tmv::Matrix<std::complex<T> > ca1 = a1 * std::complex<T>(3,-4); tmv::BandMatrix<T> b1(a1,1,3); tmv::BandMatrix<std::complex<T> > cb1(ca1,1,3); tmv::BandMatrix<T> b1v = b1.view(); tmv::BandMatrix<std::complex<T> > cb1v = cb1.view(); #if (XTEST & 2) tmv::BandMatrix<T> b3(a1.colRange(0,N-2),1,3); tmv::BandMatrix<std::complex<T> > cb3(ca1.colRange(0,N-2),1,3); tmv::BandMatrix<T> b4(a1.rowRange(0,N-2),1,3); tmv::BandMatrix<std::complex<T> > cb4(ca1.rowRange(0,N-2),1,3); tmv::BandMatrix<T> b3v = b3.view(); tmv::BandMatrix<std::complex<T> > cb3v = cb3.view(); tmv::BandMatrix<T> b4v = b4.view(); tmv::BandMatrix<std::complex<T> > cb4v = cb4.view(); #endif for(size_t i=START;i<s.size();i++) { if (showstartdone) std::cout<<"Start loop: i = "<<i<<", si = "<<tmv::TMV_Text(s[i])<< " "<<s[i]<<std::endl; tmv::SymMatrixView<T> si = s[i]; tmv::SymMatrixView<std::complex<T> > csi = cs[i]; TestMatrixDivArith1(dt,b1v,si,cb1v,csi,"Sym/SquareBandMatrix"); if (dt == tmv::LU) continue; #if (XTEST & 2) TestMatrixDivArith1(dt,b3v,si,cb3v,csi,"Sym/NonSquareBandMatrix"); TestMatrixDivArith1(dt,b4v,si,cb4v,csi,"Sym/NonSquareBandMatrix"); #endif } }
int main() { Book b1("123", "War and Peace", "Tolstoy"); Book b2("234", "Moby Dick", "Melville"); Book b3("345", "Phantom Tollbooth", "Juster"); Patron p1("abc", "Felicity"); Patron p2("bcd", "Waldo"); Patron p3("123", "Jeremy"); Library lib; lib.addBook(&b1); lib.addBook(&b2); lib.addBook(&b3); lib.addPatron(&p1); lib.addPatron(&p2); lib.addPatron(&p3); std::cout << lib.checkOutBook("bcd", "234") << std::endl; for (int i=0; i<7; i++) lib.incrementCurrentDate(); std::cout << lib.checkOutBook("bcd", "123") << std::endl; std::cout << lib.checkOutBook("abc", "345") << std::endl; for (int i=0; i<24; i++) lib.incrementCurrentDate(); std::cout << lib.payFine("bcd", 0.4) << std::endl; double p1Fine = p1.getFineAmount(); double p2Fine = p2.getFineAmount(); std::cout << "p1 fine: " << p1Fine << std::endl; std::cout << "p2 fine: " << p2Fine << std::endl; std::cout << "request: " << lib.requestBook ("123", "123") << std::endl; std::cout << "request: " << lib.requestBook ("12b", "123") << std::endl; std::cout << "request: " << lib.requestBook ("abc", "123") << std::endl; for (int i=0; i<10; i++) lib.incrementCurrentDate(); std::cout << "return book: " << lib.returnBook ("123") << std::endl; std::cout << lib.payFine("bcd", 1.0) << std::endl; p1Fine = p1.getFineAmount(); p2Fine = p2.getFineAmount(); std::cout << "p1 fine: " << p1Fine << std::endl; std::cout << "p2 fine: " << p2Fine << std::endl; std::cout << "checkout book: " << lib.checkOutBook("123", "345") << std::endl; std::cout << "checkout book: " << lib.checkOutBook("123", "123") << std::endl; return 0; }
void TimeControls::initUI() { auto playback = mEditor->playback(); SignalBlocker b( mLoopStartSpinBox ); mLoopStartSpinBox->setValue( playback->markInFrame() ); SignalBlocker b2( mLoopEndSpinBox ); mLoopEndSpinBox->setValue( playback->markOutFrame() ); mPlaybackRangeCheckBox->setChecked( false ); mLoopStartSpinBox->setEnabled( false ); mLoopEndSpinBox->setEnabled( false ); SignalBlocker b3( mFpsBox ); mFpsBox->setValue( playback->fps() ); }
TEST(Bubbles, PrintStatus) { bbs::Bubble b1(1, 1, bbs::colors_t::NONE); EXPECT_EQ(b1.getPrintableStatus(), "N"); bbs::Bubble b2(1, 1, bbs::colors_t::RED); EXPECT_EQ(b2.getPrintableStatus(), "R"); bbs::Bubble b3(1, 1, bbs::colors_t::GREEN); EXPECT_EQ(b3.getPrintableStatus(), "G"); bbs::Bubble b4(1, 1, bbs::colors_t::YELLOW); EXPECT_EQ(b4.getPrintableStatus(), "Y"); bbs::Bubble b5(1, 1, bbs::colors_t::BLUE); EXPECT_EQ(b5.getPrintableStatus(), "B"); }
TEST(BubbleInitializing, Colors) { bbs::Bubble b1(1, 1, bbs::colors_t::NONE); EXPECT_EQ(b1.getStatus(), bbs::colors_t::NONE); bbs::Bubble b2(1, 1, bbs::colors_t::RED); EXPECT_EQ(b2.getStatus(), bbs::colors_t::RED); bbs::Bubble b3(1, 1, bbs::colors_t::GREEN); EXPECT_EQ(b3.getStatus(), bbs::colors_t::GREEN); bbs::Bubble b4(1, 1, bbs::colors_t::YELLOW); EXPECT_EQ(b4.getStatus(), bbs::colors_t::YELLOW); bbs::Bubble b5(1, 1, bbs::colors_t::BLUE); EXPECT_EQ(b5.getStatus(), bbs::colors_t::BLUE); }
void drawShapes( QPainter *p ) { QBrush b1( Qt::blue ); QBrush b2( Qt::green, Qt::Dense6Pattern ); // green 12% fill QBrush b3( Qt::NoBrush ); // void brush QBrush b4( Qt::CrossPattern ); // black cross pattern p->setPen( Qt::red ); p->setBrush( b1 ); p->drawRect( 10, 10, 200, 100 ); p->setBrush( b2 ); p->drawRoundRect( 10, 150, 200, 100, 20, 20 ); p->setBrush( b3 ); p->drawEllipse( 250, 10, 200, 100 ); p->setBrush( b4 ); p->drawPie( 250, 150, 200, 100, 45*16, 90*16 ); }
int main() { Big b0("b0"); Big b1(b0); b1.setName("b1"); std::cout << std::endl << "现在b1:" << std::endl; print(b1); Big b2(std::move(makeBig(1, 2, "临时b2") + 4)); b2.setName("b2"); std::cout << std::endl << "现在b2:" << std::endl; print(b2); Big b3("b3"); b3 = b0; b3.setName("变量b3=b0"); std::cout << std::endl << "现在b3:" << std::endl; print(b3); Big b4("b4"); b4 = b0 + 8; b4.setName("变量b4=b0+8"); std::cout << std::endl << "现在b4:" << std::endl; print(b4); std::cout << "-----------------------" << std::endl; std::vector<Big> *v = new std::vector<Big>; v->push_back(b0 + 16); std::cout << "1st push_back" << std::endl; v->push_back(makeBig(32, 64, "临时b5")); std::cout << "2nd push_back" << std::endl; v->push_back(makeBig(128, 256, "临时b6") + 512); std::cout << "3rd push_back" << std::endl; std::cout << std::endl << "释放vector<Big>内所有的资源:" << std::endl; delete v; std::cout << "-----------------------" << std::endl; std::cout << "程序到达终点,操作系统释放剩余的资源!" << std::endl; return 0; }//main
int main(int argc, char** argv) { bimap<int, char> bm; bm.insertOrKeep(5, 'c'); bm.insertOrKeep(3, 'b'); bm.insertOrKeep(5, 'd'); bm.insertOrReplace(4, 'b'); std::cout << bm[4] << std::endl; std::cout << bm('b') << std::endl; try { std::cout << bm('f') << std::endl; } catch(...) { } // for(bimap::iterator it = bm.begin(); it != bm.end(); ++it) { for(auto const& p: bm) { std::cout << "<" << p.first << ", " << p.second << ">" << std::endl; } std::unordered_map<int, char> m; m[5] = 'c'; m[4] = 'b'; m[2] = 'c'; bimap<int, char> b2(m.begin(), m.end()); for(auto const& p: b2) { std::cout << "<" << p.first << ", " << p.second << ">" << std::endl; } std::vector<std::pair<int, char>> v; v.push_back(std::pair<int,char>(3, 'a')); v.push_back(std::pair<int,char>(5, 'c')); v.push_back(std::pair<int,char>(9, 'b')); bimap<int, char> b3(v.begin(), v.end()); return 0; }
void drawShapes( QPainter *p ) { QBrush b1( blue ); // solid blue brush QBrush b2( green, Dense6Pattern ); // green 12% fill QBrush b3( NoBrush ); // void brush QBrush b4( CrossPattern ); // black cross pattern p->setPen( red ); p->setBrush( b1 ); p->drawRect( 10, 10, 200, 100 ); // draw some shapes p->setBrush( b2 ); p->drawRoundRect( 10, 150, 200, 100, 20, 20 ); p->setBrush( b3 ); p->drawEllipse( 250, 10, 200, 100 ); p->setBrush( b4 ); p->drawPie( 250, 150, 200, 100, 45*16, 90*16 ); }
void test_single_dest() { // push only tbb::flow::graph g; tbb::flow::source_node<T> src(g, source_body<T>() ); test_push_receiver<T> dest; tbb::flow::make_edge( src, dest ); g.wait_for_all(); for (int i = 0; i < N; ++i ) { ASSERT( dest.get_count(i) == 1, NULL ); } // push only tbb::atomic<int> counters3[N]; tbb::flow::source_node<T> src3(g, source_body<T>() ); function_body<T> b3( counters3 ); tbb::flow::function_node<T,bool> dest3(g, tbb::flow::unlimited, b3 ); tbb::flow::make_edge( src3, dest3 ); g.wait_for_all(); for (int i = 0; i < N; ++i ) { int v = counters3[i]; ASSERT( v == 1, NULL ); } // push & pull tbb::flow::source_node<T> src2(g, source_body<T>() ); tbb::atomic<int> counters2[N]; function_body<T> b2( counters2 ); tbb::flow::function_node<T,bool> dest2(g, tbb::flow::serial, b2 ); tbb::flow::make_edge( src2, dest2 ); g.wait_for_all(); for (int i = 0; i < N; ++i ) { int v = counters2[i]; ASSERT( v == 1, NULL ); } // test copy constructor tbb::flow::source_node<T> src_copy(src); test_push_receiver<T> dest_c; ASSERT( src_copy.register_successor(dest_c), NULL ); g.wait_for_all(); for (int i = 0; i < N; ++i ) { ASSERT( dest_c.get_count(i) == 1, NULL ); } }
TEST(BoxTest, Construction) { Box b1; Box b2(2.10, 0.14, 9.6); Vector3D v3(0.4, 3.21, 1.5); Box b3(v3); EXPECT_DOUBLE_EQ(b1.length.y, 0.0); EXPECT_DOUBLE_EQ(b2.length.x, 2.10); EXPECT_DOUBLE_EQ(b3.length.z, 1.5); EXPECT_DOUBLE_EQ(b1.half_length.x, 0.0); EXPECT_DOUBLE_EQ(b2.half_length.z, 4.8); EXPECT_DOUBLE_EQ(b3.half_length.x, 0.2); EXPECT_DOUBLE_EQ(b1.volume, 0.0); EXPECT_DOUBLE_EQ(b2.volume, 2.8224); EXPECT_DOUBLE_EQ(b3.volume, 1.926); }
void ClientConnection::RestoreArea(RECT &r) { int x = r.left; int y = r.top; int w = r.right - r.left; int h = r.bottom - r.top; HBITMAP m_hTempBitmap=NULL; HDC m_hTempBitmapDC=NULL; boost::recursive_mutex::scoped_lock l(m_bitmapdcMutex); ObjectSelector b1(m_hBitmapDC, m_hBitmap); PaletteSelector ps1(m_hBitmapDC, m_hPalette); m_hTempBitmapDC = CreateCompatibleDC(m_hBitmapDC); m_hTempBitmap = CreateCompatibleBitmap(m_hBitmapDC, w, h); ObjectSelector b3(m_hTempBitmapDC, m_hTempBitmap); PaletteSelector ps3(m_hTempBitmapDC, m_hPalette); ObjectSelector b2(m_hCacheBitmapDC, m_hCacheBitmap); PaletteSelector ps2(m_hCacheBitmapDC, m_hPalette); if (!BitBlt(m_hTempBitmapDC, 0, 0, w, h, m_hBitmapDC, x, y, SRCCOPY)) { //vnclog.Print(0, _T("Error saving temp bitmap\n")); Log.WinError(_ERROR_, "Error saving temp bitmap"); } if (!BitBlt(m_hBitmapDC, x, y, w, h, m_hCacheBitmapDC, x, y, SRCCOPY)) { //vnclog.Print(0, _T("Error restoring screen\n")); Log.WinError(_ERROR_, "Error restoring screen"); } if (!BitBlt(m_hCacheBitmapDC, x, y, w, h, m_hTempBitmapDC, 0, 0, SRCCOPY)) { //vnclog.Print(0, _T("Error restoring screen under cursor\n")); Log.WinError(_ERROR_, "Error restoring screen under cursor"); } DeleteDC(m_hTempBitmapDC); if (m_hTempBitmap != NULL) DeleteObject(m_hTempBitmap); if (m_hCacheBitmapDC != NULL) DeleteObject(m_hTempBitmapDC); }
template <class Type> void bench_pack_im(Type *,INT vmax,bool quick) { for (INT x=10; x< (quick ? 300 : 1200); x+= 220) { cout << x << "\n"; Bench_PackB_IM<Type> b1(Pt2di(x,x),0); Bench_PackB_IM<Type> b0(Pt2di(x,x),FX%vmax); Bench_PackB_IM<Type> b2(Pt2di(x,x),(FX>FY)*vmax); Bench_PackB_IM<Type> b3(Pt2di(x,x),frandr()<0.1); Bench_PackB_IM<Type> b4(Pt2di(x,x),frandr()<(1/128.0)); b0.DoNothing(); b1.DoNothing(); b2.DoNothing(); b3.DoNothing(); b4.DoNothing(); } }