Example #1
0
void Display::open(const Project& project)
{
    string plugin;

    try
    {
        plugin = get_parameters().get("plugin_name");
        // Add platform dependent extension.
#ifdef _WIN32
        plugin += ".dll";
#else
        plugin += ".so";
#endif

        plugin = project.search_paths().qualify(plugin);
    }
    catch (const ExceptionDictionaryItemNotFound&)
    {
        RENDERER_LOG_FATAL("%s", "cannot open display: bad parameters.");
        return;
    }

    try
    {
        impl = new Impl(plugin.c_str(), get_parameters());
    }
    catch (const ExceptionCannotLoadSharedLib& e)
    {
        RENDERER_LOG_FATAL("cannot open display: %s", e.what());
    }
    catch (const ExceptionSharedLibCannotGetSymbol& e)
    {
        RENDERER_LOG_FATAL("cannot open display: %s", e.what());
    }
}
Example #2
0
void RBSCMConstruction::print_info()
{
  // Print out info that describes the current setup
  libMesh::out << std::endl << "RBSCMConstruction parameters:" << std::endl;
  libMesh::out << "system name: " << this->name() << std::endl;
  libMesh::out << "SCM Greedy tolerance: " << get_SCM_training_tolerance() << std::endl;
  if(rb_scm_eval)
  {
    libMesh::out << "A_q operators attached: " << get_rb_theta_expansion().get_n_A_terms() << std::endl;
    libMesh::out << "Number of parameters: "   << get_n_params() << std::endl;
  }
  else
  {
    libMesh::out << "RBThetaExpansion member is not set yet" << std::endl;
  }
  RBParameters::const_iterator it     = get_parameters().begin();
  RBParameters::const_iterator it_end = get_parameters().end();
  for( ; it != it_end; ++it)
  {
    std::string param_name = it->first;
    libMesh::out <<   "Parameter " << param_name
                 << ": Min = " << get_parameter_min(param_name)
                 << ", Max = " << get_parameter_max(param_name)
                 << ", value = " << get_parameters().get_value(param_name) << std::endl;
  }
  libMesh::out << "n_training_samples: " << get_n_training_samples() << std::endl;
  libMesh::out << std::endl;
}
Example #3
0
void RBSCMConstruction::enrich_C_J(unsigned int new_C_J_index)
{
  START_LOG("enrich_C_J()", "RBSCMConstruction");

  set_params_from_training_set_and_broadcast(new_C_J_index);

  rb_scm_eval->C_J.push_back(get_parameters());

  libMesh::out << std::endl << "SCM: Added mu = (";

  RBParameters::const_iterator it     = get_parameters().begin();
  RBParameters::const_iterator it_end = get_parameters().end();
  for( ; it != it_end; ++it)
  {
    if(it != get_parameters().begin()) libMesh::out << ",";
    std::string param_name = it->first;
    RBParameters C_J_params = rb_scm_eval->C_J[rb_scm_eval->C_J.size()-1];
    libMesh::out << C_J_params.get_value(param_name);
  }
  libMesh::out << ")" << std::endl;

  // Finally, resize C_J_stability_vector and SCM_UB_vectors
  rb_scm_eval->C_J_stability_vector.push_back(0.);

  std::vector<Real> zero_vector(get_rb_theta_expansion().get_n_A_terms());
  rb_scm_eval->SCM_UB_vectors.push_back(zero_vector);

  STOP_LOG("enrich_C_J()", "RBSCMConstruction");
}
Example #4
0
static ssize_t codec_debug_write(struct file *filp,
                                 const char __user *ubuf, size_t cnt, loff_t *ppos)
{
    char *access_str = filp->private_data;
    char lbuf[32];
    int rc;
    long int param[5];

    if (cnt > sizeof(lbuf) - 1)
        return -EINVAL;

    rc = copy_from_user(lbuf, ubuf, cnt);
    if (rc)
        return -EFAULT;

    lbuf[cnt] = '\0';

    if (!strcmp(access_str, "power")) {
        if (get_parameters(lbuf, param, 1) == 0) {
            switch (param[0]) {
            case 1:
                adie_codec.codec_pdata->marimba_codec_power(1);
                marimba_codec_bring_up();
                break;
            case 0:
                marimba_codec_bring_down();
                adie_codec.codec_pdata->marimba_codec_power(0);
                break;
            default:
                rc = -EINVAL;
                break;
            }
        } else
            rc = -EINVAL;
    } else if (!strcmp(access_str, "poke")) {
        /* write */
        rc = get_parameters(lbuf, param, 2);
        if ((param[0] <= 0xFF) && (param[1] <= 0xFF) &&
                (rc == 0))
            adie_codec_write(param[0], 0xFF, param[1]);
        else
            rc = -EINVAL;
    } else if (!strcmp(access_str, "peek")) {
        /* read */
        rc = get_parameters(lbuf, param, 1);
        if ((param[0] <= 0xFF) && (rc == 0))
            adie_codec_read(param[0], &read_data);
        else
            rc = -EINVAL;
    }

    if (rc == 0)
        rc = cnt;
    else
        pr_err("%s: rc = %d\n", __func__, rc);

    return rc;
}
void create_engine::prepare_for_era_and_mods()
{
	state_.classification().era_define =
		resources::config_manager->game_config().find_child(
			"era", "id", get_parameters().mp_era)["define"].str();
	BOOST_FOREACH(const std::string& mod_id, get_parameters().active_mods) {
		state_.classification().mod_defines.push_back(
				resources::config_manager->game_config().find_child(
					"modification", "id", mod_id)["define"].str());
	}
}
Example #6
0
/* send conn's ip and port which used to connect to user server
 * to mesage server */
