Example #1
0
File: cscal.c Project: CNMAT/gsl
gsl_odeiv2_control *
gsl_odeiv2_control_scaled_new (double eps_abs, double eps_rel,
                               double a_y, double a_dydt,
                               const double scale_abs[], size_t dim)
{
  gsl_odeiv2_control *c =
    gsl_odeiv2_control_alloc (gsl_odeiv2_control_scaled);

  int status = gsl_odeiv2_control_init (c, eps_abs, eps_rel, a_y, a_dydt);

  if (status != GSL_SUCCESS)
    {
      gsl_odeiv2_control_free (c);
      GSL_ERROR_NULL ("error trying to initialize control", status);
    }

  {
    sc_control_state_t *s = (sc_control_state_t *) c->state;

    s->scale_abs = (double *) malloc (dim * sizeof (double));

    if (s->scale_abs == 0)
      {
        free (s);
        GSL_ERROR_NULL ("failed to allocate space for scale_abs", GSL_ENOMEM);
      }

    memcpy (s->scale_abs, scale_abs, dim * sizeof (double));
  }

  return c;
}
Example #2
0
gsl_odeiv2_control *
gsl_odeiv2_control_standard_new (double eps_abs, double eps_rel,
                                 double a_y, double a_dydt)
{
    gsl_odeiv2_control *c =
        gsl_odeiv2_control_alloc (gsl_odeiv2_control_standard);

    int status = gsl_odeiv2_control_init (c, eps_abs, eps_rel, a_y, a_dydt);

    if (status != GSL_SUCCESS)
    {
        gsl_odeiv2_control_free (c);
        GSL_ERROR_NULL ("error trying to initialize control", status);
    }

    return c;
}
Example #3
0
void IzhikevichBranch::subthreshold_regimeRegime_::init_solver() {
    

    IntegrationStep_ = cell->B_.step_;

    static const gsl_odeiv2_step_type* T1 = gsl_odeiv2_step_rk2;
    //FIXME: Could be reduced to include only the states which have a time
    //       derivative
    N = 2;

    if ( s_ == 0 )
        s_ = gsl_odeiv2_step_alloc (T1, N);
    else
        gsl_odeiv2_step_reset(s_);

    if ( c_ == 0 )
        c_ = gsl_odeiv2_control_standard_new (0.001, 0.0, 1.0, 0.0);
    else
        gsl_odeiv2_control_init(c_, 0.001, 0.0, 1.0, 0.0);

    if ( e_ == 0 )
        e_ = gsl_odeiv2_evolve_alloc(N);
    else
        gsl_odeiv2_evolve_reset(e_);

    sys_.function  = IzhikevichBranch_subthreshold_regime_dynamics;
    sys_.jacobian  = IzhikevichBranch_subthreshold_regime_jacobian;
    sys_.dimension = N;
    sys_.params    = reinterpret_cast<void*>(this->cell);

    if (u == 0)
        u = (double *)malloc(sizeof(double) * N);
        assert (u);
    if (jac == 0)
        jac = (double *)malloc(sizeof(double) * N);
        assert (jac);    
}