TEST(SaturationEffectTest, SaturationZeroRemovesColorButPreservesAlpha) { float data[] = { 0.0f, 0.0f, 0.0f, 1.0f, 0.5f, 0.5f, 0.5f, 0.3f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.7f, 0.0f, 0.0f, 1.0f, 1.0f, }; float expected_data[] = { 0.0f, 0.0f, 0.0f, 1.0f, 0.5f, 0.5f, 0.5f, 0.3f, 0.2126f, 0.2126f, 0.2126f, 1.0f, 0.7152f, 0.7152f, 0.7152f, 0.7f, 0.0722f, 0.0722f, 0.0722f, 1.0f, }; float out_data[5 * 4]; EffectChainTester tester(data, 5, 1, FORMAT_RGBA_POSTMULTIPLIED_ALPHA, COLORSPACE_sRGB, GAMMA_LINEAR); Effect *saturation_effect = tester.get_chain()->add_effect(new SaturationEffect()); ASSERT_TRUE(saturation_effect->set_float("saturation", 0.0f)); tester.run(out_data, GL_RGBA, COLORSPACE_sRGB, GAMMA_LINEAR); expect_equal(expected_data, out_data, 4, 5); }
TEST(Ref_count_tests, default_return_0) { reference_counted<int> tester(42); ASSERT_EQ(0, tester.get_number_of_references()); }
int main() { return tester(); }
int main(int argc, char* argv[]) { Pooma::initialize(argc,argv); Pooma::Tester tester(argc,argv); int test_number = 0; #if POOMA_EXCEPTIONS try { #endif tester.out() << "\nTesting resizable DataBlockPtr." << std::endl; RCBlock_t p; p.reserve(100); PAssert(p.size() == 0); PAssert(p.capacity() == 100); PAssert(p.empty()); p.resize(10,RCBlock_t::NoInitTag()); p.resize(20); p.resize(30,100); p.resize(10); PAssert(p.size() == 10); PAssert(!p.empty()); RCBlock_t q(100,RCBlock_t::NoInitTag()); PAssert(q.size() == 0); PAssert(q.capacity() == 100); PAssert(q.empty()); q.resize(10,RCBlock_t::NoInitTag()); q.resize(20); q.resize(30,100); q.resize(10); PAssert(q.size() == 10); PAssert(!q.empty()); RCBlock_t bb(100); PAssert(bb.size() == 100); PAssert(bb.capacity() == 100); PAssert(!bb.empty()); bb.resize(10,10); bb.resize(5,5); bb.resize(0); PAssert(bb.empty()); bb.resize(10); test_number++; PAssert(!p.isShared()); PAssert(!q.isShared()); PAssert(!bb.isShared()); test_number++; for (int i = 0; i < 10; i++) p[i] = (i-5)*(i-5); test_number++; print(p,tester); print(q,tester); print(bb,tester); #if POOMA_EXCEPTIONS test_number++; try { for (int i = 0; i < 11; i++) p[i] = -p[i]; throw "Bounds checking failed!"; } catch(const Pooma::Assertion &) { tester.out() << "Bounds check worked." << std::endl; } #endif test_number++; for (int i = 0; i < 10; i++) PInsist( p[i] == *(p+i), "p[i] != *(p+i)" ); for (int i = 0; i < 10; i++) PInsist( p[i] == *(p+i), "p[i] != *(p+i)" ); test_number++; PAssert(!p.isShared()); test_number++; foo(p,tester); test_number++; PAssert(!p.isShared()); test_number++; bar(p,tester); PAssert(!p.isShared()); test_number++; print(p,tester); test_number++; RCBlock_t a(1000,RCBlock_t::NoInitTag()); a++; #if POOMA_EXCEPTIONS try { tester.out() << a[4]; throw "Bounds checking failed!"; } catch(const Pooma::Assertion &) { tester.out() << "Bounds check worked." << std::endl; tester.check(1); } #endif // Reset start pointer... a--; a.resize(10,RCBlock_t::NoInitTag()); for (int i = 0; i < 10; i++) a[i] = (i-5)*(i-5); bar(a,tester); print(a,tester); test_number++; RCBlock_t q1 = p; #if POOMA_EXCEPTIONS try { RCBlock_t q2; q2 = p; PAssert(q1 == p); PAssert(q2 == p); PAssert(q1 == q2); PAssert(p.isShared()); PAssert(q1.isShared()); PAssert(q2.isShared()); for (int i = 0; i < 10; i++) PAssert(q1[i] == q2[i]); PAssert(p.capacity() == q1.capacity()); PAssert(p.capacity() == q2.capacity()); PAssert(p.size() == q1.size()); PAssert(p.size() == q2.size()); } catch (...) { tester.out() << "Something is very wrong!" << std::endl; tester.check(0); } #endif PAssert(p.isShared()); PAssert(q1.isShared()); p[1] = -999; PAssert(q1[1] == -999); test_number++; p.invalidate(); PAssert(!p.isValid()); #if POOMA_EXCEPTIONS try { tester.out() << p[3]; throw "Bounds checking failed!"; } catch(const Pooma::Assertion &) { tester.out() << "Bounds check worked." << std::endl; } #endif PAssert(!q1.isShared()); test_number++; recurse(q1,tester); PAssert(!q1.isShared()); tester.out() << "q1.isShared = " << q1.isShared() << std::endl; print(q1,tester); test_number++; { const RCBlock_t r = q1; PAssert(r.isShared()); print(r,tester); for (int i = 0; i < 10; i++) tester.out() << *(r+i) << " "; tester.out() << std::endl; p = r; PAssert(p.isShared()); } PAssert(p.isShared()); test_number++; q1.invalidate(); PAssert(!p.isShared()); test_number++; tester.out() << "\nTesting conversions to non-boundschecked" << std::endl; RCFBlock_t s = p; PAssert(s.isShared()); PAssert(p.isShared()); PAssert(s == p); print(s,tester); recurse(s,tester); PAssert(s.isShared()); test_number++; s.makeOwnCopy(); PAssert(!s.isShared()); PAssert(!p.isShared()); PAssert(s != p); for (int i = 0; i < 10; i++) s[i] = i*i; tester.out() << "These should not be the same." << std::endl; for (int i = 0; i < 10; i++) tester.out() << p[i] << " "; tester.out() << std::endl; for (int i = 0; i < 10; i++) tester.out() << s[i] << " "; tester.out() << std::endl; tester.out() << "printed ok that time." << std::endl; print(s,tester); print(p,tester); s.invalidate(); PAssert(!p.isShared()); p.invalidate(); #if POOMA_EXCEPTIONS } catch(const char *err) { tester.exceptionHandler( err ); tester.set( false ); } catch(const Pooma::Assertion &err) { tester.exceptionHandler( err ); tester.set( false ); } #endif tester.out() << "All Done!" << std::endl; int res = tester.results("dbptr_test5 "); Pooma::finalize(); return res; }
int main(void) { unsigned i, j, esize, cycle, x = 0; _SPM unsigned * elem; SPM_BTE_Buffer bte; const unsigned check = 0xbeef0000; unsigned run_limit = 1000; #ifdef PATMOS data_spm = SPM_BASE; #endif /* Always call spm_init as a first step */ spm_init(); printf("SPM location 0x%x\n", (unsigned) DATA_SPM_BASE); printf("off_chip location 0x%x size %u words\n", (unsigned) off_chip, MAX_TEST_SIZE); printf("Expected SPM size: %u words, %u bytes\n", DATA_SPM_WORDS, DATA_SPM_SIZE); spm_size_test(); printf("basic tests\n"); tester(0, 1024, 4, 1024); tester(0, 1, 4, 1024); tester(1, 1024, 4, 1024); tester(0, 1, 8, 512); mysrand(1000); for (cycle = 0; cycle < 100; cycle++) { do { esize = 1 << (myrand() % 8); } while (((DATA_SPM_SIZE / 2) % (esize * 4)) != 0); printf("%u writing test pattern, element size %u\n", cycle, esize); for (i = MAX_ITEMS; i < (MAX_ITEMS + (DATA_SPM_WORDS * 2)); i++) { off_chip[i] = check | i; } elem = spm_bte_init(&bte, off_chip, data_spm, DATA_SPM_SIZE, esize * 4); mysrand(cycle + 1); for (i = 0; i < MAX_ITEMS; ) { for (j = 0; j < esize; i++, j++) { elem[j] = (cycle == 0) ? i : (myrand() + 1); } elem = spm_bte_produce(&bte); } spm_bte_finish(&bte); invalidate_data_cache(); printf("%u checking test pattern, element size %u\n", cycle, esize); mysrand(cycle + 1); x = 0; for (i = 0; i < MAX_ITEMS; i++) { j = (cycle == 0) ? i : (myrand() + 1); if (off_chip[i] != j) { printf("off_chip[%08x] = %08x should be %08x\n", i, off_chip[i], j); x++; assert(x < 10); } } assert(!x); x = 0; for (i = 0; i < (DATA_SPM_WORDS * 2); i++) { if (off_chip[i + MAX_ITEMS] != (check | i)) { x = i; } } printf("producer overshot by %u (%u)\n", x, DATA_SPM_WORDS * 2); printf("%u single buffer tests\n", cycle); mysrand(cycle + 0x2000); for (i = 0; (i < (3 + cycle)) && (i < 25); i++) { unsigned elem_size = 4 << (myrand() % 4); unsigned spm_elems = DATA_SPM_SIZE / elem_size; unsigned total_elems; spm_elems /= 1 << (myrand() % 4); if (spm_elems < 2) { spm_elems = 2; } total_elems = (myrand() % MAX_ITEMS) + 1; tester((myrand() % total_elems) % 256, total_elems, elem_size, spm_elems * elem_size); } mysrand(cycle + 0x1000); printf("%u multi-buffer tests, myrand %04x\n", cycle, myrand() & 0xffff); multibuf(myrand(), 2 + (myrand() % 15), run_limit); for (i = 2; i <= 16; i++) { multibuf(1024, i, run_limit); } multibuf(myrand(), 2 + (myrand() % 15), run_limit); for (i = 2; i <= 8; i++) { multibuf(2048, i, run_limit); } run_limit *= 10; if (run_limit > MAX_TEST_SIZE) { run_limit = MAX_TEST_SIZE; } } return 0; }
void gkBlenderMeshConverter::convert_legacy(void) { Blender::MFace* mface = m_bmesh->mface; Blender::MVert* mvert = m_bmesh->mvert; Blender::MCol* mcol = 0; Blender::MTFace* mtface[8] = {0, 0, 0, 0, 0, 0, 0, 0}; Blender::MVert vpak[4]; unsigned int cpak[4]; unsigned int ipak[4]; int totlayer; gkSubMesh* curSubMesh = 0; m_meshtable.clear(); gkLoaderUtils_getLayers_legacy(m_bmesh, mtface, &mcol, totlayer); bool sortByMat = gkEngine::getSingleton().getUserDefs().blendermat; bool openglVertexColor = gkEngine::getSingleton().getUserDefs().rendersystem == OGRE_RS_GL; for (int fi = 0; fi < m_bmesh->totface; fi++) { const Blender::MFace& curface = mface[fi]; // skip if face is not a triangle || quad if (!curface.v3) continue; const bool isQuad = curface.v4 != 0; TempFace t[2]; PackedFace f; f.totlay = totlayer; if (isQuad) { vpak[0] = mvert[curface.v1]; vpak[1] = mvert[curface.v2]; vpak[2] = mvert[curface.v3]; vpak[3] = mvert[curface.v4]; ipak[0] = curface.v1; ipak[1] = curface.v2; ipak[2] = curface.v3; ipak[3] = curface.v4; if (mcol != 0) { cpak[0] = packColourABGR(mcol[0]); cpak[1] = packColourABGR(mcol[1]); cpak[2] = packColourABGR(mcol[2]); cpak[3] = packColourABGR(mcol[3]); } else cpak[0] = cpak[1] = cpak[2] = cpak[3] = 0xFFFFFFFF; for (int i = 0; i < totlayer; i++) { if (mtface[i] != 0) { f.uvLayers[i][0] = gkVector2((float*)mtface[i][fi].uv[0]); f.uvLayers[i][1] = gkVector2((float*)mtface[i][fi].uv[1]); f.uvLayers[i][2] = gkVector2((float*)mtface[i][fi].uv[2]); f.uvLayers[i][3] = gkVector2((float*)mtface[i][fi].uv[3]); } } f.verts = vpak; f.index = ipak; f.colors = cpak; gkVector3 e0, e1; e0 = (gkVector3(mvert[curface.v1].co) - gkVector3(mvert[curface.v2].co)); e1 = (gkVector3(mvert[curface.v3].co) - gkVector3(mvert[curface.v4].co)); if (e0.squaredLength() < e1.squaredLength()) { convertIndexedTriangle(&t[0], 0, 1, 2, f); convertIndexedTriangle(&t[1], 2, 3, 0, f); } else { convertIndexedTriangle(&t[0], 0, 1, 3, f); convertIndexedTriangle(&t[1], 3, 1, 2, f); } } else { for (int i = 0; i < totlayer; i++) { if (mtface[i] != 0) { f.uvLayers[i][0] = gkVector2((float*)mtface[i][fi].uv[0]); f.uvLayers[i][1] = gkVector2((float*)mtface[i][fi].uv[1]); f.uvLayers[i][2] = gkVector2((float*)mtface[i][fi].uv[2]); } } vpak[0] = mvert[curface.v1]; vpak[1] = mvert[curface.v2]; vpak[2] = mvert[curface.v3]; ipak[0] = curface.v1; ipak[1] = curface.v2; ipak[2] = curface.v3; if (mcol != 0) { cpak[0] = packColourABGR(mcol[0]); cpak[1] = packColourABGR(mcol[1]); cpak[2] = packColourABGR(mcol[2]); } else cpak[0] = cpak[1] = cpak[2] = cpak[3] = 0xFFFFFFFF; f.verts = vpak; f.index = ipak; f.colors = cpak; convertIndexedTriangle(&t[0], 0, 1, 2, f); } gkMeshPair tester(curSubMesh); if (sortByMat) { int mode = 0; if (mtface[0]) mode = mtface[0][fi].mode; tester.test = gkMeshHashKey(curface.mat_nr, mode); } else { Blender::Image* ima[8] = {0, 0, 0, 0, 0, 0, 0, 0}; for (int i = 0; i < totlayer; i++) { if (mtface[i] != 0) ima[i] = mtface[i][fi].tpage; } int mode = 0, alpha = 0; if (mtface[0]) { mode = mtface[0][fi].mode; alpha = mtface[0][fi].transp; } tester.test = gkMeshHashKey(mode, alpha, ima); } // find submesh UTsize arpos = 0; if ((arpos = m_meshtable.find(tester)) == UT_NPOS) { curSubMesh = new gkSubMesh(); curSubMesh->setTotalLayers(totlayer); curSubMesh->setVertexColors(mcol != 0); m_gmesh->addSubMesh(curSubMesh); tester.item = curSubMesh; m_meshtable.push_back(tester); } else curSubMesh = m_meshtable.at(arpos).item; if (curSubMesh == 0) continue; if (!(curface.flag & ME_SMOOTH)) { // face normal calcNormal(&t[0]); if (isQuad) t[1].v0.no = t[1].v1.no = t[1].v2.no = t[0].v0.no; } int triflag = 0; if (mtface[0]) { if (mtface[0][fi].mode & TF_DYNAMIC) triflag |= gkTriangle::TRI_COLLIDER; if (mtface[0][fi].mode & TF_INVISIBLE) triflag |= gkTriangle::TRI_INVISIBLE; } else triflag = gkTriangle::TRI_COLLIDER; curSubMesh->addTriangle(t[0].v0, t[0].i0, t[0].v1, t[0].i1, t[0].v2, t[0].i2, triflag); if (isQuad) { curSubMesh->addTriangle(t[1].v0, t[1].i0, t[1].v1, t[1].i1, t[1].v2, t[1].i2, triflag); } if (mcol) mcol += 4; } }
int mp4_createSeeked(const char *path, float fStart) { int rc = 0; MP4_CONTAINER_T *pMp4; BOX_T *pBoxTrak; BOX_T *pBox; BOX_HDLR_T *pBoxHdlr; MP4_TRAK_T mp4TrakTmp; MP4_TRAK_T mp4TrakAud; MP4_TRAK_T mp4TrakVid; MP4_TRAK_T *pMp4TrakVid = NULL; MP4_TRAK_T *pMp4TrakAud = NULL; MP4_STBL_CLONE_T cloneVid; MP4_STBL_CLONE_T cloneAud; uint64_t startHz = 0; if(!(pMp4 = mp4_open(path, 1))) { return -1; } memset(&cloneVid, 0, sizeof(cloneVid)); memset(&cloneAud, 0, sizeof(cloneAud)); if(!(pBoxTrak = mp4_findBoxInTree(pMp4->proot, *((uint32_t *) "moov"))) || !(pBoxTrak = pBoxTrak->child)) { LOG(X_ERROR("No tracks found in mp4")); mp4_close(pMp4); return -1; } while(pBoxTrak && (!pMp4TrakAud || !pMp4TrakVid)) { if(pBoxTrak->type != *((uint32_t *) "trak") || !(pBoxHdlr = (BOX_HDLR_T *) mp4_findBoxInTree(pBoxTrak, *((uint32_t *) "hdlr")))) { pBoxTrak = pBoxTrak->pnext; continue; } memset(&mp4TrakTmp, 0, sizeof(MP4_TRAK_T)); mp4TrakTmp.pTrak = pBoxTrak; pBox = fillTrack(&mp4TrakTmp, 0); if(!pBox) { pBoxTrak = pBoxTrak->pnext; continue; } if(!pMp4TrakAud && (pBoxHdlr->handlertype == *((uint32_t *) "soun") || pBoxHdlr->handlertype == *((uint32_t *) "sdsm"))) { memcpy(&mp4TrakAud, &mp4TrakTmp, sizeof(mp4TrakAud)); pMp4TrakAud = &mp4TrakAud; } else if(!pMp4TrakVid && pBoxHdlr->handlertype == *((uint32_t *) "vide")) { memcpy(&mp4TrakVid, &mp4TrakTmp, sizeof(mp4TrakVid)); pMp4TrakVid = &mp4TrakVid; } pBoxTrak = pBoxTrak->pnext; } fStart=15; if(pMp4TrakVid) { startHz = (uint64_t) (fStart * pMp4TrakVid->pMdhd->timescale); fprintf(stdout, "vid seek %lldHz\n", startHz); cloneVid.useSyncSample = 1; tester(pMp4TrakVid, pMp4->pStream, startHz, &cloneVid); } /* if(pMp4TrakAud) { startHz = (uint64_t) (fStart * pMp4TrakAud->pMdhd->timescale); fprintf(stdout, "aud seek %lldHz\n", startHz); tester(pMp4TrakAud, pMp4->pStream, startHz, &cloneAud); } */ mp4_close(pMp4); return rc; }
int main(void) { tester(7); getchar(); }
bool test_fp_manipulation(std::ostream& out, const std::string& name) { simd_fpmanip_tester<T, N, A> tester(name); return test_simd_fp_manipulation(out, tester); }
void testConstantScoreRangeQuery( CuTest * pTc ) { /// Run Java Lucene tests TestConstantScoreRangeQuery tester( pTc ); tester.runTests(); }
void Cqtpainter::Test() { CQtTester tester(m_painter, g_nNumbers, g_bRandom); tester.Test(); }
FUNCTION objend () { register Ocb * o; extern int aggressive; Debug o = xqting_ocb; destroy_message_vector (o); if ( o->centry == DCRT || o->centry == DDES ) { unmark_macro ( o->ci ); } else { register Msgh * n; for ( n = fstigb ( o->ci ); n; n = nxtigb ( n ) ) { if ( n->mtype != DYNDSMSG ) unmark_macro ( n ); } } if ( o->centry == INIT || o->centry == DCRT || o->centry == DDES ) { #ifdef SOM /* Update the phase's highest-seen ept field to the Ept of the event just completed. Also update the amount of total unrolled back work done by the phase. */ o->Ept = o->sb->Ept; #endif SOM save_state (o); } if ( o->centry == EVENT ) { o->stats.numecomp++; o->eventTimePermitted -= o->sb->effectWork; #ifdef SOM /* Update the phase's highest-seen ept field to the Ept of the event just completed. Also update the amount of total unrolled back work done by the phase. */ o->Ept = o->sb->Ept; #endif SOM save_state ( o ); } else if ( o->centry == TERM ) { #ifdef RBC if ( o->uses_rbc ) l_destroy ( o->sb ); else /* destroy_state and rollback chip don't mix */ #endif destroy_state ( o->sb ); o->sb = NULL; l_destroy ( o->stk ); o->stk = NULL; #ifdef RBC if ( o->uses_rbc && rollback_op ( o, 1, posinfPlus1 ) ) { printf ( "weird error term objend for %s\n", o->name ); tester(); } #endif o->ci = NULL; o->co = NULL; o->control = EDGE; o->runstat = BLKINF; if ( ! aggressive ) cancel_omsgs ( o, o->svt, o->phase_end ); l_remove ( o ); o->svt = posinfPlus1; l_insert ( l_prev_macro ( _prqhd ), o ); dispatch (); return; } go_forward ( o ) ; dispatch (); }
TEST(Ref_count_tests, delete_value) { reference_counted<int> tester(50); tester.add_reference(); tester.release(); ASSERT_EQ(NULL, tester.is_null()); }
TEST(Ref_count_tests, set_value) { reference_counted<int> tester(45); ASSERT_EQ(45, tester.get_value()); }
TEST(Ref_count_tests, Add_one_reference) { reference_counted<int> tester(42); tester.add_reference(); ASSERT_EQ(1, tester.get_number_of_references()); }
void CPredictionCopyTester::RunTests( void ) { CCopyTesterData2 *foo1, *foo2, *foo3; foo1 = new CCopyTesterData2; foo2 = new CCopyTesterData2; foo3 = new CCopyTesterData2; foo2->MakeDifferent(); CPredictionCopy::PrepareDataMap( foo1->GetPredDescMap() ); CPredictionCopy::PrepareDataMap( foo2->GetPredDescMap() ); CPredictionCopy::PrepareDataMap( foo2->GetPredDescMap() ); // foo1 == foo3 // foo1 != foo2 { Msg( "Comparing and copying == objects, should have zero diffcount\n" ); // Compare foo1 and foo3, should be equal CPredictionCopy tester( PC_NON_NETWORKED_ONLY, foo1, false, foo3, false, CPredictionCopy::TRANSFERDATA_ERRORCHECK_SPEW ); int diff_count = 0; diff_count = tester.TransferData( "test1", -1, foo3->GetPredDescMap() ); Msg( "diff_count == %i\n", diff_count ); Assert( !diff_count ); } { Msg( "Simple compare of != objects, should spew and have non-zero diffcount\n" ); // Compare foo1 and foo2, should differ CPredictionCopy tester( PC_NON_NETWORKED_ONLY, foo1, false, foo2, false, CPredictionCopy::TRANSFERDATA_ERRORCHECK_SPEW ); int diff_count = 0; diff_count = tester.TransferData( "test2", -1, foo2->GetPredDescMap() ); Msg( "diff_count == %i (should be 13)\n", diff_count ); Assert( diff_count == 13 ); } { Msg( "Comparing and copying same objects, should spew and have non-zero diffcount\n" ); // Compare foo1 and foo2 while overriting foo2, should have differences but leave objects == CPredictionCopy tester( PC_NON_NETWORKED_ONLY, foo1, false, foo2, false, CPredictionCopy::TRANSFERDATA_COPYONLY ); tester.TransferData( "test2", -1, foo1->GetPredDescMap() ); } { Msg( "Comparing and copying objects which were just made to coincide, should have zero diffcount\n" ); // Make sure foo1 is now == foo2 CPredictionCopy tester( PC_NON_NETWORKED_ONLY, foo1, false, foo2, false, CPredictionCopy::TRANSFERDATA_ERRORCHECK_SPEW ); int diff_count = 0; diff_count = tester.TransferData( "test4", -1, foo2->GetPredDescMap() ); Msg( "diff_count == %i\n", diff_count ); Assert( !diff_count ); } delete foo3; delete foo2; delete foo1; }
void run() { IncTester tester( 0 /* inc without wait */ ); tester.go(); ASSERT( tester.wait() ); ASSERT_EQUALS( tester.getVal() , 1 ); }
int main(int argc, char *argv[]) { // Initialize MPI #ifdef HAVE_MPI MPI_Init(&argc,&argv); #endif // Create a communicator for Epetra objects #ifdef HAVE_MPI Epetra_MpiComm Comm( MPI_COMM_WORLD ); #else Epetra_SerialComm Comm; #endif int * testInt = new int[100]; delete [] testInt; bool verbose = false; if (argc > 1) if (argv[1][0]=='-' && argv[1][1]=='v') verbose = true; // Get the process ID and the total number of processors int MyPID = Comm.MyPID(); int NumProc = Comm.NumProc(); // Set up theolver options parameter list Teuchos::RCP<Teuchos::ParameterList> noxParamsPtr = Teuchos::rcp(new Teuchos::ParameterList); Teuchos::ParameterList & noxParams = *(noxParamsPtr.get()); // Set up the printing utilities // Only print output if the "-v" flag is set on the command line Teuchos::ParameterList& printParams = noxParams.sublist("Printing"); printParams.set("MyPID", MyPID); printParams.set("Output Precision", 5); printParams.set("Output Processor", 0); if( verbose ) printParams.set("Output Information", NOX::Utils::OuterIteration + NOX::Utils::OuterIterationStatusTest + NOX::Utils::InnerIteration + NOX::Utils::Parameters + NOX::Utils::Details + NOX::Utils::Warning + NOX::Utils::TestDetails); else printParams.set("Output Information", NOX::Utils::Error + NOX::Utils::TestDetails); Teuchos::RCP<NOX::Utils> printing = Teuchos::rcp( new NOX::Utils(printParams) ); // Identify the test problem if (printing->isPrintType(NOX::Utils::TestDetails)) printing->out() << "Starting epetra/NOX_Operators/NOX_BroydenOp.exe" << std::endl; // Identify processor information #ifdef HAVE_MPI if (printing->isPrintType(NOX::Utils::TestDetails)) { printing->out() << "Parallel Run" << std::endl; printing->out() << "Number of processors = " << NumProc << std::endl; printing->out() << "Print Process = " << MyPID << std::endl; } Comm.Barrier(); if (printing->isPrintType(NOX::Utils::TestDetails)) printing->out() << "Process " << MyPID << " is alive!" << std::endl; Comm.Barrier(); #else if (printing->isPrintType(NOX::Utils::TestDetails)) printing->out() << "Serial Run" << std::endl; #endif int status = 0; // Create a TestCompare class NOX::Epetra::TestCompare tester( printing->out(), *printing); double abstol = 1.e-4; double reltol = 1.e-4 ; // Test NOX::Epetra::BroydenOperator int numGlobalElems = 3 * NumProc; Epetra_Map broydenRowMap ( numGlobalElems, 0, Comm ); Epetra_Vector broydenWorkVec ( broydenRowMap ); Epetra_CrsGraph broydenWorkGraph( Copy, broydenRowMap, 0 ); std::vector<int> globalIndices(3); for( int lcol = 0; lcol < 3; ++lcol ) globalIndices[lcol] = 3 * MyPID + lcol; std::vector<int> myGlobalIndices(2); // Row 1 structure myGlobalIndices[0] = globalIndices[0]; myGlobalIndices[1] = globalIndices[2]; broydenWorkGraph.InsertGlobalIndices( globalIndices[0], 2, &myGlobalIndices[0] ); // Row 2 structure myGlobalIndices[0] = globalIndices[0]; myGlobalIndices[1] = globalIndices[1]; broydenWorkGraph.InsertGlobalIndices( globalIndices[1], 2, &myGlobalIndices[0] ); // Row 3 structure myGlobalIndices[0] = globalIndices[1]; myGlobalIndices[1] = globalIndices[2]; broydenWorkGraph.InsertGlobalIndices( globalIndices[2], 2, &myGlobalIndices[0] ); broydenWorkGraph.FillComplete(); Teuchos::RCP<Epetra_CrsMatrix> broydenWorkMatrix = Teuchos::rcp( new Epetra_CrsMatrix( Copy, broydenWorkGraph ) ); // Create an identity matrix broydenWorkVec.PutScalar(1.0); broydenWorkMatrix->ReplaceDiagonalValues(broydenWorkVec); NOX::Epetra::BroydenOperator broydenOp( noxParams, printing, broydenWorkVec, broydenWorkMatrix, true ); broydenWorkVec[0] = 1.0; broydenWorkVec[1] = -1.0; broydenWorkVec[2] = 2.0; broydenOp.setStepVector( broydenWorkVec ); broydenWorkVec[0] = 2.0; broydenWorkVec[1] = 1.0; broydenWorkVec[2] = 3.0; broydenOp.setYieldVector( broydenWorkVec ); broydenOp.computeSparseBroydenUpdate(); // Create the gold matrix for comparison Teuchos::RCP<Epetra_CrsMatrix> goldMatrix = Teuchos::rcp( new Epetra_CrsMatrix( Copy, broydenWorkGraph ) ); int numCols ; double * values ; // Row 1 answers goldMatrix->ExtractMyRowView( 0, numCols, values ); values[0] = 6.0 ; values[1] = 2.0 ; // Row 2 answers goldMatrix->ExtractMyRowView( 1, numCols, values ); values[0] = 5.0 ; values[1] = 0.0 ; // Row 3 structure goldMatrix->ExtractMyRowView( 2, numCols, values ); values[0] = -1.0 ; values[1] = 7.0 ; goldMatrix->Scale(0.2); status += tester.testCrsMatrices( broydenOp.getBroydenMatrix(), *goldMatrix, reltol, abstol, "Broyden Sparse Operator Update Test" ); // Now try a dense Broyden Update Epetra_CrsGraph broydenWorkGraph2( Copy, broydenRowMap, 0 ); myGlobalIndices.resize(3); // All Rowsstructure myGlobalIndices[0] = globalIndices[0]; myGlobalIndices[1] = globalIndices[1]; myGlobalIndices[2] = globalIndices[2]; broydenWorkGraph2.InsertGlobalIndices( globalIndices[0], 3, &myGlobalIndices[0] ); broydenWorkGraph2.InsertGlobalIndices( globalIndices[1], 3, &myGlobalIndices[0] ); broydenWorkGraph2.InsertGlobalIndices( globalIndices[2], 3, &myGlobalIndices[0] ); broydenWorkGraph2.FillComplete(); Teuchos::RCP<Epetra_CrsMatrix> broydenWorkMatrix2 = Teuchos::rcp( new Epetra_CrsMatrix( Copy, broydenWorkGraph2 ) ); // Create an identity matrix broydenWorkVec.PutScalar(1.0); broydenWorkMatrix2->ReplaceDiagonalValues(broydenWorkVec); NOX::Epetra::BroydenOperator broydenOp2( noxParams, printing, broydenWorkVec, broydenWorkMatrix2, true ); broydenWorkVec[0] = 1.0; broydenWorkVec[1] = -1.0; broydenWorkVec[2] = 2.0; broydenOp2.setStepVector( broydenWorkVec ); broydenWorkVec[0] = 2.0; broydenWorkVec[1] = 1.0; broydenWorkVec[2] = 3.0; broydenOp2.setYieldVector( broydenWorkVec ); broydenOp2.computeSparseBroydenUpdate(); // Create the gold matrix for comparison Teuchos::RCP<Epetra_CrsMatrix> goldMatrix2 = Teuchos::rcp( new Epetra_CrsMatrix( Copy, broydenWorkGraph2 ) ); // Row 1 answers goldMatrix2->ExtractMyRowView( 0, numCols, values ); values[0] = 7.0 ; values[1] = -1.0 ; values[2] = 2.0 ; // Row 2 answers goldMatrix2->ExtractMyRowView( 1, numCols, values ); values[0] = 2.0 ; values[1] = 4.0 ; values[2] = 4.0 ; // Row 3 structure goldMatrix2->ExtractMyRowView( 2, numCols, values ); values[0] = 1.0 ; values[1] = -1.0 ; values[2] = 8.0 ; double scaleF = 1.0 / 6.0; goldMatrix2->Scale( scaleF ); status += tester.testCrsMatrices( broydenOp2.getBroydenMatrix(), *goldMatrix2, reltol, abstol, "Broyden Sparse Operator Update Test (Dense)" ); // Now test the ability to remove active entries in the Broyden update Epetra_CrsGraph inactiveGraph( Copy, broydenRowMap, 0 ); // Row 1 structure inactiveGraph.InsertGlobalIndices( globalIndices[0], 1, &myGlobalIndices[1] ); // Row 2 structure inactiveGraph.InsertGlobalIndices( globalIndices[1], 1, &myGlobalIndices[2] ); // Row 3 structure inactiveGraph.InsertGlobalIndices( globalIndices[2], 1, &myGlobalIndices[0] ); inactiveGraph.FillComplete(); // Inactivate entries in dense matrix to arrive again at the original sparse structure broydenOp2.removeEntriesFromBroydenUpdate( inactiveGraph ); #ifdef HAVE_NOX_DEBUG if( verbose ) broydenOp2.outputActiveEntries(); #endif // Reset to the identity matrix broydenOp2.resetBroydenMatrix( *broydenWorkMatrix2 ); // Step and Yield vectors are already set broydenOp2.computeSparseBroydenUpdate(); status += tester.testCrsMatrices( broydenOp2.getBroydenMatrix(), *goldMatrix, reltol, abstol, "Broyden Sparse Operator Update Test (Entry Removal)", false ); // Summarize test results if( status == 0 ) printing->out() << "Test passed!" << std::endl; else printing->out() << "Test failed!" << std::endl; #ifdef HAVE_MPI MPI_Finalize(); #endif // Final return value (0 = successfull, non-zero = failure) return status; }
int main(int argc, char *argv[]) { // Initialize POOMA and output stream, using Tester class Pooma::initialize(argc, argv); Pooma::Tester tester(argc, argv); Interval<1> a(0,10),b(0,20),r(3,7); Interval<2> s(a,b),rr(r,r); typedef std::vector<Interval<2> > DomainList_t; DomainList_t res; tester.out() << " from " << s<< " remove "<<rr<<std::endl; res = DomainRemoveOverlap(s,rr); DomainList_t::iterator start = res.begin(); DomainList_t::iterator end = res.end(); for ( ; start!=end ; ++start) { tester.out() << *start << std::endl; } res.clear(); Interval<2> k(Interval<1>(2,3),Interval<1>(-1,30)); res = DomainRemoveOverlap(s,k); start = res.begin(); end = res.end(); for ( ; start!=end ; ++start) { tester.out() << *start << std::endl; } res.clear(); Interval<2> k2(Interval<1>(2,3),Interval<1>(0,20)); res = DomainRemoveOverlap(s,k2); tester.out() << " " <<std::endl; tester.out() <<"from " <<s<<" remove "<<k2<<std::endl; tester.out() << " " <<std::endl; start = res.begin(); end = res.end(); for ( ; start!=end ; ++start) { tester.out() << *start << std::endl; } res.clear(); Interval<2> k3(Interval<1>(-7,3),Interval<1>(-6,8)); res = DomainRemoveOverlap(s,k3); tester.out() << " " <<std::endl; tester.out() <<"from "<< s<<" remove "<<k3<<std::endl; tester.out() << " " <<std::endl; start = res.begin(); end = res.end(); for ( ; start!=end ; ++start) { tester.out() << *start << std::endl; } tester.out() << "-------------------------------------------" << std::endl; int retval = tester.results("DomainRO operations"); Pooma::finalize(); return retval; }
int main(int argc, char *argv[]) { Pooma::initialize(argc,argv); Pooma::Tester tester(argc, argv); // -------------------------------------------------------------------------- // 3D // -------------------------------------------------------------------------- Tensor<3,double,Full> t3f1(0.0, 3.0, 6.0, 1.0, 4.0, 7.0, 2.0, 5.0, 8.0); tester.out() << "t3f1: " << t3f1 << std::endl; Tensor<3,double,Full> t3f2 = -t3f1; tester.out() << "t3f2: " << t3f2 << std::endl; Tensor<3,double,Symmetric> t3s1(1.0, 2.0, 3.0, 4.0, 5.0, 6.0); tester.out() << "t3s1: " << t3s1 << std::endl; Tensor<3,double,Symmetric> t3s2(-1.0, -2.0, -3.0, -4.0, -5.0, -6.0); tester.out() << "t3s2: " << t3s2 << std::endl; Tensor<3,double,Full> t3s1AsFull(1.0,2.0,4.0, 2.0,3.0,5.0, 4.0,5.0,6.0); tester.out() << "t3s1AsFull: " << t3s1AsFull << std::endl; Tensor<3,double,Full> t3s2AsFull = -t3s1AsFull; tester.out() << "t3s2AsFull: " << t3s2AsFull << std::endl; Tensor<3,double,Symmetric> t3s3(9.0, 9.0, 9.0, 9.0, 9.0, 9.0), t3s4(9.0, 9.0, 9.0, 9.0, 9.0, 9.0); t3s3 = t3s1 + t3s2; tester.out() << "t3s3 = t3s1 + t3s2: " << t3s3 << std::endl; tester.check("t3s3", t3s3, Tensor<3,double,Symmetric>(0.0)); tester.check("t3s3 against Full", (t3s3 == Tensor<3,double,Symmetric>(0.0))); Tensor<3,double,Full> t3f3(99.9), t3f4(99.9), t3f5(99.9), t3f6(99.9); t3f3 = t3f1 + t3f2; // No need to check results here; done in TestTensors t3f4 = t3s1 + t3s2; tester.out() << "t3f4 = t3s1 + t3s2: " << t3f4 << std::endl; tester.check("t3f4", (t3f4 == t3s3)); t3f5 = t3f1 + t3s2; tester.out() << "t3f5 = t3f1 + t3s2: " << t3f5 << std::endl; tester.check("t3f5", t3f5, t3f1 + t3s2AsFull); t3f6 = t3s2 + t3f1; tester.out() << "t3f6 = t3s2 + t3f1: " << t3f6 << std::endl; tester.check("t3f6", t3f6, t3f1 + t3s2AsFull); t3f6 -= t3f1; tester.out() << "t3f6 -= t3f1: " << t3f6 << std::endl; tester.check("t3f6", t3f6, t3s2AsFull); t3s4 = t3s3 - t3f1; tester.out() << "t3s4 = t3s3 - t3f1: " << t3s4 << std::endl; tester.check("t3s4", (t3s4 == Tensor<3,double,Symmetric>(0,-3,-4,-6,-7,-8))); // Test Tensor dot Tensor: // Full: double sum = 0.0; int i, j, k; t3f3 = dot(t3f1, t3f2); for (i = 0; i < 3; ++i) { for (j = 0; j < 3; ++j) { for (k = 0; k < 3; ++k) { t3f3(i,k) -= t3f1(i,j)*t3f2(j,k); } } } t3f3 = t3f3*t3f3; for (i = 0; i < 3; ++i) { for (j = 0; j < 3; ++j) { sum += t3f3(i,j); } } tester.check("dot(t3f1, t3f2)", (sum == 0)); // Symmetric: sum = 0.0; t3f3 = dot(t3s1, t3s2); for (i = 0; i < 3; ++i) { for (j = 0; j < 3; ++j) { for (k = 0; k < 3; ++k) { t3f3(i,k) -= t3s1(i,j)*t3s2(j,k); } } } t3f3 = t3f3*t3f3; for (i = 0; i < 3; ++i) { for (j = 0; j < 3; ++j) { sum += t3f3(i,j); } } tester.check("dot(t3s1, t3s2)", (sum == 0)); // Test Tensor dot Vector, and vice-versa: // Full: // Vector dot Tensor Vector<3> v31(1.0, 2.0, 3.0); tester.out() << "v31: " << v31 << std::endl; Vector<3> v32(9.0); v32 = dot(v31, t3f2); tester.out() << "v32 = dot(v31, t3f2): " << v32 << std::endl; for (i = 0; i < 3; ++i) { for (j = 0; j < 3; ++j) { v32(j) -= v31(i)*t3f2(i,j); } } v32 = v32*v32; sum = 0.0; for (i = 0; i < 3; ++i) { sum += v32(i); } tester.check("dot(v31, t3f2)", (sum == 0)); // Tensor dot Vector v32 = dot(t3f2, v31); tester.out() << "v32 = dot(t3f2, v31): " << v32 << std::endl; for (i = 0; i < 3; ++i) { for (j = 0; j < 3; ++j) { v32(i) -= t3f2(i,j)*v31(j); } } v32 = v32*v32; sum = 0.0; for (i = 0; i < 3; ++i) { sum += v32(i); } tester.check("dot(t3f2, v31)", (sum == 0)); // Symmetric: // Vector dot Tensor v32 = dot(v31, t3s2); tester.out() << "v32 = dot(v31, t3s2): " << v32 << std::endl; for (i = 0; i < 3; ++i) { for (j = 0; j < 3; ++j) { v32(j) -= v31(i)*t3s2(i,j); } } v32 = v32*v32; sum = 0.0; for (i = 0; i < 3; ++i) { sum += v32(i); } tester.check("dot(v31, t3s2)", (sum == 0)); // Tensor dot Vector v32 = dot(t3s2, v31); tester.out() << "v32 = dot(t3s2, v31): " << v32 << std::endl; for (i = 0; i < 3; ++i) { for (j = 0; j < 3; ++j) { v32(i) -= t3s2(i,j)*v31(j); } } v32 = v32*v32; sum = 0.0; for (i = 0; i < 3; ++i) { sum += v32(i); } tester.check("dot(t3s2, v31)", (sum == 0)); // -------------------------------------------------------------------------- // 2D // -------------------------------------------------------------------------- Tensor<2,double,Full> t2f1(0.0, 2.0, 1.0, 3.0); tester.out() << "t2f1: " << t2f1 << std::endl; Tensor<2,double,Full> t2f2 = -t2f1; tester.out() << "t2f2: " << t2f2 << std::endl; Tensor<2,double,Symmetric> t2s1(1.0, 2.0, 3.0); tester.out() << "t2s1: " << t2s1 << std::endl; Tensor<2,double,Symmetric> t2s2(-1.0, -2.0, -3.0); tester.out() << "t2s2: " << t2s2 << std::endl; Tensor<2,double,Full> t2s1AsFull(1.0,2.0, 2.0,3.0); tester.out() << "t2s1AsFull: " << t2s1AsFull << std::endl; Tensor<2,double,Full> t2s2AsFull = -t2s1AsFull; tester.out() << "t2s2AsFull: " << t2s2AsFull << std::endl; Tensor<2,double,Symmetric> t2s3(9.0, 9.0, 9.0), t2s4(9.0, 9.0, 9.0); t2s3 = t2s1 + t2s2; tester.out() << "t2s3 = t2s1 + t2s2: " << t2s3 << std::endl; tester.check("t2s3", t2s3, Tensor<2,double,Symmetric>(0.0)); tester.check("t2s3 against Full", (t2s3 == Tensor<2,double,Symmetric>(0.0))); Tensor<2,double,Full> t2f3(99.9), t2f4(99.9), t2f5(99.9), t2f6(99.9), t2f7(99.9); t2f3 = t2f1 + t2f2; tester.out() << "t2f3 = t2f1 + t2f2: " << t2f3 << std::endl; tester.check("t2f3", t2f3, Tensor<2,double,Full>(0.0)); t2f4 = t2s1 + t2s2; tester.out() << "t2f4 = t2s1 + t2s2: " << t2f4 << std::endl; tester.check("t2f4", (t2f4 == t2s3)); t2f5 = t2f1 + t2s2; tester.out() << "t2f5 = t2f1 + t2s2: " << t2f5 << std::endl; tester.check("t2f5", t2f5, t2f1 + t2s2AsFull); t2f6 = t2s2 + t2f1; tester.out() << "t2f6 = t2s2 + t2f1: " << t2f6 << std::endl; tester.check("t2f6", t2f6, t2f1 + t2s2AsFull); t2f6 -= t2f1; tester.out() << "t2f6 -= t2f1: " << t2f6 << std::endl; tester.check("t2f6", t2f6, t2s2AsFull); t2s4 = t2s3 - t2f1; tester.out() << "t2s4 = t2s3 - t2f1: " << t2s4 << std::endl; tester.check("t2s4", (t2s4 == Tensor<2,double,Symmetric>(-0, -2, -3))); // Test Tensor dot Tensor: // Full: sum = 0.0; t2f3 = dot(t2f1, t2f2); for (i = 0; i < 2; ++i) { for (j = 0; j < 2; ++j) { for (k = 0; k < 2; ++k) { t2f3(i,k) -= t2f1(i,j)*t2f2(j,k); } } } t2f3 = t2f3*t2f3; for (i = 0; i < 2; ++i) { for (j = 0; j < 2; ++j) { sum += t2f3(i,j); } } tester.check("dot(t2f1, t2f2)", (sum == 0)); // Symmetric: sum = 0.0; t2f3 = dot(t2s1, t2s2); for (i = 0; i < 2; ++i) { for (j = 0; j < 2; ++j) { for (k = 0; k < 2; ++k) { t2f3(i,k) -= t2s1(i,j)*t2s2(j,k); } } } t2f3 = t2f3*t2f3; for (i = 0; i < 2; ++i) { for (j = 0; j < 2; ++j) { sum += t2f3(i,j); } } tester.check("dot(t2s1, t2s2)", (sum == 0)); // Test Tensor dot Vector, and vice-versa: // Full: // Vector dot Tensor Vector<2> v21(1.0, 2.0); tester.out() << "v21: " << v21 << std::endl; Vector<2> v22(9.0); v22 = dot(v21, t2f2); tester.out() << "v22 = dot(v21, t2f2): " << v22 << std::endl; for (i = 0; i < 2; ++i) { for (j = 0; j < 2; ++j) { v22(j) -= v21(i)*t2f2(i,j); } } v22 = v22*v22; sum = 0.0; for (i = 0; i < 2; ++i) { sum += v22(i); } tester.check("dot(v21, t2f2)", (sum == 0)); // Tensor dot Vector v22 = dot(t2f2, v21); tester.out() << "v22 = dot(t2f2, v21): " << v22 << std::endl; for (i = 0; i < 2; ++i) { for (j = 0; j < 2; ++j) { v22(i) -= t2f2(i,j)*v21(j); } } v22 = v22*v22; sum = 0.0; for (i = 0; i < 2; ++i) { sum += v22(i); } tester.check("dot(t2f2, v21)", (sum == 0)); // Symmetric: // Vector dot Tensor v22 = dot(v21, t2s2); tester.out() << "v22 = dot(v21, t2s2): " << v22 << std::endl; for (i = 0; i < 2; ++i) { for (j = 0; j < 2; ++j) { v22(j) -= v21(i)*t2s2(i,j); } } v22 = v22*v22; sum = 0.0; for (i = 0; i < 2; ++i) { sum += v22(i); } tester.check("dot(v21, t2s2)", (sum == 0)); // Tensor dot Vector v22 = dot(t2s2, v21); tester.out() << "v22 = dot(t2s2, v21): " << v22 << std::endl; for (i = 0; i < 2; ++i) { for (j = 0; j < 2; ++j) { v22(i) -= t2s2(i,j)*v21(j); } } v22 = v22*v22; sum = 0.0; for (i = 0; i < 2; ++i) { sum += v22(i); } tester.check("dot(t2s2, v21)", (sum == 0)); // -------------------------------------------------------------------------- // 1D // -------------------------------------------------------------------------- Tensor<1,double,Full> t1f1(1.0); tester.out() << "t1f1: " << t1f1 << std::endl; Tensor<1,double,Full> t1f2 = -t1f1; tester.out() << "t1f2: " << t1f2 << std::endl; Tensor<1,double,Symmetric> t1s1(1.0); tester.out() << "t1s1: " << t1s1 << std::endl; Tensor<1,double,Symmetric> t1s2(-1.0); tester.out() << "t1s2: " << t1s2 << std::endl; Tensor<1,double,Full> t1s1AsFull(1.0); tester.out() << "t1s1AsFull: " << t1s1AsFull << std::endl; Tensor<1,double,Full> t1s2AsFull = -t1s1AsFull; tester.out() << "t1s2AsFull: " << t1s2AsFull << std::endl; Tensor<1,double,Symmetric> t1s3(9.0), t1s4(9.0); t1s3 = t1s1 + t1s2; tester.out() << "t1s3 = t1s1 + t1s2: " << t1s3 << std::endl; tester.check("t1s3", t1s3, Tensor<1,double,Symmetric>(0.0)); tester.check("t1s3 against Full", (t1s3 == Tensor<1,double,Symmetric>(0.0))); Tensor<1,double,Full> t1f3(99.9), t1f4(99.9), t1f5(99.9), t1f6(99.9), t1f7(99.9); t1f3 = t1f1 + t1f2; tester.out() << "t1f3 = t1f1 + t1f2: " << t1f3 << std::endl; tester.check("t1f3", t1f3, Tensor<1,double,Full>(0.0)); t1f4 = t1s1 + t1s2; tester.out() << "t1f4 = t1s1 + t1s2: " << t1f4 << std::endl; tester.check("t1f4", (t1f4 == t1s3)); t1f5 = t1f1 + t1s2; tester.out() << "t1f5 = t1f1 + t1s2: " << t1f5 << std::endl; tester.check("t1f5", t1f5, t1f1 + t1s2AsFull); t1f6 = t1s2 + t1f1; tester.out() << "t1f6 = t1s2 + t1f1: " << t1f6 << std::endl; tester.check("t1f6", t1f6, t1f1 + t1s2AsFull); t1f6 -= t1f1; tester.out() << "t1f6 -= t1f1: " << t1f6 << std::endl; tester.check("t1f6", t1f6, t1s2AsFull); t1s4 = t1s3 - t1f1; tester.out() << "t1s4 = t1s3 - t1f1: " << t1s4 << std::endl; tester.check("t1s4", (t1s4 == Tensor<1,double,Symmetric>(-1))); // Test Tensor dot Tensor: // Full: sum = 0.0; t1f3 = dot(t1f1, t1f2); for (i = 0; i < 1; ++i) { for (j = 0; j < 1; ++j) { for (k = 0; k < 1; ++k) { t1f3(i,k) -= t1f1(i,j)*t1f2(j,k); } } } t1f3 = t1f3*t1f3; for (i = 0; i < 1; ++i) { for (j = 0; j < 1; ++j) { sum += t1f3(i,j); } } tester.check("dot(t1f1, t1f2)", (sum == 0)); // Symmetric: sum = 0.0; t1f3 = dot(t1s1, t1s2); for (i = 0; i < 1; ++i) { for (j = 0; j < 1; ++j) { for (k = 0; k < 1; ++k) { t1f3(i,k) -= t1s1(i,j)*t1s2(j,k); } } } t1f3 = t1f3*t1f3; for (i = 0; i < 1; ++i) { for (j = 0; j < 1; ++j) { sum += t1f3(i,j); } } tester.check("dot(t1s1, t1s2)", (sum == 0)); // Test Tensor dot Vector, and vice-versa: // Full: // Vector dot Tensor Vector<1> v11(1.0); tester.out() << "v11: " << v11 << std::endl; Vector<1> v12(9.0); v12 = dot(v11, t1f2); tester.out() << "v12 = dot(v11, t1f2): " << v12 << std::endl; for (i = 0; i < 1; ++i) { for (j = 0; j < 1; ++j) { v12(j) -= v11(i)*t1f2(i,j); } } v12 = v12*v12; sum = 0.0; for (i = 0; i < 1; ++i) { sum += v12(i); } tester.check("dot(v11, t1f2)", (sum == 0)); // Tensor dot Vector v12 = dot(t1f2, v11); tester.out() << "v12 = dot(t1f2, v11): " << v12 << std::endl; for (i = 0; i < 1; ++i) { for (j = 0; j < 1; ++j) { v12(i) -= t1f2(i,j)*v11(j); } } v12 = v12*v12; sum = 0.0; for (i = 0; i < 1; ++i) { sum += v12(i); } tester.check("dot(t1f2, v11)", (sum == 0)); // Symmetric: // Vector dot Tensor v12 = dot(v11, t1s2); tester.out() << "v12 = dot(v11, t1s2): " << v12 << std::endl; for (i = 0; i < 1; ++i) { for (j = 0; j < 1; ++j) { v12(j) -= v11(i)*t1s2(i,j); } } v12 = v12*v12; sum = 0.0; for (i = 0; i < 1; ++i) { sum += v12(i); } tester.check("dot(v11, t1s2)", (sum == 0)); // Tensor dot Vector v12 = dot(t1s2, v11); tester.out() << "v12 = dot(t1s2, v11): " << v12 << std::endl; for (i = 0; i < 1; ++i) { for (j = 0; j < 1; ++j) { v12(i) -= t1s2(i,j)*v11(j); } } v12 = v12*v12; sum = 0.0; for (i = 0; i < 1; ++i) { sum += v12(i); } tester.check("dot(t1s2, v11)", (sum == 0)); int ret = tester.results("TestSymmetricTensors"); Pooma::finalize(); return ret; }
void gkBlenderMeshConverter::convert_bmesh(void) { Blender::MVert* mvert = m_bmesh->mvert; Blender::MPoly* mpoly = m_bmesh->mpoly; Blender::MLoop* mloop = m_bmesh->mloop; Blender::MTexPoly* mtexpoly = m_bmesh->mtpoly; Blender::MLoopUV* muvloop = m_bmesh->mloopuv; Blender::MLoopCol* mloopCol = m_bmesh->mloopcol; // UV-Layer-Data Blender::MTexPoly* mtpoly[8] = {0, 0, 0, 0, 0, 0, 0, 0}; Blender::MLoopUV* muvs[8] = {0, 0, 0, 0, 0, 0, 0, 0}; bool hasUV = muvloop != 0; Blender::MVert vpak[4]; unsigned int cpak[4]; unsigned int ipak[4]; int totlayer; gkSubMesh* curSubMesh = 0; m_meshtable.clear(); gkLoaderUtils_getLayers_bmesh(m_bmesh, mtpoly,muvs, &mloopCol, totlayer); bool sortByMat = gkEngine::getSingleton().getUserDefs().blendermat; bool openglVertexColor = gkEngine::getSingleton().getUserDefs().rendersystem == OGRE_RS_GL; bool hasTexPoly = mtexpoly != 0; for (int fi = 0; fi < m_bmesh->totpoly; fi++) { const Blender::MPoly& curpoly = mpoly[fi]; const Blender::MTexPoly& curTexPol = mtexpoly[fi]; // skip if face is not a triangle || quad if (curpoly.totloop<3) continue; if (curpoly.totloop>4){ gkLogger::write("Using poly with more than 4 verts is not supported by gkMeshConverter!"); continue; } const bool isQuad = curpoly.totloop==4; TempFace t[2]; PackedFace f; f.totlay = totlayer; const Blender::MLoop& v1 = mloop[curpoly.loopstart]; const Blender::MLoop& v2 = mloop[curpoly.loopstart+1]; const Blender::MLoop& v3 = mloop[curpoly.loopstart+2]; if (isQuad) { const Blender::MLoop& v4 = mloop[curpoly.loopstart+3]; const Blender::MLoopUV& uv1 = muvloop[curpoly.loopstart]; const Blender::MLoopUV& uv2 = muvloop[curpoly.loopstart+1]; const Blender::MLoopUV& uv3 = muvloop[curpoly.loopstart+2]; const Blender::MLoopUV& uv4 = muvloop[curpoly.loopstart+3]; vpak[0] = mvert[v1.v]; vpak[1] = mvert[v2.v]; vpak[2] = mvert[v3.v]; vpak[3] = mvert[v4.v]; ipak[0] = v1.v; ipak[1] = v2.v; ipak[2] = v3.v; ipak[3] = v4.v; if (mloopCol != 0) { cpak[0] = *(unsigned int*)(mloopCol + curpoly.loopstart); cpak[1] = *(unsigned int*)(mloopCol + curpoly.loopstart+1); cpak[2] = *(unsigned int*)(mloopCol + curpoly.loopstart+2); cpak[3] = *(unsigned int*)(mloopCol + curpoly.loopstart+3); } else cpak[0] = cpak[1] = cpak[2] = cpak[3] = 0xFFFFFFFF; //TODO: Multitexture!? for (int i = 0; i < totlayer; i++) { if (mtpoly[i] != 0) { f.uvLayers[i][0] = gkVector2((float*)&muvs[i][curpoly.loopstart].uv[0]); f.uvLayers[i][1] = gkVector2((float*)&muvs[i][curpoly.loopstart+1].uv[0]); f.uvLayers[i][2] = gkVector2((float*)&muvs[i][curpoly.loopstart+2].uv[0]); f.uvLayers[i][3] = gkVector2((float*)&muvs[i][curpoly.loopstart+3].uv[0]); } } f.verts = vpak; f.index = ipak; f.colors = cpak; // what is this? gkVector3 e0, e1; e0 = (gkVector3(mvert[v1.v].co) - gkVector3(mvert[v2.v].co)); e1 = (gkVector3(mvert[v3.v].co) - gkVector3(mvert[v4.v].co)); if (e0.squaredLength() < e1.squaredLength()) { convertIndexedTriangle(&t[0], 0, 1, 2, f); convertIndexedTriangle(&t[1], 2, 3, 0, f); } else { convertIndexedTriangle(&t[0], 0, 1, 3, f); convertIndexedTriangle(&t[1], 3, 1, 2, f); } } else { for (int i = 0; i < totlayer; i++) { if (mtpoly[i] != 0) { f.uvLayers[i][0] = gkVector2((float*)&muvs[i][curpoly.loopstart].uv[0]); f.uvLayers[i][1] = gkVector2((float*)&muvs[i][curpoly.loopstart+1].uv[0]); f.uvLayers[i][2] = gkVector2((float*)&muvs[i][curpoly.loopstart+2].uv[0]); } } vpak[0] = mvert[v1.v]; vpak[1] = mvert[v2.v]; vpak[2] = mvert[v3.v]; ipak[0] = v1.v; ipak[1] = v2.v; ipak[2] = v3.v; if (mloopCol != 0) { cpak[0] = *(unsigned int*)(mloopCol + curpoly.loopstart); cpak[1] = *(unsigned int*)(mloopCol + curpoly.loopstart+1); cpak[2] = *(unsigned int*)(mloopCol + curpoly.loopstart+2); } else cpak[0] = cpak[1] = cpak[2] = 0xFFFFFFFF; f.verts = vpak; f.index = ipak; f.colors = cpak; convertIndexedTriangle(&t[0], 0, 1, 2, f); } gkMeshPair tester(curSubMesh); if (sortByMat) { int mode = 0; if (mtpoly[0]) mode = mtpoly[0][fi].mode; tester.test = gkMeshHashKey(curpoly.mat_nr, mode); } else { Blender::Image* ima[8] = {0, 0, 0, 0, 0, 0, 0, 0}; for (int i = 0; i < totlayer; i++) { if (mtpoly[i] != 0) ima[i] = mtpoly[i][fi].tpage; } int mode = 0, alpha = 0; if (mtpoly[0]) { mode = mtpoly[0][fi].mode; alpha = mtpoly[0][fi].transp; } tester.test = gkMeshHashKey(mode, alpha, ima); } // find submesh UTsize arpos = 0; if ((arpos = m_meshtable.find(tester)) == UT_NPOS) { curSubMesh = new gkSubMesh(); curSubMesh->setTotalLayers(totlayer); curSubMesh->setVertexColors(mloopCol != 0); m_gmesh->addSubMesh(curSubMesh); tester.item = curSubMesh; m_meshtable.push_back(tester); } else curSubMesh = m_meshtable.at(arpos).item; if (curSubMesh == 0) continue; if (!(curpoly.flag & ME_SMOOTH)) { // face normal calcNormal(&t[0]); if (isQuad) t[1].v0.no = t[1].v1.no = t[1].v2.no = t[0].v0.no; } // ---- warning ----- // mtpoly[0][fi].mode is always 0 which makes the mesh invisible // For now setting the standardvalue to collider (which means visible) // This is afaik the only data I couldn't get in import int triflag = gkTriangle::TRI_COLLIDER; if (mtpoly[0]) { if (mtpoly[0][fi].mode & TF_DYNAMIC) triflag |= gkTriangle::TRI_COLLIDER; if (mtpoly[0][fi].mode & TF_INVISIBLE) triflag |= gkTriangle::TRI_INVISIBLE; } else triflag = gkTriangle::TRI_COLLIDER; // ---- end warning ------ curSubMesh->addTriangle(t[0].v0, t[0].i0, t[0].v1, t[0].i1, t[0].v2, t[0].i2, triflag); if (isQuad) { curSubMesh->addTriangle(t[1].v0, t[1].i0, t[1].v1, t[1].i1, t[1].v2, t[1].i2, triflag); } } }
bool test_simd_int(std::ostream& out, const std::string& name) { simd_int_basic_tester<T, N, A> tester(name); return test_simd_int_basic(out, tester); }
int main(int argc, char *argv[]) { Pooma::initialize(argc, argv); Pooma::Tester tester(argc, argv); #if POOMA_CHEETAH typedef Cheetah::MatchingHandler Handler_t; const int numContexts = Pooma::contexts(); const int myContext = Pooma::context(); Handler_t *handler = new Cheetah::MatchingHandler(*Pooma::controller()); tester.out() << "Testing Grid messages . . .\n"; tester.out() << "Running with " << numContexts << " contexts." << std::endl; int start = myContext * 10; int end = (myContext + 1) * 10; Range<1> r(start, end, 2); Grid<1> foo(r); tester.out() << "Here are our Grids..." << std::endl; BARRIER; tester.out().setOutputContext(-1); tester.out() << foo << std::endl; // Here's the message pattern - we're just sending in a ring: int toContext = (myContext + 1) % numContexts; int fromContext = (myContext + numContexts - 1) % numContexts; BARRIER; tester.out() << "Node " << myContext << "; Sending to " << toContext << "; Receiving from " << fromContext << std::endl; int msgtag = 0; handler->send(toContext, msgtag, foo); Send_t bar; handler->request(fromContext, msgtag, receiveGrid, &bar); while (!gotIt) Pooma::poll(); BARRIER; tester.out().setOutputContext(0); tester.out() << "Here are the Grids we received:" << std::endl; BARRIER; tester.out().setOutputContext(-1); tester.out() << bar << std::endl; start = fromContext * 10; end = (fromContext + 1) * 10; Range<1> ans(start, end, 2); BARRIER; tester.check(bar == ans); delete handler; #else tester.out() << "This test requires Cheetah" << std::endl; #endif int ret = tester.results("GridMessage Test"); Pooma::finalize(); return ret; }
bool test_simd_cast(std::ostream& out, const std::string& name) { simd_cast_tester<N, A> tester(name); return test_simd_cast(out, tester); }
bool test_exponential(std::ostream& out, const std::string& name) { simd_exponential_tester<T, N, A> tester(name); return test_simd_exponential(out, tester); }
bool test_complex_simd_load_store(std::ostream& out, const std::string& name) { simd_complex_ls_tester<T, N, A> tester(name); return test_complex_simd_load_store(out, tester); }
void tst_QSocketNotifier::unexpectedDisconnection() { /* Given two sockets and two QSocketNotifiers registered on each their socket. If both sockets receive data, and the first slot invoked by one of the socket notifiers empties both sockets, the other notifier will also emit activated(). This results in unexpected disconnection in QAbstractSocket. The use case is that somebody calls one of the waitFor... functions in a QSocketNotifier activated slot, and the waitFor... functions do local selects that can empty both stdin and stderr while waiting for fex bytes to be written. */ QTcpServer server; QVERIFY(server.listen(QHostAddress::LocalHost, 0)); NATIVESOCKETENGINE readEnd1; readEnd1.initialize(QAbstractSocket::TcpSocket); readEnd1.connectToHost(server.serverAddress(), server.serverPort()); QVERIFY(readEnd1.waitForWrite()); QVERIFY(readEnd1.state() == QAbstractSocket::ConnectedState); QVERIFY(server.waitForNewConnection()); QTcpSocket *writeEnd1 = server.nextPendingConnection(); QVERIFY(writeEnd1 != 0); NATIVESOCKETENGINE readEnd2; readEnd2.initialize(QAbstractSocket::TcpSocket); readEnd2.connectToHost(server.serverAddress(), server.serverPort()); QVERIFY(readEnd2.waitForWrite()); QVERIFY(readEnd2.state() == QAbstractSocket::ConnectedState); QVERIFY(server.waitForNewConnection()); QTcpSocket *writeEnd2 = server.nextPendingConnection(); QVERIFY(writeEnd2 != 0); writeEnd1->write("1", 1); writeEnd2->write("2", 1); writeEnd1->waitForBytesWritten(); writeEnd2->waitForBytesWritten(); writeEnd1->flush(); writeEnd2->flush(); UnexpectedDisconnectTester tester(&readEnd1, &readEnd2); QTimer timer; timer.setSingleShot(true); timer.start(30000); do { // we have to wait until sequence value changes // as any event can make us jump out processing QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents); QVERIFY(timer.isActive()); //escape if test would hang } while(tester.sequence <= 0); QVERIFY(readEnd1.state() == QAbstractSocket::ConnectedState); QVERIFY(readEnd2.state() == QAbstractSocket::ConnectedState); QCOMPARE(tester.sequence, 2); readEnd1.close(); readEnd2.close(); writeEnd1->close(); writeEnd2->close(); server.close(); }
void Main(int argc, char** argv) { std::vector<Patterns> patterns; std::vector<std::string> types; std::string file; std::string algName = "run"; int repCount = 10; ITester::Algorithm alg; for (--argc, ++argv; argc; --argc, ++argv) { if (!strcmp(*argv, "-t") && argc >= 2) { types.push_back(argv[1]); patterns.push_back(Patterns()); --argc, ++argv; } else if (!strcmp(*argv, "-f") && argc >= 2) { file = argv[1]; --argc, ++argv; } else if (!strcmp(*argv, "-a") && argc >= 2) { algName = argv[1]; --argc, ++argv; } else if (!strcmp(*argv, "-c") && argc >= 2) { repCount = Pire::FromString<int>(argv[1]); --argc, ++argv; } else if (!strcmp(*argv, "-e") && argc >= 2) { if (patterns.empty()) throw usage; patterns.back().push_back(argv[1]); --argc, ++argv; } else { if (patterns.empty()) throw usage; patterns.back().push_back(*argv); } } if (types.empty() || file.empty() || patterns.back().empty()) throw usage; if (algName == "run") alg = ITester::DefaultRun; else if (algName == "shortestprefix") alg = ITester::ShortestPrefix; else if (algName == "longestprefix") alg = ITester::LongestPrefix; else throw usage; std::unique_ptr<ITester> tester(CreateTester(types)); tester->Prepare(alg, patterns); FileMmap fmap(file.c_str()); // Run the benchmark multiple times std::ostringstream stream; for (std::vector<std::string>::iterator j = types.begin(), je = types.end(); j != je; ++j) stream << *j << " "; std::string typesName = stream.str(); for (int i = 0; i < repCount; ++i) { Timer timer(typesName, fmap.Size()); tester->Run(fmap.Begin(), fmap.End()); } }
int main(int argc, char* argv[]) { // initialize Pooma Pooma::initialize(argc,argv); Pooma::Tester tester(argc,argv); int return_status = 0; int n = 20; double pi = 3.1415926535897932; Array<1> a(n),b(n),c(n),d(n); Array<1,double,CompressibleBrick> aa(n),bb(n),cc(n),dd(n); int i; for (i=0; i<n; ++i) { a(i) = sin(0.1*pi*i); b(i) = cos(0.1*pi*i); c(i) = 1.0; d(i) = 2.0; } tester.out() << "Testing Compressile Bricks." << std::endl; aa = a; bb = b; cc = c; dd = d; Pooma::blockAndEvaluate(); tester.out() << " i aa bb cc dd " << std::endl; for (i=0; i<n; ++i) { tester.out() << i << " " << aa.read(i) << " " << bb.read(i) << " " << cc.read(i) << " " << dd.read(i) << std::endl; } tester.out() << "aa: " << compressed(aa) << std::endl; tester.out() << "bb: " << compressed(bb) << std::endl; tester.out() << "cc: " << compressed(cc) << std::endl; tester.out() << "dd: " << compressed(dd) << std::endl; tester.check(!aa.engine().compressed()); tester.check(!bb.engine().compressed()); tester.check(cc.engine().compressed()); tester.check(dd.engine().compressed()); aa = aa*aa+bb*bb; bb = cc*dd+2.0*cc; bb += cc*dd+2.0*cc; cc = dd*c+d; Pooma::blockAndEvaluate(); tester.out() << " i aa bb cc dd " << std::endl; for (i=0; i<n; ++i) { tester.out() << i << " " << aa.read(i) << " " << bb.read(i) << " " << cc.read(i) << " " << dd.read(i) << std::endl; } tester.out() << "aa: " << compressed(aa) << std::endl; tester.out() << "bb: " << compressed(bb) << std::endl; tester.out() << "cc: " << compressed(cc) << std::endl; tester.out() << "dd: " << compressed(dd) << std::endl; tester.check(!aa.engine().compressed()); tester.check(bb.engine().compressed()); tester.check(cc.engine().compressed()); tester.check(dd.engine().compressed()); a = b+dd*cc; Pooma::blockAndEvaluate(); tester.out() << "a: "; for (i=0; i<n; ++i) { tester.out() << "(" << i << ")=" << a.read(i) << ","; } tester.out() << std::endl; tester.out() << "------------------------------------------------" << std::endl; int retval = tester.results("compressibleTest1"); Pooma::finalize(); return return_status; }
int main(int argc, char *argv[]) { Pooma::initialize(argc, argv); Pooma::Tester tester(argc, argv); Interval<1> n1(1,5); Interval<1> n2(4,8); Interval<1> n3(10,20); Interval<2> a(n1,n2); Interval<3> b(n1,n2,n3); Range<1> r1(1,5); Range<1> r2(4,8,2); Range<1> r3(5,9,2); Range<1> r4(10,20,5); Range<2> ra(r1,r2); Range<2> rb(r1,r3); Range<3> rc(r1,r2,r3); tester.out() << "1: touches(" << a[0] << "," << a[1] << ") ? "; tester.out() << touches(a[0], a[1]) << std::endl; tester.check( touches(a[0], a[1]) ); tester.out() << "0: touches(" << a[0] << "," << b[2] << ") ? "; tester.out() << touches(a[0], b[2]) << std::endl; tester.check( touches(a[0], b[2])==0); tester.out() << "1: touches(" << a[0] << "," << ra[0] << ") ? "; tester.out() << touches(a[0], ra[0]) << std::endl; tester.check(touches(a[0], ra[0])); tester.out() << "1: touches(" << ra[0] << "," << ra[1] << ") ? "; tester.out() << touches(ra[0], ra[1]) << std::endl; tester.check( touches(ra[0], ra[1])); tester.out() << "0: touches(" << r2 << "," << r3 << ") ? "; tester.out() << touches(r2, r3) << std::endl; tester.check( touches(r2, r3)==0); tester.out() << "0: touches(" << ra << "," << rb << ") ? "; tester.out() << touches(ra, rb) << std::endl; tester.check( touches(ra, rb) ==0); tester.out() << "1: touches(" << rc << "," << rc << ") ? "; tester.out() << touches(rc, rc) << std::endl; tester.check( touches(rc, rc) ); tester.out() << "------------------------------------" << std::endl; tester.check(" touches ", true); Interval<1> c1(1,10); Interval<1> c2(3,8); Interval<1> c3(5,15); Interval<2> ca(c1, c1); Interval<2> cb(c1, c2); Range<1> cr1(2,20,2); Range<1> cr2(4,16,4); Range<1> cr3(3,15,2); Range<1> cr4(5,15,5); tester.out() << "1: contains(" << c1 << "," << c2 << ") ? "; tester.out() << contains(c1,c2) << std::endl; tester.check(contains(c1,c2)); tester.out() << "0: contains(" << c2 << "," << c1 << ") ? "; tester.out() << contains(c2,c1) << std::endl; tester.check(contains(c2,c1)==0); tester.out() << "0: contains(" << c1 << "," << c3 << ") ? "; tester.out() << contains(c1,c3) << std::endl; tester.check(contains(c1,c3)==0); tester.out() << "1: contains(" << ca << "," << cb << ") ? "; tester.out() << contains(ca,cb) << std::endl; tester.check(contains(ca,cb)); tester.out() << "0: contains(" << cb << "," << ca << ") ? "; tester.out() << contains(cb,ca) << std::endl; tester.check(contains(cb,ca)==0); tester.out() << "1: contains(" << cr1 << "," << cr2 << ") ? "; tester.out() << contains(cr1,cr2) << std::endl; tester.check( contains(cr1,cr2)); tester.out() << "0: contains(" << cr1 << "," << cr3 << ") ? "; tester.out() << contains(cr1,cr3) << std::endl; tester.check(contains(cr1,cr3)==0); tester.out() << "1: contains(" << c3 << "," << cr4 << ") ? "; tester.out() << contains(c3,cr4) << std::endl; tester.check(contains(c3,cr4)); tester.out() << "0: contains(" << cr4 << "," << c3 << ") ? "; tester.out() << contains(cr4,c3) << std::endl; tester.check(contains(cr4,c3)==0); tester.out() << "------------------------------------" << std::endl; Interval<2> s1, s2; Range<2> sr1, sr2; split(cb, s1, s2); tester.out() << "split(" << cb << ") = " << s1 << " and " << s2 << std::endl; tester.check(s1==Interval<2>(Interval<1>(1,5),Interval<1>(3,5))); tester.check(s2==Interval<2>(Interval<1>(6,10),Interval<1>(6,8))); split(rb, sr1, sr2); tester.out() << "split(" << rb << ") = " << sr1 << " and " << sr2 << std::endl; tester.check(sr1==Range<2>(Range<1>(1,2),Range<1>(5,5,2))); tester.check(sr2==Range<2>(Range<1>(3,5),Range<1>(7,9,2))); tester.out() << "------------------------------------" << std::endl; tester.out() << "intersect(" << cb << "," << ca << ") = "; tester.out() << intersect(cb,ca) << std::endl; tester.check(intersect(cb,ca)==Interval<2>(Interval<1>(1,10), Interval<1>(3,8))); tester.out() << "intersect(" << rb << "," << ra << ") = "; tester.out() << intersect(rb,ra) << std::endl; Range<1> i1(1,16,3); Range<1> i2(17,3,-2); tester.out() << "intersect(" << i1 << "," << i2 << ") = "; tester.out() << intersect(i1,i2) << std::endl; tester.check( intersect(i1,i2) == Range<1>(7,14,6)); tester.out() << "intersect(" << i2 << "," << i1 << ") = "; tester.out() << intersect(i2,i1) << std::endl; tester.check( intersect(i2,i1) == Range<1>(13,7,-6)); tester.out() << "------------------------------------" << std::endl; Interval<1> eq1(1,5); Range<1> eq2 = -2 * eq1 + 3; Range<1> eq3(-8,8,4); Range<1> eq4 = 3 * eq1; Range<1> eq5 = 2 * eq1; Range<1> eq6 = 6 * eq1 + 1; tester.out() << "For " << eq1 << " --> " << eq4 << ", then " << eq3 << " --> "; tester.out() << equivSubset(eq1,eq4,eq3) << std::endl; tester.out() << "For " << eq4 << " --> " << eq6 << ", then " << eq3 << " --> "; tester.out() << equivSubset(eq4,eq6,eq3) << std::endl; tester.out() << "For " << eq1 << " --> " << eq2 << ", then " << eq3 << " --> "; tester.out() << equivSubset(eq1,eq2,eq3) << std::endl; tester.out() << "------------------------------------" << std::endl; NewDomain3<Interval<1>, Interval<1>, int>::SliceType_t ba; // tester.out() << "Created initial slice domain ba = " << ba << std::endl; ba = NewDomain3<Interval<1>, Interval<1>, int>::combineSlice(ba,eq1,eq1,7); tester.out() << "After taking slice, ba = " << ba << std::endl; int retval = tester.results("Domain Calc"); Pooma::finalize(); return retval; }