24 #include <lal/LALStdlib.h>
25 #include <lal/Interpolate.h>
68 memcpy (dn, params->
y, n*
sizeof(
REAL4));
69 memcpy (up, params->
y, n*
sizeof(
REAL4));
70 diff = target - params->
x[near = 0];
71 for (i = 1; diff > 0 && i < n; ++i)
73 REAL4 tmp = target - params->
x[i];
74 diff = (fabs(tmp) < fabs(diff) ? near = i, tmp : diff);
86 for (order = 1; order < n; ++order)
88 UINT4 imax = n - order;
89 for (i = 0; i < imax; ++i)
92 REAL4 xup = params->
x[i + order];
93 REAL4 den = xdn - xup;
96 fac = (dn[i + 1] - up[i])/den;
97 dn[i] = fac*(xdn - target);
98 up[i] = fac*(xup - target);
102 output->y += (near < imax ? dn[near] : up[--near]);
105 output->dy = fabs(dn[0]) < fabs(up[0]) ? fabs(dn[0]) : fabs(up[0]);
156 if ( yout == NULL ||
y == NULL ||
x == NULL )
178 memcpy (dn,
y, n*
sizeof(*dn));
179 memcpy (up,
y, n*
sizeof(*up));
180 diff = xtarget -
x[near];
181 for (i = 1; diff > 0 && i < n; ++i)
183 REAL8 tmp = xtarget -
x[i];
184 diff = (fabs(tmp) < fabs(diff) ? near = i, tmp : diff);
196 for (order = 1; order < n; ++order)
198 UINT4 imax = n - order;
199 for (i = 0; i < imax; ++i)
203 REAL8 den = xdn - xup;
211 fac = (dn[i + 1] - up[i])/den;
212 dn[i] = fac*(xdn - xtarget);
213 up[i] = fac*(xup - xtarget);
217 *yout += (near < imax ? dn[near] : up[--near]);
220 dy = fabs(dn[0]) < fabs(up[0]) ? fabs(dn[0]) : fabs(up[0]);
234 const gsl_interp_type *itrp_type
240 gsl_interp_accel *i_acc = gsl_interp_accel_alloc();
249 spline = gsl_spline_alloc(gsl_interp_cspline, n_data_points);
251 spline = gsl_spline_alloc(itrp_type, n_data_points);
253 gsl_spline_init(spline, x_in->
data, y_in->
data, n_data_points);
258 x_min = x_in->
data[0];
260 for(; i<x_out->
length; i++) {
266 if (x_out->
data[i] < x_min || x_out->
data[i] > x_max ) {
267 XLALPrintError(
"XLAL Error - %s: %g is outside the bounds of the interpolant.\n", __func__, x_out->
data[i]);
270 y_out->
data[i] = gsl_spline_eval(spline, x_out->
data[i], i_acc);
276 gsl_spline_free(spline);
277 gsl_interp_accel_free(i_acc);
288 const gsl_interp_type *itrp_type
296 int destroy_t_out = 0;
298 if (ts_in->
deltaT < 0.0) {
299 XLALPrintError(
"XLAL Error - %s: Not enough information in the time series to infer sampling values. Supply proper epoch and deltaT.", __func__);
306 for (; length>=0; length--){
307 t_out->
data[length] = length*ts_in->
deltaT + start;
#define ASSERT(assertion, statusptr, code, mesg)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
int XLALPrintError(const char *fmt,...)
#define INTERPOLATEH_ENULL
Null pointer.
#define INTERPOLATEH_ESIZE
Invalid size.
void LALDPolynomialInterpolation(LALStatus *status, DInterpolateOut *output, REAL8 target, DInterpolatePar *params)
int XLALREAL8TimeSeriesInterpolation(REAL8TimeSeries *ts_in, REAL8Sequence *y_in, REAL8Sequence *t_in, REAL8Sequence *t_out, UINT4 n_data_points, const gsl_interp_type *itrp_type)
void LALSPolynomialInterpolation(LALStatus *status, SInterpolateOut *output, REAL4 target, SInterpolatePar *params)
#define INTERPOLATEH_EZERO
Zero divide.
REAL8 XLALREAL8PolynomialInterpolation(REAL8 *yout, REAL8 xtarget, REAL8 *y, REAL8 *x, UINT4 n)
int XLALREAL8Interpolation(REAL8Sequence *x_in, REAL8Sequence *y_in, REAL8Sequence *x_out, REAL8Sequence *y_out, UINT4 n_data_points, const gsl_interp_type *itrp_type)
double REAL8
Double precision real floating-point number (8 bytes).
uint32_t UINT4
Four-byte unsigned integer.
float REAL4
Single precision real floating-point number (4 bytes).
void XLALDestroyREAL8Sequence(REAL8Sequence *sequence)
REAL8Sequence * XLALCreateREAL8Sequence(size_t length)
#define XLAL_ERROR_REAL8(...)
Macro to invoke a failure from a XLAL routine returning a REAL8.
#define XLAL_ERROR_VAL(val,...)
Macro to invoke the XLALError() function and return with code val (it should not really be used itsel...
#define xlalErrno
Modifiable lvalue containing the XLAL error number.
#define XLAL_PRINT_DEPRECATION_WARNING(replacement)
Prints a deprecation warning at the "warning" verbosity level.
@ XLAL_ENOMEM
Memory allocation error.
@ XLAL_EFAULT
Invalid pointer.
@ XLAL_EINVAL
Invalid argument.
@ XLAL_EFPDIV0
IEEE Division by zero floating point error.
REAL8 XLALGPSGetREAL8(const LIGOTimeGPS *epoch)
Returns the GPS time as a REAL8.
These structures contain the output of the interpolation.
These structures contain the interpolation parameters; These are the arrays of n domain values and t...
REAL8 * y
The array of values to interpolate.
REAL8 * x
The array of domain values.
UINT4 n
The number of points in the arrays to use in the interpolation.
LAL status structure, see The LALStatus structure for more details.
Time series of REAL8 data, see DATATYPE-TimeSeries types for more details.
REAL8Sequence * data
The sequence of sampled data.
REAL8 deltaT
The time step between samples of the time series in seconds.
LIGOTimeGPS epoch
The start time of the time series.
Vector of type REAL8, see DATATYPE-Vector types for more details.
REAL8 * data
Pointer to the data array.
UINT4 length
Number of elements in array.
These structures contain the output of the interpolation.
These structures contain the interpolation parameters; These are the arrays of n domain values and t...
REAL4 * x
The array of domain values.
UINT4 n
The number of points in the arrays to use in the interpolation.
REAL4 * y
The array of values to interpolate.
void output(int gps_sec, int output_type)