void SolveShort(Geometry *geometry, Stencil *st_uw, Stencil *st_dw, int k, int kend, int l, int m, double I_uw, double *chi, double *S, double *I, double *Psi) { int local; double chi_uw, chi_dw, S_uw, S_dw, dS_dw, dS_uw, dtau_uw, dtau_dw, w[3], c1, c2; local = k*geometry->Nplane + m*geometry->Nx + l; /* --- The upwind quantities -- -------------- */ chi_uw = Interpolate_3D(chi, geometry, st_uw, l, m); dtau_uw = 0.5 * (chi_uw + chi[local]) * st_uw->ds; S_uw = Interpolate_3D(S, geometry, st_uw, l, m); dS_uw = (S_uw - S[local]) / dtau_uw; if (k == kend) { w2(dtau_uw, w); /* --- Piecewise linear integration in last layer -- ------------ */ c1 = (S_uw - S[local]) / dtau_uw; I[local] = I_uw*(1.0 - w[0]) + w[0]*S[local] + w[1]*c1; if (Psi) Psi[local] = w[0] - w[1]/dtau_uw; } else { w3(dtau_uw, w); /* --- The downwind quantities -- -------------- */ chi_dw = Interpolate_3D(chi, geometry, st_dw, l, m); dtau_dw = 0.5 * (chi[local] + chi_dw) * st_dw->ds; S_dw = Interpolate_3D(S, geometry, st_dw, l, m); dS_dw = (S[local] - S_dw) / dtau_dw; /* --- Piecewise quadratic integration -- -------------- */ c1 = (dS_uw*dtau_dw + dS_dw*dtau_uw); c2 = (dS_uw - dS_dw); I[local] = I_uw*(1.0 - w[0]) + w[0]*S[local] + (w[1]*c1 + w[2]*c2) / (dtau_uw + dtau_dw); /* --- Try piecewise linear if quadratic gives negative monochromatic intensity -- -------------- */ if (I[local] < 0.0) { c1 = dS_uw; I[local] = (1.0 - w[0])*I_uw + w[0]*S[local] + w[1]*c1; if (Psi) Psi[local] = w[0] - w[1]/dtau_uw; } else { if (Psi) { c1 = dtau_uw - dtau_dw; Psi[local] = w[0] + (w[1]*c1 - w[2]) / (dtau_uw * dtau_dw); } } } }
static void on26_disconnect ( PIA *pi ) { if (pi->mode >= 2) { w3(4); w3(4); w3(4); w3(4); } else { w0(4); P1; w0(4); P1; } CCP(0x30); w0(pi->saved_r0); w2(pi->saved_r2); }
static int fit2_read_regr( PIA *pi, int cont, int regr ) { int a, b, r; if (cont) { if (regr != 6) return 0xff; r = 7; } else r = regr + 0x10; w2(0xc); w0(r); w2(4); w2(5); w0(0); a = r1(); w0(1); b = r1(); w2(4); return j44(a,b); }
void testVecDot() { glam::vec4 v1(1, 2, 3.5, 100); glam::vec4 w1(0.5, 80, 20, 0.1); float u1 = glam::dot(v1, w1); TS_ASSERT_EQUALS(u1, 240.5f); glam::Vector<double, 7> v2(1, 2, 3, 4, 5, 6, 0); glam::Vector<double, 7> w2(0, 6, 5, 4, 3, 2, 1); TS_ASSERT_EQUALS(glam::dot(v2, w2), 70); }
int main() { sem_init(&f,0,10); sem_init(&s,0,10); w1(); w2(); // pthread_mutex_init(&f,NULL); // pthread_mutex_init(&s,NULL); }
shared_ptr<OsmMap> createTestMap() { shared_ptr<OsmMap> map(new OsmMap()); _map = map; shared_ptr<Node> n1 = createNode(0.0, 0.0); n1->setTag("building", "yes"); n1->setTag("name", "n1"); shared_ptr<Way> w1(new Way(Status::Unknown1, map->createNextWayId(), 13.0)); w1->setTag("area", "yes"); w1->setTag("building", "yes"); w1->setTag("name", "w1"); w1->addNode(createNode(0.1, 0.0)->getId()); w1->addNode(createNode(0.2, 0.0)->getId()); w1->addNode(createNode(0.2, 0.1)->getId()); w1->addNode(w1->getNodeId(0)); map->addWay(w1); shared_ptr<Way> w2(new Way(Status::Unknown1, map->createNextWayId(), 13.0)); w2->setTag("highway", "track"); w2->setTag("name", "w2"); w2->addNode(createNode(0.3, 0.0)->getId()); w2->addNode(createNode(0.3, 0.1)->getId()); map->addWay(w2); shared_ptr<Way> w3(new Way(Status::Unknown1, map->createNextWayId(), 13.0)); w3->setTag("highway", "road"); w3->setTag("name", "w3"); w3->addNode(createNode(0.4, 0.0)->getId()); w3->addNode(createNode(0.4, 0.1)->getId()); map->addWay(w3); shared_ptr<Way> w4(new Way(Status::Unknown1, map->createNextWayId(), 13.0)); w4->addNode(createNode(0.5, 0.0)->getId()); w4->addNode(createNode(0.7, 0.0)->getId()); w4->addNode(createNode(0.6, 0.1)->getId()); w4->addNode(w4->getNodeId(0)); map->addWay(w4); shared_ptr<Way> w5(new Way(Status::Unknown1, map->createNextWayId(), 13.0)); w5->addNode(createNode(0.55, 0.01)->getId()); w5->addNode(createNode(0.65, 0.01)->getId()); w5->addNode(createNode(0.6, 0.05)->getId()); w5->addNode(w5->getNodeId(0)); map->addWay(w5); shared_ptr<Relation> r1(new Relation(Status::Unknown1, 1, 15.0, "multipolygon")); r1->setTag("building", "yes"); r1->setTag("name", "r1"); r1->addElement("outer", w4->getElementId()); r1->addElement("inner", w5->getElementId()); map->addRelation(r1); return map; }
void test1() { worker<int> w1(boost::bind<int>(&calculatefib, 7)); worker<int> w2(boost::bind<int>(&calculatefib, 8)); worker<int> w3(boost::bind<int>(&fib_job::calc, boost::shared_ptr<fib_job>(new fib_job(11)))); int sum = w1.get() + w2.get() + w3.get(); std::cout << "Done, sum=" << sum << std::endl; }
/* reference counting having cyclic dependencies (widget implementation) //*/ void testRCIPtr() { RCWidget w1(10); RCWidget w2(w1); w2.doThis(); std::cout << w1.showThat() << '\n'; // prints 10 std::cout << w2.showThat() << '\n'; // prints -1 }
void test() { Wrapper w1; clang_analyzer_eval(w1.value == 42); // expected-warning{{TRUE}} Wrapper w2(50); clang_analyzer_eval(w2.value == 50); // expected-warning{{TRUE}} Wrapper w3(false); clang_analyzer_eval(w3.value == 42); // expected-warning{{TRUE}} }
static void ktti_write_regr( PIA *pi, int cont, int regr, int val) { int r; r = regr + cont_map[cont]; w0(r); w2(0xb); w2(0xa); w2(3); w2(6); w0(val); w2(3); w0(0); w2(6); w2(0xb); }
static void on20_connect ( PIA *pi) { pi->saved_r0 = r0(); pi->saved_r2 = r2(); w2(4);w0(0);w2(0xc);w2(4);w2(6);w2(4);w2(6);w2(4); if (pi->mode) { op(2); vl(8); op(2); vl(9); } else { op(2); vl(0); op(2); vl(8); } }
static void epat_write_regr( PIA *pi, int cont, int regr, int val) { int r; r = regr + cont_map[cont]; switch (pi->mode) { case 0: case 1: case 2: w0(0x60+r); w2(1); w0(val); w2(4); break; case 3: case 4: case 5: w3(0x40+r); w4(val); break; } }
static void epia_write_regr( PIA *pi, int cont, int regr, int val) { int r; regr += cont_map[cont]; switch (pi->mode) { case 0: case 1: case 2: r = regr^0x19; w0(r); w2(1); w0(val); w2(3); w2(4); break; case 3: case 4: case 5: r = regr^0x40; w3(r); w4(val); w2(4); break; } }
void test_fraction() { Fraction w1(1, 2); assert(w1.Numerator() == 1); assert(w1.Denominator() == 2); Fraction w2(12, -16); assert(w2.Numerator() == -3); assert(w2.Denominator() == 4); std::cerr << "test_fraction ok." << std::endl; }
bool matrix_eq(const M& w, const N& w2, float prec) { boost::test_tools::percent_tolerance_t <float> pt(prec); boost::test_tools::close_at_tolerance<typename M::value_type> cmp(pt); for(int i=0;i<w.shape()[0];i++){ for(int j=0;j<w.shape()[1];j++){ if( !cmp(w(i,j), w2(i,j))) return false; } } return true; }
static void fit2_read_block( PIA *pi, char * buf, int count ) { int k, a, b, c, d; w2(0xc); w0(0x10); for (k=0;k<count/4;k++) { w2(4); w2(5); w0(0); a = r1(); w0(1); b = r1(); w0(3); c = r1(); w0(2); d = r1(); buf[4*k+0] = j44(a,b); buf[4*k+1] = j44(d,c); w2(4); w2(5); a = r1(); w0(3); b = r1(); w0(1); c = r1(); w0(0); d = r1(); buf[4*k+2] = j44(d,c); buf[4*k+3] = j44(a,b); } w2(4); }
static int comm_read_regr( PIA *pi, int cont, int regr ) { int l, h, r; r = regr + cont_map[cont]; switch (pi->mode) { case 0: w0(r); P1; w0(0); w2(6); l = r1(); w0(0x80); h = r1(); w2(4); return j44(l,h); case 1: w0(r+0x20); P1; w0(0); w2(0x26); h = r0(); w2(4); return h; case 2: case 3: case 4: w3(r+0x20); (void)r1(); w2(0x24); h = r4(); w2(4); return h; } return -1; }
void Grid::setSize(unsigned int width, unsigned int height, unsigned int rows, unsigned int columns, unsigned int xSep, unsigned int ySep) { // Delete previous grid mcs.clear(); // Int/Int always returns int int w = (int)width / columns; int h = (int)height / rows; for(size_t i = 0; i < rows; i++) { for(size_t j = 0; j < columns; j++) { // Added counter clockwise Coordinate w2(w * j + xSep, h * i + ySep); Coordinate x(w * j + xSep, h * (i + 1) - ySep); Coordinate y(w * (j + 1) - xSep, h * (i + 1) - ySep); Coordinate z(w * (j + 1) - xSep, h * i + ySep); mcs.push_back(w2); mcs.push_back(x); mcs.push_back(x); mcs.push_back(y); if (xSep > 0) { mcs.push_back(y); mcs.push_back(z); } if (ySep > 0) { mcs.push_back(z); mcs.push_back(w2); } } } if (xSep == 0) { mcs.push_back(Coordinate(0,0)); mcs.push_back(Coordinate(width,0)); } if (ySep == 0) { mcs.push_back(Coordinate(width,0)); mcs.push_back(Coordinate(width,height)); } }
static void dstr_write_regr( PIA *pi, int cont, int regr, int val ) { int r; r = regr + cont_map[cont]; w0(0x81); P1; if (pi->mode >= 2) { w0(0x11); } else { w0(1); } P2; w0(r); P1; switch (pi->mode) { case 0: case 1: w0(val); w2(5); w2(7); w2(5); w2(4); break; case 2: case 3: case 4: w4(val); break; } }
static void ktti_write_block( PIA *pi, char * buf, int count ) { int k; for (k=0;k<count/2;k++) { w0(0x10); w2(0xb); w2(0xa); w2(3); w2(6); w0(buf[2*k]); w2(3); w0(buf[2*k+1]); w2(6); w2(0xb); } }
static void aten_write_block( PIA *pi, char * buf, int count ) { int k; w0(0x88); w2(0xe); w2(6); for (k=0;k<count/2;k++) { w0(buf[2*k+1]); w2(0xe); w2(6); w0(buf[2*k]); w2(7); w2(6); } w2(0xc); }
static void fit3_write_regr( PIA *pi, int cont, int regr, int val) { if (cont == 1) return; switch (pi->mode) { case 0: case 1: w2(0xc); w0(regr); w2(0x8); w2(0xc); w0(val); w2(0xd); w0(0); w2(0xc); break; case 2: w2(0xc); w0(regr); w2(0x8); w2(0xc); w4(val); w4(0); w2(0xc); break; } }
int _tmain(int argc, _TCHAR* argv[]) { Widget w1; // 기본 생성자 호출 Widget w2(w1); // 복사 생성자 호출 w1 = w2; // 복사 대입연산자 호출 Widget w3 = w2; // 복사 생성자 호출 Widget aWidget; if (hasAcceptableQuality(aWidget)) //복사 생성자 호출(pass - by - value) return 0; }
TEST(RocksRecordStoreTest, Isolation1 ) { scoped_ptr<HarnessHelper> harnessHelper( newHarnessHelper() ); scoped_ptr<RecordStore> rs( harnessHelper->newNonCappedRecordStore() ); RecordId loc1; RecordId loc2; { scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); { WriteUnitOfWork uow( opCtx.get() ); StatusWith<RecordId> res = rs->insertRecord( opCtx.get(), "a", 2, false ); ASSERT_OK( res.getStatus() ); loc1 = res.getValue(); res = rs->insertRecord( opCtx.get(), "a", 2, false ); ASSERT_OK( res.getStatus() ); loc2 = res.getValue(); uow.commit(); } } { scoped_ptr<OperationContext> t1( harnessHelper->newOperationContext() ); scoped_ptr<OperationContext> t2( harnessHelper->newOperationContext() ); scoped_ptr<WriteUnitOfWork> w1( new WriteUnitOfWork( t1.get() ) ); scoped_ptr<WriteUnitOfWork> w2( new WriteUnitOfWork( t2.get() ) ); rs->dataFor( t1.get(), loc1 ); rs->dataFor( t2.get(), loc1 ); ASSERT_OK( rs->updateRecord( t1.get(), loc1, "b", 2, false, NULL ).getStatus() ); ASSERT_OK( rs->updateRecord( t1.get(), loc2, "B", 2, false, NULL ).getStatus() ); try { // this should fail rs->updateRecord( t2.get(), loc1, "c", 2, false, NULL ); ASSERT( 0 ); } catch ( WriteConflictException& dle ) { w2.reset( NULL ); t2.reset( NULL ); } w1->commit(); // this should succeed } }
int main(void) { Word w1("beast"); Word w2("dough"); Word w3("happy"); Word w4("question"); std::cout << "Let's go" << std::endl; std::cout << w1.pigLatinify() << std::endl; std::cout << w2.pigLatinify() << std::endl; std::cout << w3.pigLatinify() << std::endl; std::cout << w4.pigLatinify() << std::endl; return 0; }
// A triangle void SubdivScene::scenario1() { VertexData w1(1,0,0); w1.colour(1,0,0); VertexData w2(0,1,0); w2.colour(1,1,0); VertexData w3(0,0,0); w3.colour(0,0,1); VertexData w4(0,1,1); HDS.beginPolygon(w1); HDS.nextVertex(w2); Edge& e = HDS.nextVertex(w3); Face& f = HDS.endPolygon(); }
void MLQueryUPS::inflateScheduledActionItem(DCM_OBJECT* obj) { LST_HEAD* l1 = 0; CONDITION cond = ::DCM_GetSequenceList(&obj, DCM_PRCSCHEDULEDPROCSTEPSEQ, &l1); if (cond != DCM_NORMAL) { ::COND_PopCondition(TRUE); return; } DCM_SEQUENCE_ITEM* item1 = (DCM_SEQUENCE_ITEM*)::LST_Head(&l1); if (item1 == NULL) return; LST_HEAD* l2 = 0; cond = ::DCM_GetSequenceList(&item1->object, DCM_PRCSCHEDULEDACTIONITEMCODESEQ, &l2); if (cond != DCM_NORMAL) { ::COND_PopCondition(TRUE); return; } DCM_SEQUENCE_ITEM* item2 = (DCM_SEQUENCE_ITEM*) ::LST_Head(&l2); if (item2 == NULL) { // Then, we have an empty sequence item2 = (DCM_SEQUENCE_ITEM*) ::malloc(sizeof(*item2)); ::DCM_CreateObject(&item2->object, 0); MDICOMWrapper w2(item2->object); w2.setString(DCM_IDCODEVALUE, ""); w2.setString(DCM_IDCODINGSCHEMEDESIGNATOR, ""); w2.setString(DCM_IDCODEMEANING, ""); ::LST_Enqueue(&l2, item2); } else { // See if they sent a zero-length item MDICOMWrapper w3(item2->object); bool emptyFlag = true; if (w3.attributePresent(DCM_IDCODEVALUE)) emptyFlag = false; if (w3.attributePresent(DCM_IDCODINGSCHEMEDESIGNATOR)) emptyFlag = false; if (w3.attributePresent(DCM_IDCODEMEANING)) emptyFlag = false; if (emptyFlag) { // Then none of these are included w3.setString(DCM_IDCODEVALUE, ""); w3.setString(DCM_IDCODINGSCHEMEDESIGNATOR, ""); w3.setString(DCM_IDCODEMEANING, ""); } } }
void SKINNEDMESH::RenderSkeleton(BONE* bone, BONE *parent, D3DXMATRIX world) { //Temporary function to render the bony hierarchy if(world == NULL)return; if(bone == NULL)bone = (BONE*)m_pRootBone; D3DXMATRIX r, s; D3DXMatrixRotationYawPitchRoll(&r, -D3DX_PI * 0.5f, 0.0f, 0.0f); //Draw Sphere m_pDevice->SetRenderState(D3DRS_LIGHTING, true); m_pDevice->SetTransform(D3DTS_WORLD, &(r * bone->CombinedTransformationMatrix * world)); if(bone->Name != NULL)m_pSphereMesh->DrawSubset(0); //Draw line between bones if(parent != NULL && bone->Name != NULL && parent->Name != NULL) { D3DXMATRIX w1 = bone->CombinedTransformationMatrix; D3DXMATRIX w2 = parent->CombinedTransformationMatrix; //Extract translation D3DXVECTOR3 thisBone = D3DXVECTOR3(w1(3, 0), w1(3, 1), w1(3, 2)); D3DXVECTOR3 ParentBone = D3DXVECTOR3(w2(3, 0), w2(3, 1), w2(3, 2)); if(D3DXVec3Length(&(thisBone - ParentBone)) < 2.0f) { m_pDevice->SetTransform(D3DTS_WORLD, &world); VERTEX vert[] = {VERTEX(ParentBone, 0xffff0000), VERTEX(thisBone, 0xff00ff00)}; m_pDevice->SetRenderState(D3DRS_LIGHTING, false); m_pDevice->SetFVF(VERTEX::FVF); m_pDevice->DrawPrimitiveUP(D3DPT_LINESTRIP, 1, &vert[0], sizeof(VERTEX)); } } if(bone->pFrameSibling)RenderSkeleton((BONE*)bone->pFrameSibling, parent, world); if(bone->pFrameFirstChild)RenderSkeleton((BONE*)bone->pFrameFirstChild, bone, world); }
static void fit3_write_block( PIA *pi, char * buf, int count ) { int k; switch (pi->mode) { case 0: case 1: w2(0xc); w0(0); w2(0x8); w2(0xc); for (k=0;k<count/2;k++) { w0(buf[2*k ]); w2(0xd); w0(buf[2*k+1]); w2(0xc); } break; case 2: w2(0xc); w0(0); w2(0x8); w2(0xc); for (k=0;k<count;k++) w4(buf[k]); w2(0xc); break; } }
int main() { Widget w1(std::string("Widget 1")); Widget w2(std::string("Widget 2")); std::cout << w1.m_name << std::endl; std::cout << w2.m_name << std::endl; swap(w1, w2); std::cout << w1.m_name << std::endl; std::cout << w2.m_name << std::endl; return 0; }