Exemple #1
0
/* tests a single evaluator function from the high-level interface */
static int
test_single_high_level(
    double (*evaluator)(const gsl_spline2d *, const double, const double,
                        gsl_interp_accel *, gsl_interp_accel *),
    int (*evaluator_e)(const gsl_spline2d *, const double, const double,
                       gsl_interp_accel *, gsl_interp_accel *, double *),
    const gsl_spline2d * interp, const double x, const double y,
    gsl_interp_accel * xa, gsl_interp_accel * ya,
    const double expected_results[], size_t i)
{
  if (expected_results != NULL)
    {
      int status;
      double result = evaluator(interp, x, y, xa, ya);

      gsl_test_rel(result, expected_results[i], 1e-10,
                   "high level %s %d", gsl_spline2d_name(interp), i);

      status = evaluator_e(interp, x, y, xa, ya, &result);
      if (status == GSL_SUCCESS)
        {
          gsl_test_rel(result, expected_results[i], 1e-10,
                       "high level _e %s %d", gsl_spline2d_name(interp), i);
        }
    }

  return 0;
}
Exemple #2
0
int
main()
{
  double latc, rc;
  double lon;

  rc = 100.0 + 6371.2;
  lon = 20.0;

  for (latc = -90.0; latc < 90.0; latc += 1.0)
    {
      double latc_rad = latc * M_PI / 180.0;
      double latd, altd;
      double lat, r;

      geo2geodetic(latc_rad,
                   lon * M_PI / 180.0,
                   rc,
                   &latd,
                   &altd);

       geodetic2geo(latd, altd, &lat, &r);

       gsl_test_rel(lat, latc_rad, 1.0e-7, "lat");
       gsl_test_rel(r, rc, 1.0e-7, "r");
    }

  exit (gsl_test_summary());
}
Exemple #3
0
/*
 * Test the identities:
 *
 * Sum_{k=0}^n (n choose k) (2 y)^{n - k} H_k(x) = H_n(x + y)
 *
 * and
 *
 * Sum_{k=0}^n (n choose k) y^{n-k} He_k(x) = He_n(x + y)
 *
 * see: http://mathworld.wolfram.com/HermitePolynomial.html (Eq. 55)
 */
void
test_hermite_id1(const int n, const double x, const double y)
{
  double *a = malloc((n + 1) * sizeof(double));
  double *b = malloc((n + 1) * sizeof(double));
  double lhs, rhs;
  int k;

  a[0] = gsl_pow_int(2.0 * y, n);
  b[0] = gsl_pow_int(y, n);
  for (k = 1; k <= n; ++k)
    {
      double fac = (n - k + 1.0) / (k * y);
      a[k] = 0.5 * fac * a[k - 1];
      b[k] = fac * b[k - 1];
    }

  lhs = gsl_sf_hermite_phys_series(n, x, a);
  rhs = gsl_sf_hermite_phys(n, x + y);
  gsl_test_rel(lhs, rhs, TEST_TOL4, "identity1 phys n=%d x=%g y=%g", n, x, y);

  lhs = gsl_sf_hermite_prob_series(n, x, b);
  rhs = gsl_sf_hermite_prob(n, x + y);
  gsl_test_rel(lhs, rhs, TEST_TOL3, "identity1 prob n=%d x=%g y=%g", n, x, y);

  free(a);
  free(b);
}
Exemple #4
0
static int
test_pontius_results(const char *str,
                     const gsl_vector *c, const gsl_vector *expected_c,
                     const gsl_vector *cov_diag, const gsl_vector *expected_sd,
                     const double chisq, const double chisq_res,
                     const double expected_chisq)
{
  size_t i;

  /* test coefficient vector */
  for (i = 0; i < pontius_p; ++i)
    {
      gsl_test_rel (gsl_vector_get(c,i),
                    gsl_vector_get(expected_c, i),
                    1.0e-10,
                    "%s c["F_ZU"]", str, i) ;

      if (cov_diag && expected_sd)
        {
          gsl_test_rel (sqrt(gsl_vector_get(cov_diag, i)),
                        gsl_vector_get(expected_sd, i),
                        1e-10,
                        "%s cov["F_ZU","F_ZU"]", str, i, i);
        }
    }

  gsl_test_rel (chisq, expected_chisq, 1.0e-10, "%s chisq", str);
  gsl_test_rel (chisq_res, expected_chisq, 1.0e-10, "%s chisq residuals", str);

  return GSL_SUCCESS;
}
void
test_lmder (gsl_multifit_function_fdf * f, double x0[], 
            double * X, double F[], double * cov)
{
  const gsl_multifit_fdfsolver_type *T;
  gsl_multifit_fdfsolver *s;

  const size_t n = f->n;
  const size_t p = f->p;

  int status;
  size_t iter = 0, i;
  
  gsl_vector_view x = gsl_vector_view_array (x0, p);

  T = gsl_multifit_fdfsolver_lmsder;
  s = gsl_multifit_fdfsolver_alloc (T, n, p);
  gsl_multifit_fdfsolver_set (s, f, &x.vector);

  do
    {
      status = gsl_multifit_fdfsolver_iterate (s);

      for (i = 0 ; i < p; i++)
        {
          gsl_test_rel (gsl_vector_get (s->x, i), X[p*iter+i], 1e-5, 
                        "lmsder, iter=%u, x%u", iter, i);
        }

      gsl_test_rel (gsl_blas_dnrm2 (s->f), F[iter], 1e-5, 
                    "lmsder, iter=%u, f", iter);

      iter++;
    }
  while (iter < 20);
  
  {
    size_t i, j;
    gsl_matrix * covar = gsl_matrix_alloc (4, 4);
    gsl_multifit_covar (s->J, 0.0, covar);

    for (i = 0; i < 4; i++) 
      {
        for (j = 0; j < 4; j++)
          {
            gsl_test_rel (gsl_matrix_get(covar,i,j), cov[i*p + j], 1e-7, 
                          "gsl_multifit_covar cov(%d,%d)", i, j) ;
          }
      }

    gsl_matrix_free (covar);
  }

  gsl_multifit_fdfsolver_free (s);

}
Exemple #6
0
void
test_eigen_gensymm_results (const gsl_matrix * A, 
                            const gsl_matrix * B,
                            const gsl_vector * eval, 
                            const gsl_matrix * evec, 
                            size_t count,
                            const char * desc,
                            const char * desc2)
{
  const size_t N = A->size1;
  size_t i, j;

  gsl_vector * x = gsl_vector_alloc(N);
  gsl_vector * y = gsl_vector_alloc(N);
  gsl_vector * z = gsl_vector_alloc(N);

  /* check A v = lambda B v */
  for (i = 0; i < N; i++)
    {
      double ei = gsl_vector_get (eval, i);
      gsl_vector_const_view vi = gsl_matrix_const_column(evec, i);
      double norm = gsl_blas_dnrm2(&vi.vector);

      /* check that eigenvector is normalized */
      gsl_test_rel(norm, 1.0, N * GSL_DBL_EPSILON,
                   "gensymm(N=%u,cnt=%u), %s, normalized(%d), %s", N, count,
                   desc, i, desc2);

      gsl_vector_memcpy(z, &vi.vector);

      /* compute y = A z */
      gsl_blas_dgemv (CblasNoTrans, 1.0, A, z, 0.0, y);

      /* compute x = B z */
      gsl_blas_dgemv (CblasNoTrans, 1.0, B, z, 0.0, x);

      /* compute x = lambda B z */
      gsl_blas_dscal(ei, x);

      /* now test if y = x */
      for (j = 0; j < N; j++)
        {
          double xj = gsl_vector_get (x, j);
          double yj = gsl_vector_get (y, j);

          gsl_test_rel(yj, xj, 1e9 * GSL_DBL_EPSILON, 
                       "gensymm(N=%u,cnt=%u), %s, eigenvalue(%d,%d), real, %s", N, count, desc, i, j, desc2);
        }
    }

  gsl_vector_free(x);
  gsl_vector_free(y);
  gsl_vector_free(z);
}
Exemple #7
0
void
test_eigen_genherm_results (const gsl_matrix_complex * A, 
                            const gsl_matrix_complex * B,
                            const gsl_vector * eval, 
                            const gsl_matrix_complex * evec, 
                            size_t count,
                            const char * desc,
                            const char * desc2)
{
  const size_t N = A->size1;
  size_t i, j;

  gsl_vector_complex * x = gsl_vector_complex_alloc(N);
  gsl_vector_complex * y = gsl_vector_complex_alloc(N);

  /* check A v = lambda B v */
  for (i = 0; i < N; i++)
    {
      double ei = gsl_vector_get (eval, i);
      gsl_vector_complex_const_view vi =
        gsl_matrix_complex_const_column(evec, i);
      double norm = gsl_blas_dznrm2(&vi.vector);

      /* check that eigenvector is normalized */
      gsl_test_rel(norm, 1.0, N * GSL_DBL_EPSILON,
                   "genherm(N=%u,cnt=%u), %s, normalized(%d), %s", N, count,
                   desc, i, desc2);

      /* compute y = A z */
      gsl_blas_zgemv (CblasNoTrans, GSL_COMPLEX_ONE, A, &vi.vector, GSL_COMPLEX_ZERO, y);

      /* compute x = B z */
      gsl_blas_zgemv (CblasNoTrans, GSL_COMPLEX_ONE, B, &vi.vector, GSL_COMPLEX_ZERO, x);

      /* compute x = lambda B z */
      gsl_blas_zdscal(ei, x);

      /* now test if y = x */
      for (j = 0; j < N; j++)
        {
          gsl_complex xj = gsl_vector_complex_get (x, j);
          gsl_complex yj = gsl_vector_complex_get (y, j);

          gsl_test_rel(GSL_REAL(yj), GSL_REAL(xj), 1e9 * GSL_DBL_EPSILON, 
                       "genherm(N=%u,cnt=%u), %s, eigenvalue(%d,%d), real, %s", N, count, desc, i, j, desc2);
          gsl_test_abs(GSL_IMAG(yj), GSL_IMAG(xj), 1e9 * GSL_DBL_EPSILON, 
                       "genherm(N=%u,cnt=%u), %s, eigenvalue(%d,%d), imag, %s", N, count, desc, i, j, desc2);
        }
    }

  gsl_vector_complex_free(x);
  gsl_vector_complex_free(y);
}
Exemple #8
0
/* solve system with lambda = 0 and test against OLS solution */
static void
test_reg1(const gsl_matrix * X, const gsl_vector * y,
          const gsl_vector * wts, const double tol,
          gsl_multifit_linear_workspace * w, const char * desc)
{
  const size_t n = X->size1;
  const size_t p = X->size2;
  double rnorm, snorm, chisq;
  gsl_vector *c0 = gsl_vector_alloc(p);
  gsl_vector *c1 = gsl_vector_alloc(p);
  gsl_matrix *cov = gsl_matrix_alloc(p, p);
  size_t j;

  if (wts)
    {
      gsl_matrix *Xs = gsl_matrix_alloc(n, p);
      gsl_vector *ys = gsl_vector_alloc(n);

      gsl_multifit_wlinear(X, wts, y, c0, cov, &chisq, w);

      gsl_multifit_linear_wstdform1(NULL, X, wts, y, Xs, ys, w);
      gsl_multifit_linear_svd(Xs, w);
      gsl_multifit_linear_solve(0.0, Xs, ys, c1, &rnorm, &snorm, w);

      gsl_matrix_free(Xs);
      gsl_vector_free(ys);
    }
  else
    {
      gsl_multifit_linear(X, y, c0, cov, &chisq, w);

      gsl_multifit_linear_svd(X, w);
      gsl_multifit_linear_solve(0.0, X, y, c1, &rnorm, &snorm, w);
    }

  gsl_test_rel(rnorm*rnorm, chisq, tol,
               "test_reg1: %s, lambda = 0, n=%zu p=%zu chisq", desc, n, p);

  /* test c0 = c1 */
  for (j = 0; j < p; ++j)
    {
      double c0j = gsl_vector_get(c0, j);
      double c1j = gsl_vector_get(c1, j);

      gsl_test_rel(c1j, c0j, tol, "test_reg1: %s, lambda = 0, n=%zu p=%zu c0/c1",
                   desc, n, p);
    }

  gsl_vector_free(c0);
  gsl_vector_free(c1);
  gsl_matrix_free(cov);
}
static void
osborne_checksol(const double x[], const double sumsq,
                 const double epsrel, const char *sname,
                 const char *pname)
{
  const double sumsq_exact = 5.464894697482687e-05;
  const double osborne_x[osborne_P] = {
    3.754100521058740e-01, GSL_NAN, GSL_NAN, GSL_NAN, GSL_NAN };

  gsl_test_rel(sumsq, sumsq_exact, epsrel, "%s/%s sumsq",
               sname, pname);

  /* only the first model parameter is uniquely constrained */
  gsl_test_rel(x[0], osborne_x[0], epsrel, "%s/%s i=0",
               sname, pname);
}
Exemple #10
0
static int
test_COD_decomp_eps(const gsl_matrix * m, const double eps, const char *desc)
{
  int s = 0;
  size_t i, j, M = m->size1, N = m->size2;
  size_t rank;

  gsl_matrix * QRZT = gsl_matrix_alloc(M, N);
  gsl_matrix * Q = gsl_matrix_alloc(M, M);
  gsl_matrix * R = gsl_matrix_alloc(M, N);
  gsl_matrix * QR = gsl_matrix_alloc(M, N);
  gsl_matrix * Z = gsl_matrix_alloc(N, N);
  gsl_vector * tau_Q = gsl_vector_alloc(GSL_MIN(M, N));
  gsl_vector * tau_Z = gsl_vector_alloc(GSL_MIN(M, N));
  gsl_vector * work = gsl_vector_alloc(N);
  gsl_matrix * lhs = gsl_matrix_alloc(M, N);
  gsl_matrix * rhs = gsl_matrix_alloc(M, N);

  gsl_permutation * perm = gsl_permutation_alloc(N);

  gsl_matrix_memcpy(QRZT, m);

  s += gsl_linalg_COD_decomp(QRZT, tau_Q, tau_Z, perm, &rank, work);
  s += gsl_linalg_COD_unpack(QRZT, tau_Q, tau_Z, rank, Q, R, Z);

  /* compute lhs = m P */
  gsl_matrix_memcpy(lhs, m);
  gsl_permute_matrix(perm, lhs);

  /* compute rhs = Q R Z^T */
  gsl_blas_dgemm (CblasNoTrans, CblasNoTrans, 1.0, Q, R, 0.0, QR);
  gsl_blas_dgemm (CblasNoTrans, CblasTrans, 1.0, QR, Z, 0.0, rhs);

  for (i = 0; i < M; i++)
    {
      for (j = 0; j < N; j++)
        {
          double aij = gsl_matrix_get(rhs, i, j);
          double bij = gsl_matrix_get(lhs, i, j);

          gsl_test_rel(aij, bij, eps, "%s (%3lu,%3lu)[%lu,%lu]: %22.18g   %22.18g\n",
                       desc, M, N, i, j, aij, bij);
        }
    }

  gsl_permutation_free (perm);
  gsl_vector_free(work);
  gsl_vector_free(tau_Q);
  gsl_vector_free(tau_Z);
  gsl_matrix_free(QRZT);
  gsl_matrix_free(lhs);
  gsl_matrix_free(rhs);
  gsl_matrix_free(QR);
  gsl_matrix_free(Q);
  gsl_matrix_free(R);
  gsl_matrix_free(Z);

  return s;
}
Exemple #11
0
static void
powell1_checksol(const double x[], const double sumsq,
                 const double epsrel, const char *sname,
                 const char *pname)
{
    size_t i;
    const double sumsq_exact = 0.0;

    gsl_test_rel(sumsq, sumsq_exact, epsrel, "%s/%s sumsq",
                 sname, pname);

    for (i = 0; i < powell1_P; ++i)
    {
        gsl_test_rel(x[i], 0.0, epsrel, "%s/%s i="F_ZU,
                     sname, pname, i);
    }
}
Exemple #12
0
static void
lin1_checksol(const double x[], const double sumsq,
              const double epsrel, const char *sname,
              const char *pname)
{
  size_t i;
  const double sumsq_exact = (double) (lin1_N - lin1_P);

  gsl_test_rel(sumsq, sumsq_exact, epsrel, "%s/%s sumsq",
               sname, pname);

  for (i = 0; i < lin1_P; ++i)
    {
      gsl_test_rel(x[i], -1.0, epsrel, "%s/%s i=%zu",
                   sname, pname, i);
    }
}
Exemple #13
0
static void
rosenbrock_checksol(const double x[], const double sumsq,
                    const double epsrel, const char *sname,
                    const char *pname)
{
  size_t i;
  const double sumsq_exact = 0.0;

  gsl_test_rel(sumsq, sumsq_exact, epsrel, "%s/%s sumsq",
               sname, pname);

  for (i = 0; i < rosenbrock_P; ++i)
    {
      gsl_test_rel(x[i], 1.0, epsrel, "%s/%s i=%zu",
                   sname, pname, i);
    }
}
Exemple #14
0
void
test_bspline(gsl_bspline_workspace * bw, gsl_bspline_deriv_workspace * dbw)
{
  gsl_vector *B;
  gsl_matrix *dB;
  size_t i, j;
  size_t n = 100;
  size_t ncoeffs = gsl_bspline_ncoeffs(bw);
  size_t order = gsl_bspline_order(bw);
  size_t nbreak = gsl_bspline_nbreak(bw);
  double a = gsl_bspline_breakpoint(0, bw);
  double b = gsl_bspline_breakpoint(nbreak - 1, bw);

  B  = gsl_vector_alloc(ncoeffs);
  dB = gsl_matrix_alloc(ncoeffs, 1);

  /* Ensure B-splines form a partition of unity */
  for (i = 0; i < n; i++)
    {
      double xi = a + (b - a) * (i / (n - 1.0));
      double sum = 0;
      gsl_bspline_eval(xi, B, bw);

      for (j = 0; j < ncoeffs; j++)
        {
          double Bj = gsl_vector_get(B, j);
          int s = (Bj < 0 || Bj > 1);
          gsl_test(s,
                   "basis-spline coefficient %u is in range [0,1] for x=%g",
                   j, xi);
          sum += Bj;
        }

      gsl_test_rel(sum, 1.0, order * GSL_DBL_EPSILON,
                   "basis-spline order %u is normalized for x=%g", order,
                   xi);
    }

  /* Ensure B-splines 0th derivatives agree with regular evaluation */
  for (i = 0; i < n; i++)
    {
      double xi = a + (b - a) * (i / (n - 1.0));
      gsl_bspline_eval(xi, B, bw);
      gsl_bspline_deriv_eval(xi, 0, dB, bw, dbw);

      for (j = 0; j < ncoeffs; j++)
        {
          gsl_test_abs(gsl_matrix_get(dB, j, 0), gsl_vector_get(B, j),
                       GSL_DBL_EPSILON,
                       "b-spline order %d basis #%d evaluation and 0th derivative consistent for x=%g",
                       order, j, xi);
        }

    }

  gsl_vector_free(B);
  gsl_matrix_free(dB);
}
Exemple #15
0
static void
brown2_checksol(const double x[], const double sumsq,
              const double epsrel, const char *sname,
              const char *pname)
{
  size_t i;
  double sumsq_exact;
  double alpha;
  const double p = (double) brown2_P;
  double alpha1mp, lhs, lastel;

  if (sumsq < 0.5)
    {
      /* sumsq = 0 case */

      sumsq_exact = 0.0;
      alpha = x[0];
      alpha1mp = pow(alpha, 1.0 - p);
      lhs = p*pow(alpha, p) - (p + 1)/alpha1mp;
      lastel = alpha1mp;

      gsl_test_rel(lhs, -1.0, epsrel, "%s/%s alpha lhs",
                   sname, pname);
    }
  else
    {
      /* sumsq = 1 case */

      sumsq_exact = 1.0;
      alpha = 0.0;
      lastel = p + 1.0;
    }

  gsl_test_rel(sumsq, sumsq_exact, epsrel, "%s/%s sumsq",
               sname, pname);

  for (i = 1; i < brown2_P - 1; ++i)
    {
      gsl_test_rel(x[i], alpha, epsrel, "%s/%s i="F_ZU,
                   sname, pname, i);
    }

  gsl_test_rel(x[brown2_P - 1], lastel, epsrel, "%s/%s last element",
               sname, pname);
}
Exemple #16
0
static void
brown3_checksol(const double x[], const double sumsq,
                const double epsrel, const char *sname,
                const char *pname)
{
  size_t i;
  const double sumsq_exact = 0.0;
  const double brown3_x[brown3_P] = { 1.0e6, 2.0e-6 };

  gsl_test_rel(sumsq, sumsq_exact, epsrel, "%s/%s sumsq",
               sname, pname);

  for (i = 0; i < brown3_P; ++i)
    {
      gsl_test_rel(x[i], brown3_x[i], epsrel, "%s/%s i=%zu",
                   sname, pname, i);
    }
}
Exemple #17
0
static void
exp1_checksol(const double x[], const double sumsq,
              const double epsrel, const char *sname,
              const char *pname)
{
  size_t i;
  const double sumsq_exact = 1.0e-2;
  const double exp1_x[exp1_P] = { -4.0, -5.0, 4.0, -4.0 }; /* approx */

  gsl_test_rel(sumsq, sumsq_exact, epsrel, "%s/%s sumsq",
               sname, pname);

  for (i = 0; i < exp1_P; ++i)
    {
      gsl_test_rel(x[i], exp1_x[i], epsrel, "%s/%s i="F_ZU,
                   sname, pname, i);
    }
}
Exemple #18
0
static void
beale_checksol(const double x[], const double sumsq,
               const double epsrel, const char *sname,
               const char *pname)
{
  size_t i;
  const double sumsq_exact = 0.0;
  const double beale_x[beale_P] = { 3.0, 0.5 };

  gsl_test_rel(sumsq, sumsq_exact, epsrel, "%s/%s sumsq",
               sname, pname);

  for (i = 0; i < beale_P; ++i)
    {
      gsl_test_rel(x[i], beale_x[i], epsrel, "%s/%s i="F_ZU,
                   sname, pname, i);
    }
}
Exemple #19
0
static void
wood_checksol(const double x[], const double sumsq,
              const double epsrel, const char *sname,
              const char *pname)
{
  size_t i;
  const double sumsq_exact = 0.0;
  const double wood_x[wood_P] = { 1.0, 1.0, 1.0, 1.0 };

  gsl_test_rel(sumsq, sumsq_exact, epsrel, "%s/%s sumsq",
               sname, pname);

  for (i = 0; i < wood_P; ++i)
    {
      gsl_test_rel(x[i], wood_x[i], epsrel, "%s/%s i="F_ZU,
                   sname, pname, i);
    }
}
Exemple #20
0
static void
kowalik_checksol(const double x[], const double sumsq,
                 const double epsrel, const char *sname,
                 const char *pname)
{
  size_t i;
  gsl_vector_const_view v = gsl_vector_const_view_array(x, kowalik_P);
  const double norm = gsl_blas_dnrm2(&v.vector);
  const double sumsq_exact1 = 3.075056038492370e-04;
  const double kowalik_x1[kowalik_P] = { 1.928069345723978e-01,
                                         1.912823290344599e-01,
                                         1.230565070690708e-01,
                                         1.360623308065148e-01 };
  const double sumsq_exact2 = 0.00102734304869549252;
  const double kowalik_x2[kowalik_P] = { GSL_NAN,   /* inf */
                                         -14.0758834005984603,
                                         GSL_NAN,   /* -inf */
                                         GSL_NAN }; /* -inf */
  const double *kowalik_x;
  double sumsq_exact;

  if (norm < 10.0)
    {
      kowalik_x = kowalik_x1;
      sumsq_exact = sumsq_exact1;
    }
  else
    {
      kowalik_x = kowalik_x2;
      sumsq_exact = sumsq_exact2;
    }

  gsl_test_rel(sumsq, sumsq_exact, epsrel, "%s/%s sumsq",
               sname, pname);

  for (i = 0; i < kowalik_P; ++i)
    {
      if (!gsl_finite(kowalik_x[i]))
        continue;

      gsl_test_rel(x[i], kowalik_x[i], epsrel, "%s/%s i="F_ZU,
                   sname, pname, i);
    }
}
Exemple #21
0
static void
powell3_checksol(const double x[], const double sumsq,
                 const double epsrel, const char *sname,
                 const char *pname)
{
  size_t i;
  const double sumsq_exact = 0.0;
  const double powell3_x[powell3_P] = { 1.09815932969975976e-05,
                                        9.10614673986700218 };

  gsl_test_rel(sumsq, sumsq_exact, epsrel, "%s/%s sumsq",
               sname, pname);

  for (i = 0; i < powell3_P; ++i)
    {
      gsl_test_rel(x[i], powell3_x[i], epsrel, "%s/%s i=%zu",
                   sname, pname, i);
    }
}
Exemple #22
0
static void
penalty2_checksol(const double x[], const double sumsq,
                  const double epsrel, const char *sname,
                  const char *pname)
{
  const double sumsq_exact = 9.37629300735544219e-06;

  gsl_test_rel(sumsq, sumsq_exact, epsrel, "%s/%s sumsq",
               sname, pname);
}
Exemple #23
0
static void
boxbod_checksol(const double x[], const double sumsq,
                 const double epsrel, const char *sname,
                 const char *pname)
{
  size_t i;
  const double sumsq_exact = 1.1680088766E+03;
  const double boxbod_x[boxbod_P] = { 2.1380940889E+02,
                                      5.4723748542E-01 };

  gsl_test_rel(sumsq, sumsq_exact, epsrel, "%s/%s sumsq",
               sname, pname);

  for (i = 0; i < boxbod_P; ++i)
    {
      gsl_test_rel(x[i], boxbod_x[i], epsrel, "%s/%s i="F_ZU,
                   sname, pname, i);
    }
}
Exemple #24
0
static void
gaussian_checksol(const double x[], const double sumsq,
                  const double epsrel, const char *sname,
                  const char *pname)
{
  size_t i;
  const double sumsq_exact = 1.12793276961871985e-08;
  const double gaussian_x[gaussian_P] = { 0.398956137838762825,
                                          1.00001908448786647,
                                          0.0 };

  gsl_test_rel(sumsq, sumsq_exact, epsrel, "%s/%s sumsq",
               sname, pname);

  for (i = 0; i < gaussian_P; ++i)
    {
      gsl_test_rel(x[i], gaussian_x[i], epsrel, "%s/%s i=%zu",
                   sname, pname, i);
    }
}
Exemple #25
0
static void
kirby2_checksol(const double x[], const double sumsq,
                const double epsrel, const char *sname,
                const char *pname)
{
  size_t i;
  const double sumsq_exact = 3.9050739624E+00;
  const double kirby2_x[kirby2_P] = {
    1.6745063063E+00, -1.3927397867E-01, 2.5961181191E-03,
   -1.7241811870E-03, 2.1664802578E-05 };

  gsl_test_rel(sumsq, sumsq_exact, epsrel, "%s/%s sumsq",
               sname, pname);

  for (i = 0; i < kirby2_P; ++i)
    {
      gsl_test_rel(x[i], kirby2_x[i], epsrel, "%s/%s i="F_ZU,
                   sname, pname, i);
    }
}
Exemple #26
0
static void
wnlin_checksol(const double x[], const double sumsq,
               const double epsrel, const char *sname,
               const char *pname)
{
  size_t i;
  const double sumsq_exact = 29.7481259665713758;
  const double wnlin_x[wnlin_P] = { 5.17378551196259195,
                                    0.111041758006851149,
                                    1.05282724070446099 };

  gsl_test_rel(sumsq, sumsq_exact, epsrel, "%s/%s sumsq",
               sname, pname);

  for (i = 0; i < wnlin_P; ++i)
    {
      gsl_test_rel(x[i], wnlin_x[i], epsrel, "%s/%s i="F_ZU,
                   sname, pname, i);
    }
}
Exemple #27
0
static void
eckerle_checksol(const double x[], const double sumsq,
                 const double epsrel, const char *sname,
                 const char *pname)
{
  size_t i;
  const double sumsq_exact = 1.4635887487E-03;
  const double eckerle_x[eckerle_P] = { 1.5543827178E+00,
                                        4.0888321754E+00,
                                        4.5154121844E+02 };

  gsl_test_rel(sumsq, sumsq_exact, epsrel, "%s/%s sumsq",
               sname, pname);

  for (i = 0; i < eckerle_P; ++i)
    {
      gsl_test_rel(x[i], eckerle_x[i], epsrel, "%s/%s i="F_ZU,
                   sname, pname, i);
    }
}
Exemple #28
0
void
test_eigenvalues_complex (const gsl_vector_complex * eval,
                          const gsl_vector_complex * eval2, 
                          const char * desc, const char * desc2)
{
  const size_t N = eval->size;
  size_t i;

  for (i = 0; i < N; i++)
    {
      gsl_complex ei = gsl_vector_complex_get (eval, i);
      gsl_complex e2i = gsl_vector_complex_get (eval2, i);
      gsl_test_rel(GSL_REAL(ei), GSL_REAL(e2i), 10*N*GSL_DBL_EPSILON, 
                   "%s, direct eigenvalue(%d) real, %s",
                   desc, i, desc2);
      gsl_test_rel(GSL_IMAG(ei), GSL_IMAG(e2i), 10*N*GSL_DBL_EPSILON, 
                   "%s, direct eigenvalue(%d) imag, %s",
                   desc, i, desc2);
    }
}
Exemple #29
0
static void
rat42_checksol(const double x[], const double sumsq,
                 const double epsrel, const char *sname,
                 const char *pname)
{
  size_t i;
  const double sumsq_exact = 8.0565229338E+00;
  const double rat42_x[rat42_P] = { 7.2462237576E+01,
                                    2.6180768402E+00,
                                    6.7359200066E-02 };

  gsl_test_rel(sumsq, sumsq_exact, epsrel, "%s/%s sumsq",
               sname, pname);

  for (i = 0; i < rat42_P; ++i)
    {
      gsl_test_rel(x[i], rat42_x[i], epsrel, "%s/%s i="F_ZU,
                   sname, pname, i);
    }
}
Exemple #30
0
static void
meyer_checksol(const double x[], const double sumsq,
               const double epsrel, const char *sname,
               const char *pname)
{
  size_t i;
  const double sumsq_exact = 8.794585517053883e+01;
  const double meyer_x[meyer_P] = { 5.609636471049458e-03,
                                    6.181346346283188e+03,
                                    3.452236346240292e+02 };

  gsl_test_rel(sumsq, sumsq_exact, epsrel, "%s/%s sumsq",
               sname, pname);

  for (i = 0; i < meyer_P; ++i)
    {
      gsl_test_rel(x[i], meyer_x[i], epsrel, "%s/%s i=%zu",
                   sname, pname, i);
    }
}