void send_conn_info_to_message(struct conn_server *server)
{
	struct list_packet *lp = allocator_malloc(&server->packet_allocator);
	packet_init(lp);
	set_length(lp, 18);
	set_command(lp, CMD_CONN_INFO);
	set_field_uint32_t(get_parameters(lp), 0, server->conn_user_ip);
	set_field_uint16_t(get_parameters(lp), 4, server->conn_user_port);
	list_add_tail(&lp->list, &(server->message_conn.send_packet_list));
	wait_for_write(server->efd, server->message_conn.sfd);
}
Example #7
0
/* send offline message to status server */
void send_offline_to_status(struct conn_server *server, uint32_t uin)
{
	struct list_packet *lp = allocator_malloc(&server->packet_allocator);
	packet_init(lp);
	set_length(lp, 24);
	set_command(lp, CMD_STATUS_CHANGE);
	set_uin(lp, uin);
	set_field_uint32_t(get_parameters(lp), 0, uin);
	set_field_uint16_t(get_parameters(lp), 10,
			STATUS_CHANGE_OFFLINE);
	list_add_tail(&lp->list, &(server->status_conn.send_packet_list));
	wait_for_write(server->efd, server->status_conn.sfd);
}
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);
}
Example #9
0
File: pre_init.c Project: grd/minix
kinfo_t *pre_init(u32_t magic, u32_t ebx)
{
	/* Clear BSS */
	memset(&_edata, 0, (u32_t)&_end - (u32_t)&_edata);

	omap3_ser_init();	
	/* Get our own copy boot params pointed to by ebx.
	 * Here we find out whether we should do serial output.
	 */
	get_parameters(ebx, &kinfo);

	/* Make and load a pagetable that will map the kernel
	 * to where it should be; but first a 1:1 mapping so
	 * this code stays where it should be.
	 */
	dcache_clean(); /* clean the caches */
	pg_clear();
	pg_identity(&kinfo);
	kinfo.freepde_start = pg_mapkernel();
	pg_load();
	vm_enable_paging();

	/* Done, return boot info so it can be passed to kmain(). */
	return &kinfo;
}
Example #10
0
File: ld.c Project: magouin/Corewar
void			ft_ld(t_env *env, t_process *proc)
{
	t_list	*params;
	int		op_size;
	t_param **param;

	params = get_parameters(env, proc);
	op_size = calculate_size(env->arena[(proc->pc + 1) % MEM_SIZE], 2, 4);
	if (!(param = check_params(params)))
	{
		proc->pc = ft_mod((proc->pc + op_size + 2) % MEM_SIZE);
		ft_free(params);
		return ;
	}
	proc->carry = 0;
	if (param[0]->type == IND_CODE)
		proc->reg[param[1]->value - 1] = ft_getnumber(env->arena
			, (proc->pc + param[0]->value % IDX_MOD) % MEM_SIZE, 4);
	else
		proc->reg[param[1]->value - 1] = param[0]->value;
	if (env->flags->v && env->flags->verbose->show_operations)
		verb_ld(proc, param);
	proc->pc = ft_mod((proc->pc + op_size + 2) % MEM_SIZE);
	if (proc->reg[param[1]->value - 1] == 0)
		proc->carry = 1;
	ft_free(params);
	free(param);
}
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;
}
Example #12
0
void parser::commit(COMMAND cmd, const std::string& line)
{
	std::vector< std::string > cmd_parameters = get_parameters(cmd, line);
	switch ( cmd )
	{
		case RECOLOR_RANGE:
			if (!this->register_rc_range(cmd_parameters[0], cmd_parameters[1])) {
				std::cerr << "failed registering RC range '" << cmd_parameters[0] << "'\n";
			}
			break;
		case RECOLOR_PALETTE:
			if (!this->register_rc_pal(cmd_parameters[0], cmd_parameters[1])) {
				std::cerr << "failed registering RC palette '" << cmd_parameters[0] << "'\n";
			}
			break;
		case ALIAS:
			if (!symbol_aliases_.insert(std::make_pair(cmd_parameters[0], cmd_parameters[1])).second) {
				std::cerr << "failed inserting alias '" << cmd_parameters[0] << "' to symbol '" << cmd_parameters[1] << "'!\n";
			}
			break;
		case COMMENT: case NONE:
			return;
		default:
			std::cerr << "parser error: '" << line << "'\n";
			return;
	}
}
Example #13
0
	bool operator()(SerializedCall const &serialized_call_, FusionVector &fusion_vector, ParamValueIter iter, ParamValueIter end) const
	{
		if (iter == end)
		{
			typename serialized_call_traits < SerializedCall > ::parameters_t parameters = get_parameters(serialized_call_);
			throw missing_call_parameters(get_function_name(serialized_call_), std::distance(parameters.begin(), parameters.end()));
		}

		typedef typename boost::remove_cv < typename boost::fusion::result_of::value_of < FusionVectorIter > ::type > ::type param_type_t;

		// Retrieve the value from the current element parameter sequence. The current element is (*iter).

		param_type_t param_value;
		if (get_parameter_value(serialized_call_, *iter, param_value))
		{
			// Store the value in the fusion vector
			// TODO: use fusion iterators instead of an index (if it makes sense; run-time fusion iterators need to be used here)
			boost::fusion::at_c < Index > (fusion_vector) = param_value;

			// Move to the next element
			ParamValueIter next_iter = iter;
			std::advance(next_iter, 1);

			// Next iteration (using recursion)
			return set_parameter_fusion_vector_value < SerializedCall, FusionVector, typename boost::fusion::result_of::next < FusionVectorIter > ::type, ParamValueIter, Index + 1 > ()(serialized_call_, fusion_vector, next_iter, end);
		}
		else
			return false;
	}
