Exemplo n.º 1
0
void PointTest::testAccessors() {
    Mcmc::Point point(parameters_, measurements_, likelihood_);
    
    CPPUNIT_ASSERT(gsl_vector_equal(point.parameters(), parameters_) == 1);
    CPPUNIT_ASSERT(gsl_vector_equal(point.measurements(), measurements_) 
            == 1);
    CPPUNIT_ASSERT_DOUBLES_EQUAL(point.likelihood(), likelihood_, d_);
}
Exemplo n.º 2
0
static int _equal(CVECTOR *a, CVECTOR *b, bool invert)
{
	if (COMPLEX(a) || COMPLEX(b))
	{
		VECTOR_ensure_complex(a);
		VECTOR_ensure_complex(b);
		return gsl_vector_complex_equal(CVEC(a), CVEC(b));
	}
	else
		return gsl_vector_equal(VEC(a), VEC(b));
}
Exemplo n.º 3
0
static void 
intermediate_point (gsl_multimin_function_fdf * fdf,
                    const gsl_vector * x, const gsl_vector * p,
                    double lambda, 
                    double pg,
                    double stepa, double stepc,
                    double fa, double fc,
                    gsl_vector * x1, gsl_vector * dx, gsl_vector * gradient,
                    double * step, double * f)
{
  double stepb, fb;

trial:
  {
    double u = fabs (pg * lambda * stepc);
    stepb = 0.5 * stepc * u / ((fc - fa) + u);
  }

  take_step (x, p, stepb, lambda, x1, dx);

  if (gsl_vector_equal (x, x1)) 
    {
      /* Take fast exit if trial point does not move from initial point */
#ifdef DEBUG
      printf ("fast exit x == x1 for stepb = %g\n", stepb);
#endif
      *step = 0;
      *f = fa;
      GSL_MULTIMIN_FN_EVAL_DF(fdf, x1, gradient);
      return ; 
    }

  fb = GSL_MULTIMIN_FN_EVAL_F (fdf, x1);

#ifdef DEBUG
  printf ("trying stepb = %g  fb = %.18e\n", stepb, fb);
#endif

  if (fb >= fa  && stepb > 0.0)
    {
      /* downhill step failed, reduce step-size and try again */
      fc = fb;
      stepc = stepb;
      goto trial;
    }
#ifdef DEBUG
  printf ("ok!\n");
#endif

  *step = stepb;
  *f = fb;
  GSL_MULTIMIN_FN_EVAL_DF(fdf, x1, gradient);
}