Added some more methods to Interpolate (constness of compute and getYi)
This commit is contained in:
parent
6d410dc129
commit
c5464dce31
3 changed files with 36 additions and 9 deletions
|
@ -49,6 +49,28 @@ double Interpolate::compute(double x)
|
|||
return y;
|
||||
}
|
||||
|
||||
double Interpolate::compute(double x) const
|
||||
throw (InvalidRangeException)
|
||||
{
|
||||
double y;
|
||||
|
||||
if (logx)
|
||||
x = log(x);
|
||||
|
||||
int err = gsl_spline_eval_e(spline, x, 0, &y);
|
||||
|
||||
if (err)
|
||||
throw InvalidRangeException("Interpolate argument outside range");
|
||||
|
||||
if (logy)
|
||||
return exp(y);
|
||||
else
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
double Interpolate::derivative(double x)
|
||||
throw (InvalidRangeException)
|
||||
{
|
||||
|
|
|
@ -21,6 +21,8 @@ namespace CosmoTool
|
|||
|
||||
double compute(double x)
|
||||
throw (InvalidRangeException);
|
||||
double compute(double x) const
|
||||
throw (InvalidRangeException);
|
||||
double derivative(double x)
|
||||
throw (InvalidRangeException);
|
||||
|
||||
|
@ -30,6 +32,7 @@ namespace CosmoTool
|
|||
void fillWithXY(double *x, double *y) const;
|
||||
double getMaxX() const;
|
||||
double getXi(int i) const { return spline->x[i]; }
|
||||
double getYi(int i) const { return spline->y[i]; }
|
||||
protected:
|
||||
gsl_interp_accel *accel_interp;
|
||||
gsl_spline *spline;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue