Ignore:
Timestamp:
Dec 14, 2008, 11:13:48 PM (12 years ago)
Author:
Jari Häkkinen
Message:

Addresses #466. Added checks for GSL errors, improved docs, added some more tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/regression/GSLInterpolation.cc

    r1648 r1650  
    3434                                     const utility::VectorBase& x,
    3535                                     const utility::VectorBase& y)
     36    : evaluation_(0.0), gsl_status_(0)
    3637  {
    3738    assert(x.size()==y.size());
     
    4445    }
    4546    interpolator_ = gsl_interp_alloc(interpolator_type, size);
    46     gsl_interp_init(interpolator_, x_, y_, size);
     47    gsl_status_=gsl_interp_init(interpolator_, x_, y_, size);
    4748    accelerator_ = gsl_interp_accel_alloc();
    4849  }
     
    6566
    6667
     68  int GSLInterpolation::error_status(void) const
     69  {
     70    return gsl_status_;
     71  }
     72
     73
    6774  double GSLInterpolation::evaluate(double x)
    68   {
    69     return gsl_interp_eval(interpolator_, x_, y_, x, accelerator_);
     75  {
     76    gsl_status_=gsl_interp_eval_e(interpolator_, x_, y_, x, accelerator_,
     77                                  &evaluation_);
     78    return evaluation_;
    7079  }
    7180
     
    7382  double GSLInterpolation::evaluate_derivative(double x)
    7483  {
    75     return gsl_interp_eval_deriv(interpolator_, x_, y_, x, accelerator_);
     84    gsl_status_=gsl_interp_eval_deriv_e(interpolator_, x_, y_, x, accelerator_,
     85                                        &evaluation_);
     86    return evaluation_;
    7687  }
    7788
     
    7990  double GSLInterpolation::evaluate_derivative2(double x)
    8091  {
    81     return gsl_interp_eval_deriv2(interpolator_, x_, y_, x, accelerator_);
     92    gsl_status_=gsl_interp_eval_deriv2_e(interpolator_, x_, y_, x, accelerator_,
     93                                         &evaluation_);
     94    return evaluation_;
    8295  }
    8396
     
    8598  double GSLInterpolation::evaluate_integral(double a, double b)
    8699  {
    87     return gsl_interp_eval_integ(interpolator_, x_, y_, a, b, accelerator_);
     100    gsl_status_=gsl_interp_eval_integ_e(interpolator_, x_, y_, a, b,
     101                                        accelerator_, &evaluation_);
     102    return evaluation_;
     103  }
     104
     105
     106  double GSLInterpolation::evaluation(void) const
     107  {
     108    return evaluation_;
    88109  }
    89110
Note: See TracChangeset for help on using the changeset viewer.