void blur2D::init() { if (image==(imagebuffer *)NULL) debug_error(miawin, "blur2D: init() error: imagebuffer not assigned"); xtab=new int[image->width]; ytab=new int[image->height]; if ((xc==0) && (yc==0) && (zoom==0)) set_parameters(image->width/2.0f, image->height/2.0f, 0.005f); else set_parameters(xc, yc, zoom); }
void RBParametrized::initialize_parameters(const RBParameters& mu_min_in, const RBParameters& mu_max_in, const RBParameters& mu_in) { // Check that the min/max vectors are valid { const std::string err_string = "Error: Invalid mu_min/mu_max in RBParameters constructor."; bool valid_min_max = (mu_min_in.n_parameters() == mu_max_in.n_parameters()); if(!valid_min_max) { libMesh::err << err_string << std::endl; } else { RBParameters::const_iterator it = mu_min_in.begin(); RBParameters::const_iterator it_end = mu_min_in.end(); for( ; it != it_end; ++it) { std::string param_name = it->first; if(mu_min_in.get_value(param_name) > mu_max_in.get_value(param_name)) { libMesh::err << err_string << std::endl; } } } } parameters_min = mu_min_in; parameters_max = mu_max_in; parameters_initialized = true; set_parameters(mu_in); }
int main(int argc, char * argv[]) { srand_file(); Parameters p; if(set_parameters(argc, argv, p)==false) { if (argc>1) cerr<<"Please, look at ReadMe.txt..."<<endl; return -1; } erase_file_if_exists("network.dat"); erase_file_if_exists("community.dat"); erase_file_if_exists("statistics.dat"); benchmark(p.excess, p.defect, p.num_nodes, p.average_k, p.max_degree, p.tau, p.tau2, p.mixing_parameter, p.overlapping_nodes, p.overlap_membership, p.nmin, p.nmax, p.fixed_range); return 0; }
bool One_Class_SVM::load_model( const char * file_name ){ struct svm_model * temp_model = svm_load_model( file_name ); // If load_model fails, this temp_model will be a null pointer. // If it succeeds and the resulting model's svm_type is not ONE_CLASS, // it can't be used as a model for one_class_svm (for obvious reasons) // and we should consider it a failure. if ( temp_model == NULL ) { return false; } else if ( temp_model->param.svm_type != ONE_CLASS ) { // Memory was allocated as a result of the successful load_model function, // but the svm type is incompatible. The pointer must be freed before // the function returns false. free ( temp_model ); return false; } // If the method hasn't returned false yet, temp_model is both non-NULL and // has svm_type ONE_CLASS. Set _model to temp_model, set trained to true, // and return trained. _model = temp_model; trained = true; _training_samples = _model->l; set_parameters( &(_model->param) ); return trained; }
Hp::Hp(FILE * resultsFile, FILE * reporter, vector<Soup *> A, vector<Soup *> B):Method(reporter) { /*** write out to out file **/ writeDescription(reporter); set_parameters(); if(A.size() != B.size()) { cout << "WARNING: An equal amount of protein and ligand structures must be given to the HP function!\n"; return; } float result; for(unsigned int i=0; i<A.size(); i++) { result = calculate(A[i],B[i]); string decoy_number; if(B[i]->name.find_last_of("_")== string::npos) decoy_number = "-1"; else decoy_number = B[i]->name.substr(B[i]->name.find_last_of("_")+1); fprintf(resultsFile,"%-4s %-4s %8f\n", A[i]->name.substr(0,4).c_str(), decoy_number.c_str(), result); } }
/* * Measure RDS bandwidth (client side). */ void run_client_rds_bw(void) { char *buf; int sockfd; par_use(L_ACCESS_RECV); par_use(R_ACCESS_RECV); set_parameters(8*1024); client_send_request(); sockfd = init(); buf = qmalloc(Req.msg_size); sync_test(); while (!Finished) { int n = sendto(sockfd, buf, Req.msg_size, 0, (SA *)&RAddr, RLen); if (Finished) break; if (n != Req.msg_size) { LStat.s.no_errs++; continue; } LStat.s.no_bytes += n; LStat.s.no_msgs++; } stop_test_timer(); exchange_results(); free(buf); close(sockfd); show_results(BANDWIDTH); }
Rectangle8::Rectangle8(MatrixXd x) { coord = x; set_parameters(); }
void RBConstructionBase<Base>::broadcast_parameters(unsigned int proc_id) { libmesh_assert_less (proc_id, this->n_processors()); // create a copy of the current parameters RBParameters current_parameters = get_parameters(); // copy current_parameters to current_parameters_vector in order to broadcast std::vector<Real> current_parameters_vector; RBParameters::const_iterator it = current_parameters.begin(); RBParameters::const_iterator it_end = current_parameters.end(); for( ; it != it_end; ++it) { current_parameters_vector.push_back(it->second); } // do the broadcast this->comm().broadcast(current_parameters_vector, proc_id); // update the copy of the RBParameters object it = current_parameters.begin(); unsigned int count = 0; for( ; it != it_end; ++it) { std::string param_name = it->first; current_parameters.set_value(param_name, current_parameters_vector[count]); count++; } // set the parameters globally set_parameters(current_parameters); }
void GLSL_Program::initialize() { program = glCreateProgram(); attach_shaders(); glLinkProgram(program); set_parameters(); if(glGetError() != GL_NO_ERROR) throw "OpenGL after initializing shader"; }
int main(int argc, char* argv[]) { ConfigXML cfg = set_parameters("SingleSampleCCE.xml"); string log_file = LOG_PATH + cfg.getStringParameter("Data", "log_file"); _START_EASYLOGGINGPP(argc, argv); easyloggingpp::Configurations confFromFile(log_file.c_str()); easyloggingpp::Loggers::reconfigureAllLoggers(confFromFile); int worker_num(0), my_rank(0); int mpi_status = MPI_Init(&argc, &argv); assert (mpi_status == MPI_SUCCESS); MPI_Comm_size(MPI_COMM_WORLD, &worker_num); MPI_Comm_rank(MPI_COMM_WORLD, &my_rank); LOG(INFO) << "my_rank = " << my_rank << " vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv Program begins vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"; // create defect center NVCenter nv = create_defect_center(cfg); // CCE SingleSampleCCE sol(my_rank, worker_num, &nv, cfg); sol.run(); LOG(INFO) << "my_rank = " << my_rank << " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Program ends ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"; mpi_status = MPI_Finalize(); assert (mpi_status == MPI_SUCCESS); }
int main(int argc, char ** argv) { rclcpp::init(argc, argv); auto node = rclcpp::Node::make_shared("set_and_get_parameters"); // TODO(wjwwood): Make the parameter service automatically start with the node. auto parameter_service = std::make_shared<rclcpp::parameter_service::ParameterService>(node); auto parameters_client = std::make_shared<rclcpp::parameter_client::SyncParametersClient>(node); // Set several different types of parameters. auto set_parameters_results = parameters_client->set_parameters({ rclcpp::parameter::ParameterVariant("foo", 2), rclcpp::parameter::ParameterVariant("bar", "hello"), rclcpp::parameter::ParameterVariant("baz", 1.45), rclcpp::parameter::ParameterVariant("foobar", true), }); // Check to see if they were set. for (auto & result : set_parameters_results) { if (!result.successful) { std::cerr << "Failed to set parameter: " << result.reason << std::endl; } } // Get a few of the parameters just set. for (auto & parameter : parameters_client->get_parameters({"foo", "baz"})) { std::cout << "Parameter name: " << parameter.get_name() << std::endl; std::cout << "Parameter value (" << parameter.get_type_name() << "): " << parameter.value_to_string() << std::endl; } return 0; }
void PrepinReader::do_water(Water * w) { read_prep("opls_uni.in"); compare(w->getAtoms()); read_parm("parm94.dat"); set_parameters(w->getAtoms()); }
void MultinomialDensities::estimate(vector<MDArray<double> > & ess) { assert(!ess.empty()); MDArray<double> e = ess[0]; e.add_inplace(pseudo_count); set_parameters(e); }
Packet_Generator::Packet_Generator(const int Packet_size, const unsigned long int Max_packets) { keep_running = false; start.forward(this, &Packet_Generator::handle_start); next.forward(this, &Packet_Generator::handle_next); output.connect(&next); set_parameters(Packet_size, Max_packets); }
Hp::Hp(FILE * reporter):Method(reporter) { /*** write out to out file **/ writeDescription(reporter); set_parameters(); }
SANE_Status sane_control_option (SANE_Handle h, SANE_Int opt, SANE_Action act, void *val, SANE_Word * info) { struct device *dev = h; DBG (3, "%s: %p, %d, <%d>, %p, %p\n", __FUNCTION__, h, opt, act, val, (void *)info); if (!dev || opt >= NUM_OPTIONS || opt < 0) return SANE_STATUS_INVAL; if (info) *info = 0; if (act == SANE_ACTION_GET_VALUE) { /* GET */ if (dev->opt[opt].type == SANE_TYPE_STRING) strcpy(val, dev->val[opt].s); else *(SANE_Word *)val = dev->val[opt].w; } else if (act == SANE_ACTION_SET_VALUE) { /* SET */ SANE_Parameters xpara = dev->para; SANE_Option_Descriptor xopt[NUM_OPTIONS]; Option_Value xval[NUM_OPTIONS]; int i; if (dev->opt[opt].constraint_type == SANE_CONSTRAINT_STRING_LIST) { dev->val[opt].s = string_match(dev->opt[opt].constraint.string_list, val); if (info && strcasecmp(dev->val[opt].s, val)) *info |= SANE_INFO_INEXACT; } else if (opt == OPT_RESOLUTION) dev->val[opt].w = res_dpi_codes[dpi_to_code(*(SANE_Word *)val)]; else dev->val[opt].w = *(SANE_Word *)val; memcpy(&xopt, &dev->opt, sizeof(xopt)); memcpy(&xval, &dev->val, sizeof(xval)); fix_window(dev); set_parameters(dev); /* check for side effects */ if (info) { if (memcmp(&xpara, &dev->para, sizeof(xpara))) *info |= SANE_INFO_RELOAD_PARAMS; if (memcmp(&xopt, &dev->opt, sizeof(xopt))) *info |= SANE_INFO_RELOAD_OPTIONS; for (i = 0; i < NUM_OPTIONS; i++) if (xval[i].w != dev->val[i].w) { if (i == opt) *info |= SANE_INFO_INEXACT; else *info |= SANE_INFO_RELOAD_OPTIONS; } } } DBG (4, "%s: %d, <%d> => %08x, %x\n", __FUNCTION__, opt, act, val? *(SANE_Word *)val : 0, info? *info : 0); return SANE_STATUS_GOOD; }
NN_VDW::NN_VDW(FILE * reporter):Nnmodel() { /*** write out to out file **/ writeDescription(reporter); printf("Using the NN_VDW network!\n"); set_parameters(); }
void Module::set ( Log_Entry &e ) { for ( int i = 0; i < e.size(); ++i ) { const char *s, *v; e.get( i, &s, &v ); if ( ! strcmp( s, ":chain" ) ) { /* This trickiness is because we may need to know the name of our chain before we actually get added to it. */ int i; sscanf( v, "%X", &i ); Chain *t = (Chain*)Loggable::find( i ); assert( t ); chain( t ); } } for ( int i = 0; i < e.size(); ++i ) { const char *s, *v; e.get( i, &s, &v ); /* if ( ! strcmp( s, ":name" ) ) */ /* label( v ); */ if ( ! strcmp( s, ":parameter_values" ) ) { set_parameters( v ); } else if ( ! ( strcmp( s, ":is_default" ) ) ) { is_default( atoi( v ) ); } else if ( ! ( strcmp( s, ":active" ) ) ) { bypass( ! atoi( v ) ); } else if ( ! strcmp( s, ":chain" ) ) { int i; sscanf( v, "%X", &i ); Chain *t = (Chain*)Loggable::find( i ); assert( t ); t->add( this ); } } }
int main(int argc, char * argv[]) { srand_file(); Parameters p; if(set_parameters(argc, argv, p)==false) { if (argc>1) cerr<<"Please, look at ReadMe.txt..."<<endl; return -1; } erase_file_if_exists("network.dat"); erase_file_if_exists("community.dat"); erase_file_if_exists("statistics.dat"); int sy0= system("rm network_*"); sy0= system("rm community_*"); sy0= system("rm network_layer_*"); int num_of_original_graphs=p.num_of_original_graphs; int num_of_layers=p.num_of_layers; int layer_index=0; cout<<"No. of original graphs: "<<num_of_original_graphs<<" No. of layers per graph: "<<num_of_layers<<endl; int max_assignment=0; ofstream comout("level_node_cluster.clu"); ofstream multiplexout("level_node_node_weight.edges"); multiplexout<<"*Intra"<<endl; for(int ori=0; ori<num_of_original_graphs; ori++) { // generating and printing graph benchmark(p.excess, p.defect, p.num_nodes, p.average_k, p.max_degree, p.tau, p.tau2, \ p.mixing_parameter, p.overlapping_nodes, p.overlap_membership, \ p.nmin, p.nmax, p.fixed_range, p.clustering_coeff); char buffer[1000]; sprintf(buffer, "mv network.dat network_%d", ori); int sy=system(buffer); sprintf(buffer, "mv community.dat community_%d", ori); sy=system(buffer); system("rm statistics.dat"); // creating layers max_assignment= create_layers(layer_index, num_of_layers, ori, comout, max_assignment, multiplexout); } comout.close(); multiplexout.close(); return 0; }
TexturePtr TextureFactory::create(const TextureFormat &format, const std::vector<TextureData> &data) { auto texture = std::make_shared<Texture>(format.get_type()); texture->bind(); if (texture->get_type() == GL_TEXTURE_2D) { if (data.size() != 1) { throw clan::Exception(clan::string_format("A 2d texture requires 1 image, (%1) were provided", data.size())); } make_immutable_storage(GL_TEXTURE_2D, format.is_generating_mipmap(), data[0].internal_format, data[0].width, data[0].height); upload_single_image(GL_TEXTURE_2D, data[0]); } else if (texture->get_type() == GL_TEXTURE_CUBE_MAP) { if (data.size() != 6) { throw clan::Exception(clan::string_format("A cube texture requires 6 images, (%1) were provided", data.size())); } bool satisfied_image_sizes = std::all_of(++data.begin(), data.end(), [&data](const TextureData &img) { return (data[0].width == img.width) && (data[0].height == img.height); }); if (!satisfied_image_sizes) { throw clan::Exception("The six textures of a cube must the same dimensions!"); } make_immutable_storage(GL_TEXTURE_CUBE_MAP, format.is_generating_mipmap(), data[0].internal_format, data[0].width, data[0].height); glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); for (unsigned int i = 0; i < data.size(); i++) { upload_single_image(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, data[i]); } } set_parameters(texture, format); if (format.is_generating_mipmap()) { glGenerateMipmap(format.get_type()); } texture->unbind(); return texture; }
void PrepinReader::do_molecule(Molecule * m, string soup_name) { string guess = soup_name+"and-bcc.prepi"; printf("Guessing that the name of the prepin file is: %s\n",guess.c_str()); read_prep(guess); compare(m->getAtoms()); read_parm("gaff.dat"); set_parameters(m->getAtoms()); }
void CCE::run() { set_parameters(); prepare_center_spin(); create_bath_spins(); prepare_bath_state(); create_spin_clusters(); run_each_clusters(); post_treatment(); }
Complementarity::Complementarity(FILE * resultsFile, FILE * reporter, vector<Soup*> A, vector<Soup*> B):Method(reporter) { set_parameters(); double result =0; bool include = true; /*** write out to out file **/ writeDescription(reporter); Distances calc(reporter); for(unsigned int i=0; i< A.size(); i++ ) { calc.calculate(A[i], B[i], false); vector<vector<float> > d =calc.getResult(); vector<Atom *> Aatoms = A[i]->getAtoms(); vector<Atom *> Batoms = B[i]->getAtoms(); for(unsigned int x=0; x<d.size(); x++) for(unsigned int y=0; y<d[0].size(); y++) { include = true; if(ignore_h == 1 && Aatoms[x]->element =="H") include = false; if(ignore_h == 1 && Batoms[y]->element =="H") include = false; // cout<<"A:"<<Aatoms[x]->element<<" B:"<<Batoms[y]->element<<" Dist:"<<sqrt(d[x][y]); if(d[x][y] < tsq && include) { result += complEnergy; // cout<<" INCLUDED"; } // cout<<endl; } string decoy_number; if(B[i]->name.find_last_of("_")== string::npos) decoy_number = "-1"; else decoy_number = B[i]->name.substr(B[i]->name.find_last_of("_")+1); fprintf(resultsFile,"%-4s %-4s %8f\n", A[i]->name.substr(0,4).c_str(), decoy_number.c_str(), result); } // fprintf(reporter,"The result is: %f kcal/mol\n", result); // fprintf(resultsFile,"%-10s %5.3f\n",A[0]->identify().substr(0,4).c_str(),result); }
ProteinEntropy::ProteinEntropy(FILE * reporter):Method(reporter) { /*** set parameters ***/ set_parameters(); /*** write out to out file **/ writeDescription(reporter); }
static int reset(NiggliParams *p) { double *lat_tmp; lat_tmp = NULL; if ((lat_tmp = multiply_matrices(p->lattice, p->tmat)) == NULL) {return 0;} memcpy(p->lattice, lat_tmp, sizeof(double) * 9); free(lat_tmp); lat_tmp = NULL; return set_parameters(p); }
int main(int argc, char ** argv) { rclcpp::init(argc, argv); auto node = rclcpp::Node::make_shared("set_and_get_parameters_async"); // TODO(wjwwood): Make the parameter service automatically start with the node. auto parameter_service = std::make_shared<rclcpp::parameter_service::ParameterService>(node); auto parameters_client = std::make_shared<rclcpp::parameter_client::AsyncParametersClient>(node); // Set several different types of parameters. auto results = parameters_client->set_parameters({ rclcpp::parameter::ParameterVariant("foo", 2), rclcpp::parameter::ParameterVariant("bar", "hello"), rclcpp::parameter::ParameterVariant("baz", 1.45), rclcpp::parameter::ParameterVariant("foobar", true), }); // Wait for the results. if (rclcpp::spin_until_future_complete(node, results) != rclcpp::executor::FutureReturnCode::SUCCESS) { printf("set_parameters service call failed. Exiting tutorial.\n"); return -1; } // Check to see if they were set. for (auto & result : results.get()) { if (!result.successful) { std::cerr << "Failed to set parameter: " << result.reason << std::endl; } } // Get a few of the parameters just set. auto parameters = parameters_client->get_parameters({"foo", "baz"}); if (rclcpp::spin_until_future_complete(node, parameters) != rclcpp::executor::FutureReturnCode::SUCCESS) { printf("get_parameters service call failed. Exiting tutorial.\n"); return -1; } for (auto & parameter : parameters.get()) { std::cout << "Parameter name: " << parameter.get_name() << std::endl; std::cout << "Parameter value (" << parameter.get_type_name() << "): " << parameter.value_to_string() << std::endl; } return 0; }
TexturePtr TextureFactory::create(const TextureFormat &format) { auto texture = std::make_shared<Texture>(format.get_type()); texture->bind(); set_parameters(texture, format); if (format.is_generating_mipmap()) { glGenerateMipmap(format.get_type()); } texture->unbind(); return texture; }
TEST_F(OperatorsProjectionTest, SetParameters) { const auto table_scan_a = create_table_scan(table_wrapper_b, ColumnID{1}, PredicateCondition::GreaterThan, 5); const auto projection_a = std::make_shared<Projection>(table_scan_a, expression_vector(b_a)); const auto subquery_expression = std::make_shared<PQPSubqueryExpression>(table_scan_a, DataType::Int, false, PQPSubqueryExpression::Parameters{}); const auto projection_b = std::make_shared<Projection>( table_wrapper_a, expression_vector(correlated_parameter_(ParameterID{2}, a_a), subquery_expression)); const auto parameters = std::unordered_map<ParameterID, AllTypeVariant>{{ParameterID{5}, AllTypeVariant{12}}, {ParameterID{2}, AllTypeVariant{13}}}; projection_b->set_parameters(parameters); const auto correlated_parameter_expression = std::dynamic_pointer_cast<CorrelatedParameterExpression>(projection_b->expressions.at(0)); ASSERT_TRUE(correlated_parameter_expression); EXPECT_TRUE(correlated_parameter_expression->value()); EXPECT_EQ(*correlated_parameter_expression->value(), AllTypeVariant{13}); }
void SPHSystem::animation() { if(sys_running != 1) { return; } set_parameters(hParam); calc_hash(dHash, dIndex,dMem, hParam->num_particle); sort_particles(dHash, dIndex, hParam->num_particle); find_start_end(dStart, dEnd, dHash, dIndex, hParam->num_particle, hParam->tot_cell); integrate_velocity(dMem, hParam->num_particle); compute(dMem, dHash, dIndex, dStart, dEnd, hParam->num_particle, hParam->tot_cell); copy_buffer(dMem, dPoints, hParam->num_particle); copy_array(hPoints, dPoints, sizeof(float2)*hParam->num_particle, CUDA_DEV_TO_HOST); copy_array(hMem, dMem, sizeof(Particle)*hParam->num_particle, CUDA_DEV_TO_HOST); }
Hp::Hp(FILE * resultsFile, FILE * reporter, vector<Soup *> A):Method(reporter) { /*** write out to out file **/ writeDescription(reporter); set_parameters(); float result; for(unsigned int i=0; i<A.size(); i++) { result = calculate(A[i]); fprintf(resultsFile,"%-4s %8f\n", A[i]->name.substr(0,4).c_str(), result); } }