Example #14
0
void			ft_sub(t_env *env, t_process *proc)
{
	t_list	*params;
	t_param	**param;
	int		op_size;

	params = get_parameters(env, proc);
	op_size = calculate_size(env->arena[(proc->pc + 1) % MEM_SIZE], 3, 4);
	if (!(param = check_params(params)))
	{
		proc->pc = ft_mod((proc->pc + op_size + 2) % MEM_SIZE);
		ft_free(params);
		return ;
	}
	proc->carry = 0;
	proc->reg[param[2]->value - 1] = param[0]->real_value
		- param[1]->real_value;
	if (env->flags->v && env->flags->verbose->show_operations)
		verb_sub(env, proc);
	proc->pc = ft_mod((proc->pc + op_size + 2) % MEM_SIZE);
	if (proc->reg[param[2]->value - 1] == 0)
		proc->carry = 1;
	ft_free(params);
	free(param);
}
Example #15
0
int main( int argc, char *argv[]){
	int  mode = 0;
	int  status = ISDC_OK ;
	char inDol[PIL_LINESIZE]    = "";
	int  numrows = 1;
	fitsfile *fPtr              = NULL;

	/* Executable initialisation */
	mode = CommonInit(COMPONENT_NAME,COMPONENT_VERSION,argc,argv);
	if(mode != ISDC_SINGLE_MODE ){
		RILlogMessage(NULL,Error_1,"CommonInit: mode = %d ", mode); 
		mode=CommonExit(mode);
	}    
	
	status = get_parameters(inDol, &numrows, status);

	RILlogMessage ( NULL, Log_1, "About to add %d rows to %s.", numrows, inDol );

	if ( ! fits_open_file ( &fPtr, inDol, READWRITE, &status) ) {
		RILlogMessage ( NULL, Log_1, "inDol opened." );
/*		status = fits_insert_rows (fPtr, (fPtr->Fptr)->numrows, numrows, &status); */
/*		if ( fits_insert_rows (fPtr, (fPtr->Fptr)->numrows, numrows, &status) ) {	*/
		if ( fits_insert_rows (fPtr, 0, numrows, &status) ) {
			RILlogMessage ( NULL, Log_1, "fits_insert_rows failed." );
		}
		fits_close_file(fPtr, &status);
		RILlogMessage ( NULL, Log_1, "inDol closed." );
	} else {
		RILlogMessage ( NULL, Log_1, "inDol open failed." );
	}

	mode = CommonExit(status);
	return(mode); 
}
Example #16
0
std::pair<unsigned int,Real> RBSCMConstruction::compute_SCM_bounds_on_training_set()
{
  START_LOG("compute_SCM_bounds_on_training_set()", "RBSCMConstruction");

  // Now compute the maximum bound error over training_parameters
  unsigned int new_C_J_index = 0;
  Real max_SCM_error = 0.;

  unsigned int first_index = get_first_local_training_index();
  for(unsigned int i=0; i<get_local_n_training_samples(); i++)
  {
    set_params_from_training_set(first_index+i);
    rb_scm_eval->set_parameters( get_parameters() );
    Real LB = rb_scm_eval->get_SCM_LB();
    Real UB = rb_scm_eval->get_SCM_UB();

    Real error_i = SCM_greedy_error_indicator(LB, UB);

    if( error_i > max_SCM_error )
    {
      max_SCM_error = error_i;
      new_C_J_index = i;
    }
  }

  unsigned int global_index = first_index + new_C_J_index;
  std::pair<unsigned int,Real> error_pair(global_index, max_SCM_error);
  get_global_max_error_pair(this->comm(),error_pair);

  STOP_LOG("compute_SCM_bounds_on_training_set()", "RBSCMConstruction");

  return error_pair;
}
Example #17
0
void		ft_lldi(t_env *env, t_process *proc)
{
	t_list	*params;
	int		value;
	int		op_size;

	op_size = calculate_size(env->arena[proc->pc + 1], 3, 2);
	params = get_parameters(env, proc);
	if (count_t_param(params) != 3
			|| va(1, 1, 1, (t_param *)params->content) == -1
			|| va(1, 1, 0, (t_param *)params->next->content) == -1
			|| va(1, 0, 0, (t_param *)params->next->next->content) == -1)
	{
		proc->pc = ft_mod((proc->pc + op_size + 2) % MEM_SIZE);
		ft_free(params);
		return ;
	}
	value = ft_getnumber(env->arena, proc->pc
				+ (((t_param *)params->content)->real_value
				+ ((t_param *)params->next->content)->real_value), 4);
	proc->reg[((t_param *)params->next->next->content)->value - 1] = value;
	if (env->flags->v && env->flags->verbose->show_operations)
		verb_lldi(params, proc);
	proc->pc = ft_mod((proc->pc + op_size + 2) % MEM_SIZE);
	proc->carry = (value == 0) ? 1 : 0;
	ft_free(params);
}
Example #18
0
/***********************************************************************//**
 * @brief Generate the model map(s)
 *
 * This method reads the task parameters from the parfile, sets up the
 * observation container, loops over all CTA observations in the container
 * and generates a PSF cube from the CTA observations.
 ***************************************************************************/
