void ArpConfigureView::Draw(BRect ) { BeginLineArray(6); const rgb_color bgcolor = ViewColor(); if( mMakeDefaultButton ) { BRect revFrame(mMakeDefaultButton->Frame()); const float left = revFrame.right + floor((mSpaceWidth*3)/2); AddLine( BPoint(left, revFrame.top), BPoint(left, revFrame.bottom), tint_color(bgcolor, B_DARKEN_4_TINT) ); AddLine( BPoint(left+1, revFrame.top), BPoint(left+1, revFrame.bottom), tint_color(bgcolor, .2) ); } BRect bnd(Bounds()); BRect panFrame(mPanel->Frame()); AddLine( BPoint(bnd.left, bnd.bottom), BPoint(bnd.left, panFrame.bottom+1), tint_color(bgcolor, .2) ); AddLine( BPoint(bnd.left, panFrame.bottom+1), BPoint(bnd.right, panFrame.bottom+1), tint_color(bgcolor, .2) ); AddLine( BPoint(bnd.right, panFrame.bottom+1), BPoint(bnd.right, bnd.bottom), tint_color(bgcolor, B_DARKEN_4_TINT) ); AddLine( BPoint(bnd.right, bnd.bottom), BPoint(bnd.left, bnd.bottom), tint_color(bgcolor, B_DARKEN_4_TINT) ); EndLineArray(); }
/* ** main */ int main (int argc, char **argv) { STRING Name; double start; double stop; init_lumineur (argc, argv); strcpy (Name, NameScn); strcat (Name, ".scn"); start = getTime(); read_scn (Name); stop = getTime(); printf ("Temps de lecture : %e seconde(s)\n", stop - start); start = getTime(); bnd (); stop = getTime(); printf ("Temps du binder : %e seconde(s)\n", stop - start); start = getTime(); scn (); stop = getTime(); printf ("Temps de la scene : %e seconde(s)\n", stop - start); start = getTime(); img (NameScn); stop = getTime(); printf ("Temps de l'image : %e seconde(s)\n", stop - start); exit (0); }
void fast_construct_mapping::construct_initial_mapping_bottomup_internal( PartitionConfig & config, graph_access & C, matrix & D, int idx, std::vector< NodeID > & perm_rank) { PartitionID num_parts = C.number_of_nodes()/config.group_sizes[idx]; partition_C_perfectly_balanced( config, C, num_parts); if( idx ==(int)(config.group_sizes.size() - 1) ) { // build initial offsets int nodes_per_block = m_tmp_num_nodes / config.group_sizes[idx]; perm_rank[0] = 0; for( unsigned int block = 1; block < perm_rank.size(); block++) { perm_rank[block] = perm_rank[block-1]+nodes_per_block; } } else { //contract partitioned graph graph_access Q; complete_boundary bnd(&C); bnd.build(); bnd.getUnderlyingQuotientGraph(Q); std::vector< NodeID > rec_ranks( num_parts, 0); construct_initial_mapping_bottomup_internal( config, Q, D, idx+1, rec_ranks); //recompute offsets forall_nodes(C, node) { PartitionID block = C.getPartitionIndex(node); perm_rank[node] = rec_ranks[block]; rec_ranks[block] += C.getNodeWeight(node); } endfor }
//-***************************************************************************** void RenderIt() { const char *templ = "/var/tmp/SimpleAbcViewer_camera.XXXXXX"; char *buffer = new char[strlen( templ ) + 1]; strcpy( buffer, templ ); #ifndef PLATFORM_WINDOWS mkstemp( buffer ); #endif std::string cameraFileName = buffer; #ifdef PLATFORM_WINDOWS cameraFileName = "SimpleAbcViewer_camera.XXXXXX"; #endif float shutterOpenTime = -0.25f; // + ( float )g_transport->getCurrentFrame(); float shutterCloseTime = 0.25f; //+ ( float )g_transport->getCurrentFrame(); float openTime = -0.5f + ( float )g_transport->getCurrentFrame(); float closeTime = 1.0f + openTime; std::ofstream camFile( cameraFileName.c_str() ); camFile << g_state.scene.cam.RIB(); camFile.close(); Box3d bnd( g_transport->getBounds() ); std::string boundStr; if ( ! bnd.isEmpty() ) { std::ostringstream boundStream; boundStream << "[" << bnd.min[0] << " " << bnd.max[0] << " " << bnd.min[1] << " " << bnd.max[1] << " " << bnd.min[2] << " " << bnd.max[2] << "]"; boundStr = boundStream.str(); } else { boundStr = ""; } std::ostringstream cmdStream; cmdStream << " --shutteropen=" << shutterOpenTime << " --shutterclose=" << shutterCloseTime << " -C " << cameraFileName << " -P " << g_state.AlembicRiPluginDsoPath << " -a " << g_state.abcFileName << " --sample1=" << openTime << " --sample2=" << closeTime << " -B \"%s\"" << boundStr; std::string cmdArgs = cmdStream.str(); std::string cmd = g_state.RenderScript; cmd += " "; cmd += cmdArgs; system( cmd.c_str() ); delete[] buffer; }
inline binding_string::binding_string(handles* hnd, size_t order, const std::string& str, ub1 cs_form) : m_str(brig::unicode::transform<char16_t>(str)) { const size_t size((m_str.size() + 1) * sizeof(char16_t)); if (size > SHRT_MAX) throw std::runtime_error("OCI type error"); m_ind = OCIInd(size); OCIBind* bnd(0); hnd->check(lib::singleton().p_OCIBindByPos(hnd->stmt, &bnd, hnd->err, ub4(order), (void*)m_str.c_str(), m_ind, SQLT_STR, &m_ind, 0, 0, 0, 0, OCI_DEFAULT)); hnd->check(lib::singleton().p_OCIAttrSet(bnd, OCI_HTYPE_BIND, (void*)&cs_form, 0, OCI_ATTR_CHARSET_FORM, hnd->err)); } // binding_string::
/* ** main */ int main (int argc, char **argv) { STRING Name; struct timeval start; struct timeval stop; int my_rank; MPI_Init(&argc,&argv); MPI_Comm_rank(MPI_COMM_WORLD,&my_rank); init_lumineur (argc, argv); strcpy (Name, NameScn); strcat (Name, ".scn"); portable_gettimeofday(&start); read_scn (Name); portable_gettimeofday(&stop); if(my_rank==0){ printf ("Temps de lecture : %ld seconde(s)\n", stop.tv_sec - start.tv_sec); } portable_gettimeofday(&start); bnd (); portable_gettimeofday(&stop); if(my_rank==0){ printf ("Temps du binder : %ld seconde(s)\n", stop.tv_sec - start.tv_sec); } portable_gettimeofday(&start); scn (); portable_gettimeofday(&stop); if(my_rank==0){ printf ("Temps de la scene : %ld seconde(s)\n", stop.tv_sec - start.tv_sec); } portable_gettimeofday(&start); img (NameScn); portable_gettimeofday(&stop); printf ("Temps de l'image : %ld seconde(s)\n", stop.tv_sec - start.tv_sec); MPI_Finalize(); exit (0); }
void MonadicLawsProofing() { //Scala notation: unit(x) flatMap f == f(x) { //Left Identity (1st Law) auto x = just(read_att48_tsp()); auto f = [](TSP::T t){ return ref(t).do_cycle_length(); }; double fun_result = bnd<double>(ret(x), f); //functional composition double oo_result = ret(x).map<double>(f); //object-oriented bool fun_holds = fun_result == f(x); bool oo_holds = oo_result == f(x); std::cout << "1st Law (Left Identity) " << (fun_holds ? "holds" : "doesn't hold") << std::endl; std::cout << "1st Law (Left Identity) " << (oo_holds ? "holds" : "doesn't hold") << std::endl; } //Scala notation: m flatMap unit == m { //Right Identity (2nd Law) auto m = make_TSP(read_att48_tsp()); auto fun_result = bnd(m, ret); auto oo_result = m.map(ret); bool fun_holds = fun_result == m; bool oo_holds = oo_result == m; std::cout << "2nd Law (Right Identity) " << (fun_holds ? "holds" : "doesn't hold") << std::endl; std::cout << "2nd Law (Right Identity) " << (oo_holds ? "holds" : "doesn't hold") << std::endl; } //Scala notation: m flatMap f flatMap g == m flatMap (x => f(x) flatMap g) { //Associativity (3rd Law) auto m = make_TSP(read_att48_tsp()); auto f = [](TSP::T t) -> TSP { auto u = ref(t); std::swap(u.cities[0], u.cities[1]); return make_TSP(u); }; auto g = [](TSP::T t) -> TSP { auto u = ref(t); std::swap(u.cities[2], u.cities[3]); return make_TSP(u); }; auto fun_result_1 = bnd(bnd(m, f), g); auto fun_result_2 = bnd(m, [&](TSP::T t) { return bnd(f(t), g); }); auto oo_result_1 = m.map(f).map(g); auto oo_result_2 = m.map([&](TSP::T t) { return f(t).map(g); }); bool fun_holds = fun_result_1 == fun_result_2; bool oo_holds = oo_result_1 == oo_result_2; std::cout << "3rd Law (Associativity) " << (fun_holds ? "holds" : "doesn't hold") << std::endl; std::cout << "3rd Law (Associativity) " << (oo_holds ? "holds" : "doesn't hold") << std::endl; } }
void binding_impl<T, TargetType>::bind(handles* hnd, size_t order) { OCIBind* bnd(0); hnd->check(lib::singleton().p_OCIBindByPos(hnd->stmt, &bnd, hnd->err, ub4(order), &m_val, sizeof(m_val), TargetType, &m_ind, 0, 0, 0, 0, OCI_DEFAULT)); } // binding_impl::
inline binding_blob::binding_blob(handles* hnd, size_t order, void* data, ub4 len) : m_data(data), m_len(len), m_ind(len > 0? OCI_IND_NOTNULL: OCI_IND_NULL) { OCIBind* bnd(0); hnd->check(lib::singleton().p_OCIBindByPos(hnd->stmt, &bnd, hnd->err, ub4(order), 0, INT_MAX, SQLT_LBI, 0, 0, 0, 0, 0, OCI_DATA_AT_EXEC)); hnd->check(lib::singleton().p_OCIBindDynamic(bnd, hnd->err, this, callback, 0, 0)); }