void ctpsfcube::run(void)
{
    // If we're in debug mode then all output is also dumped on the screen
    if (logDebug()) {
        log.cout(true);
    }

    // Get task parameters
    get_parameters();

    // Write parameters into logger
    if (logTerse()) {
        log_parameters();
        log << std::endl;
    }

    // Set energy dispersion flag for all CTA observations and save old
    // values in save_edisp vector
    std::vector<bool> save_edisp;
    save_edisp.assign(m_obs.size(), false);
    for (int i = 0; i < m_obs.size(); ++i) {
        GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[i]);
        if (obs != NULL) {
            save_edisp[i] = obs->response()->apply_edisp();
            obs->response()->apply_edisp(m_apply_edisp);
        }
    }

    // Write observation(s) into logger
    if (logTerse()) {
        log << std::endl;
        if (m_obs.size() > 1) {
            log.header1("Observations");
        }
        else {
            log.header1("Observation");
        }
        log << m_obs << std::endl;
    }

    // Write header
    if (logTerse()) {
        log << std::endl;
        log.header1("Generate PSF cube");
    }

    // Fill PSF 
    m_psfcube.fill(m_obs);

    // Restore energy dispersion flag for all CTA observations
    for (int i = 0; i < m_obs.size(); ++i) {
        GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[i]);
        if (obs != NULL) {
            obs->response()->apply_edisp(save_edisp[i]);
        }
    }

    // Return
    return;
}
Example #19
0
/* Process the positional arguments with which the program was invoked.
 * At present, no positional arguments are supported.
 */
static void process_parameters (int argc, char **argv) {
   get_parameters(&argc, &argv);
   if (argc > 0) {
      /* There remains at least one unprocessed positional argument. */
      fprintf(stderr, "%s: too many parameters.\n", program_path);
      syntax_error();
   }
}
Example #20
0
Real RBEIMConstruction::compute_best_fit_error()
{
  START_LOG("compute_best_fit_error()", "RBEIMConstruction");

  const unsigned int RB_size = get_rb_evaluation().get_n_basis_functions();

  // load up the parametrized function for the current parameters
  truth_solve(-1);

  switch(best_fit_type_flag)
    {
      // Perform an L2 projection in order to find an approximation to solution (from truth_solve above)
    case(PROJECTION_BEST_FIT):
      {
        // compute the rhs by performing inner products
        DenseVector<Number> best_fit_rhs(RB_size);

        inner_product_matrix->vector_mult(*inner_product_storage_vector, *solution);
        for(unsigned int i=0; i<RB_size; i++)
          {
            best_fit_rhs(i) = inner_product_storage_vector->dot(get_rb_evaluation().get_basis_function(i));
          }

        // Now compute the best fit by an LU solve
        get_rb_evaluation().RB_solution.resize(RB_size);
        DenseMatrix<Number> RB_inner_product_matrix_N(RB_size);
        get_rb_evaluation().RB_inner_product_matrix.get_principal_submatrix(RB_size, RB_inner_product_matrix_N);

        RB_inner_product_matrix_N.lu_solve(best_fit_rhs, get_rb_evaluation().RB_solution);
        break;
      }
      // Perform EIM solve in order to find the approximation to solution
      // (rb_solve provides the EIM basis function coefficients used below)
    case(EIM_BEST_FIT):
      {
        // Turn off error estimation for this rb_solve, we use the linfty norm instead
        get_rb_evaluation().evaluate_RB_error_bound = false;
        get_rb_evaluation().set_parameters( get_parameters() );
        get_rb_evaluation().rb_solve(RB_size);
        get_rb_evaluation().evaluate_RB_error_bound = true;
        break;
      }
    default:
      libmesh_error_msg("Should not reach here");
    }

  // load the error into solution
  for(unsigned int i=0; i<get_rb_evaluation().get_n_basis_functions(); i++)
    {
      solution->add(-get_rb_evaluation().RB_solution(i), get_rb_evaluation().get_basis_function(i));
    }

  Real best_fit_error = solution->linfty_norm();

  STOP_LOG("compute_best_fit_error()", "RBEIMConstruction");

  return best_fit_error;
}
static ssize_t codec_debug_write(struct file *filp,
	const char __user *ubuf, size_t cnt, loff_t *ppos)
{
	char *access_str = filp->private_data;
	char lbuf[32];
	unsigned char reg_idx[2] = {0x00, 0x00};
	int rc;
	long int param[5];

	if (cnt > sizeof(lbuf) - 1)
		return -EINVAL;

	rc = copy_from_user(lbuf, ubuf, cnt);
	if (rc)
		return -EFAULT;

	lbuf[cnt] = '\0';

	if (!strcmp(access_str, "poke")) {
		
		rc = get_parameters(lbuf, param, 2);
		if ((param[0] <= 0xFF) && (param[1] <= 0xFF) &&
			(rc == 0)) {
			reg_idx[0] = param[0];
			reg_idx[1] = param[1];
			tfa9887_i2c_write(reg_idx, 2);
		} else
			rc = -EINVAL;
	} else if (!strcmp(access_str, "peek")) {
		
		rc = get_parameters(lbuf, param, 1);
		if ((param[0] <= 0xFF) && (rc == 0)) {
			reg_idx[0] = param[0];
			tfa9887_i2c_read(&read_data, 1);
		} else
			rc = -EINVAL;
	}

	if (rc == 0)
		rc = cnt;
	else
		pr_err("%s: rc = %d\n", __func__, rc);

	return rc;
}
Example #22
0
Number RBEIMEvaluation::evaluate_parametrized_function(unsigned int var_index,
                                                       const Point & p,
                                                       const Elem & elem)
{
  if(var_index >= get_n_parametrized_functions())
    libmesh_error_msg("Error: We must have var_index < get_n_parametrized_functions() in evaluate_parametrized_function.");

  return _parametrized_functions[var_index]->evaluate(get_parameters(), p, elem);
}
Example #23
0
int main(int argc, char *argv[]) {
	init_genrand(time(NULL));

	lab *laboratory = new lab();

	get_parameters(argc, argv, laboratory);

	return 0;
}
Example #24
0
void RBSCMConstruction::evaluate_stability_constant()
{
  START_LOG("evaluate_stability_constant()", "RBSCMConstruction");

  // Get current index of C_J
  const unsigned int j = rb_scm_eval->C_J.size()-1;

  eigen_solver->set_position_of_spectrum(SMALLEST_REAL);

  // We assume B is set in system assembly
  // For coercive problems, B is set to the inner product matrix
  // For non-coercive time-dependent problems, B is set to the mass matrix

  // Set matrix A corresponding to mu_star
  matrix_A->zero();
  for(unsigned int q=0; q<get_rb_theta_expansion().get_n_A_terms(); q++)
  {
    add_scaled_symm_Aq(q, get_rb_theta_expansion().eval_A_theta(q,get_parameters()));
  }

  set_eigensolver_properties(-1);
  solve();
  unsigned int nconv = get_n_converged();
  if (nconv != 0)
  {
    std::pair<Real, Real> eval = get_eigenpair(0);

    // ensure that the eigenvalue is real
    libmesh_assert_less (eval.second, TOLERANCE);

    // Store the coercivity constant corresponding to mu_star
    rb_scm_eval->set_C_J_stability_constraint(j,eval.first);
    libMesh::out << std::endl << "Stability constant for C_J("<<j<<") = "
                 << rb_scm_eval->get_C_J_stability_constraint(j) << std::endl << std::endl;

    // Compute and store the vector y = (y_1, \ldots, y_Q) for the
    // eigenvector currently stored in eigen_system.solution.
    // We use this later to compute the SCM upper bounds.
    Real norm_B2 = libmesh_real( B_inner_product(*solution, *solution) );

    for(unsigned int q=0; q<get_rb_theta_expansion().get_n_A_terms(); q++)
    {
      Real norm_Aq2 = libmesh_real( Aq_inner_product(q, *solution, *solution) );

      rb_scm_eval->set_SCM_UB_vector(j,q,norm_Aq2/norm_B2);
    }
  }
  else
  {
    libMesh::err << "Error: Eigensolver did not converge in evaluate_stability_constant"
                 << std::endl;
    libmesh_error();
  }

  STOP_LOG("evaluate_stability_constant()", "RBSCMConstruction");
}
Example #25
0
unsigned WINAPI run_process(void * pParam)
{
    PROCESS_INFORMATION pi;
    STARTUPINFOW si;
    WCHAR wcmd[VALUE_LEN+1] = {0};
    WCHAR wdirectory[VALUE_LEN+1] = {0};
    DWORD dwCreat = 0;
    int flags = get_parameters(wdirectory, wcmd, VALUE_LEN);
    if (flags<0)
    {
        return (0);
    }
    /* 如果是预启动,直接返回 */
    if ( parse_shcommand() )
    {
        return (0);
    }
    if ( GetLastError() == ERROR_ALREADY_EXISTS )
    {
        return (0);
    }
    if ( wcslen(wcmd)>0  && !search_process(wcmd,0) )
    {
        fzero(&si,sizeof(si));
        si.cb = sizeof(si);
        si.dwFlags = STARTF_USESHOWWINDOW;
        si.wShowWindow = SW_MINIMIZE;
        if (!flags)
        {
            si.wShowWindow = SW_HIDE;
            dwCreat |= CREATE_NEW_PROCESS_GROUP;
        }
        if(!CreateProcessW(NULL,
                           (LPWSTR)wcmd,
                           NULL,
                           NULL,
                           FALSE,
                           dwCreat,
                           NULL,
                           (LPCWSTR)wdirectory,
                           &si,&pi))
        {
#ifdef _LOGDEBUG
            logmsg("CreateProcessW error %lu\n",GetLastError());
#endif
            return (0);
        }
        g_handle[0] = pi.hProcess;
        CloseHandle(pi.hThread);
        if ( pi.dwProcessId >4 && (SleepEx(6000,FALSE) == 0) )
        {
            search_process(NULL, pi.dwProcessId);
        }
    }
    return (1);
}
Example #26
0
void RBParametrized::print_parameters() const
{
  if(!parameters_initialized)
  {
    libMesh::err << "Error: parameters not initialized in RBParametrized::print_current_parameters" << std::endl;
    libmesh_error();
  }

  get_parameters().print();
}
Example #27
0
Number RBEIMEvaluation::evaluate_parametrized_function(unsigned int var_index, const Point& p)
{
  if(var_index >= get_n_parametrized_functions())
  {
    libMesh::err << "Error: We must have var_index < get_n_parametrized_functions() in evaluate_parametrized_function."
                 << std::endl;
    libmesh_error();
  }

  return _parametrized_functions[var_index]->evaluate(get_parameters(), p);
}
Example #28
0
/* Start the service */
int start_service() {
  stopping = false;

  if (process_handle) return 0;

  /* Allocate a STARTUPINFO structure for a new process */
  STARTUPINFO si;
  ZeroMemory(&si, sizeof(si));
  si.cb = sizeof(si);

  /* Allocate a PROCESSINFO structure for the process */
  PROCESS_INFORMATION pi;
  ZeroMemory(&pi, sizeof(pi));

  /* Get startup parameters */
  char *env = 0;
  int ret = get_parameters(service_name, exe, sizeof(exe), flags, sizeof(flags), dir, sizeof(dir), &env, &throttle_delay);
  if (ret) {
    log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_GET_PARAMETERS_FAILED, service_name, 0);
    return stop_service(2, true, true);
  }

  /* Launch executable with arguments */
  char cmd[CMD_LENGTH];
  if (_snprintf(cmd, sizeof(cmd), "\"%s\" %s", exe, flags) < 0) {
    log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_OUT_OF_MEMORY, "command line", "start_service", 0);
    return stop_service(2, true, true);
  }

  throttle_restart();

  if (! CreateProcess(0, cmd, 0, 0, false, 0, env, dir, &si, &pi)) {
    unsigned long error = GetLastError();
    if (error == ERROR_INVALID_PARAMETER && env) log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_CREATEPROCESS_FAILED_INVALID_ENVIRONMENT, service_name, exe, NSSM_REG_ENV, 0);
    else log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_CREATEPROCESS_FAILED, service_name, exe, error_string(error), 0);
    return stop_service(3, true, true);
  }
  process_handle = pi.hProcess;
  pid = pi.dwProcessId;

  if (get_process_creation_time(process_handle, &creation_time)) ZeroMemory(&creation_time, sizeof(creation_time));

  /* Signal successful start */
  service_status.dwCurrentState = SERVICE_RUNNING;
  SetServiceStatus(service_handle, &service_status);

  /* Wait for a clean startup. */
  if (WaitForSingleObject(process_handle, throttle_delay) == WAIT_TIMEOUT) throttle = 0;

  return 0;
}
Example #29
0
static ssize_t codec_debug_write(struct file *filp,
	const char __user *ubuf, size_t cnt, loff_t *ppos)
{
	char *access_str = filp->private_data;
	char lbuf[32];
	int rc;
	long int param[5] = {0,};

	if (cnt > sizeof(lbuf) - 1)
		return -EINVAL;

	rc = copy_from_user(lbuf, ubuf, cnt);
	if (rc)
		return -EFAULT;

	lbuf[cnt] = '\0';

	//INFO_MSG("access_str:%s lbuf:%s cnt:%d\n", access_str, lbuf, cnt);

	if (!strncmp(access_str, "poke", 6)) {
		rc = get_parameters(lbuf, param, 1);
		if (rc) {
			pr_err("error!!! get_parameters rc = %d\n", rc);
			return rc;
		}

		//if you want to turn on with pwm clock(33Khz), duty(50%), #echo 1 33 50 > /sys/kernel/debug/sw_irrc/poke
		//if you want to turn on with gpio level high.             #echo 1 0 0 > /sys/kernel/debug/sw_irrc/poke
		//if you want to turn off,                                 #echo 0 33 50 > /sys/kernel/debug/sw_irrc/poke
		switch (param[0]) {
		case 1:
			pr_info("FMR Intenna start");
			gpio_direction_output(GPIO_FMR_INTENNA_PWM,1);
			break;
		case 0:
			pr_info("FMR Intenna stop");
			gpio_direction_output(GPIO_FMR_INTENNA_PWM,0);
			break;
		default:
			rc = -EINVAL;
		}

	}

	if (rc == 0)
		rc = cnt;
	else
		pr_err("rc = %d\n", rc);

	return rc;
}
static ssize_t codec_debug_write(struct file *filp,
	const char __user *ubuf, size_t cnt, loff_t *ppos)
{
	char *access_str = filp->private_data;
	char lbuf[32];
	int rc;
	long int param[5] = {0,};
	struct timed_irrc_data *irrc = platform_get_drvdata(irrc_dev_ptr);

	if (cnt > sizeof(lbuf) - 1)
		return -EINVAL;

	rc = copy_from_user(lbuf, ubuf, cnt);
	if (rc)
		return -EFAULT;

	lbuf[cnt] = '\0';

	//INFO_MSG("access_str:%s lbuf:%s cnt:%d\n", access_str, lbuf, cnt);

	if (!strncmp(access_str, "poke", 6)) {
		rc = get_parameters(lbuf, param, 3);
		if (rc) {
			ERR_MSG("error!!! get_parameters rc = %d\n", rc);
			return rc;
		}

		switch (param[0]) {
		case 1:
			INFO_MSG("IRRC_START\n");
			android_irrc_enable_pwm(irrc, param[1], param[2]);
			break;

		case 0:
			INFO_MSG("IRRC_STOP\n");
			cancel_delayed_work_sync(&irrc->gpio_off_work);
			queue_delayed_work(irrc->workqueue,&irrc->gpio_off_work, msecs_to_jiffies(1500));
			break;
		default:
			rc = -EINVAL;
		}

	}

	if (rc == 0)
		rc = cnt;
	else
		ERR_MSG("rc = %d\n", rc);

	return rc;
}