34 #ifndef RPOLATOR_H__LOADED 35 #define RPOLATOR_H__LOADED 1 37 #define WITH_RPOLATOR 1 80 int logs, xlog, ylog,
zlog;
87 int read_table(
const char *
fname,
int maxrow,
double *col1,
double *col2);
88 int read_table2(
const char *
fname,
int maxrow,
double *col1,
double *col2);
89 int read_table3(
const char *
fname,
int maxrow,
double *col1,
double *col2,
double *col3);
90 int read_table4(
const char *
fname,
int maxrow,
double *col1,
double *col2,
double *col3,
double *col4);
91 int read_table5(
const char *
fname,
int maxrow,
double *col1,
double *col2,
double *col3,
double *col4,
double *col5);
93 int read_table_v(
const char *
fname, FILE *fptr,
size_t *nrow,
size_t ncol,
double ***col,
const size_t *selcol);
108 void rpol_check_equi_range(
struct rpol_table *rpt);
110 double rpol(
double *
x,
double *
y,
int n,
double xp);
111 double rpol_nearest(
double *
x,
double *
y,
int n,
double xp,
int eq,
int clip);
112 double rpol_linear(
double *
x,
double *
y,
int n,
double xp,
int eq,
int clip);
113 double rpol_2nd_order(
double *
x,
double *
y,
int n,
double xp,
int eq,
int clip);
116 double rpol_2d_linear(
double *
x,
double *
y,
double *
z,
int nx,
int ny,
double xp,
double yp,
int eq,
int clip);
struct rpol_table * read_rpol_table(const char *fname, int nd, const char *ymarker, const char *options)
General function for loading interpolation table combines 1-D and 2-D grid case.
Definition: rpolator.c:1101
int ndim
1 or 2 dimension(s), for the independent variable(s) that is.
Definition: rpolator.h:55
double ymax
Range covered in y (if ndim=2)
Definition: rpolator.h:66
double xrise
+1 if x values are in ascending order; -1 for descending
Definition: rpolator.h:65
double d
r=xp-x[i], yp = a + b*r + c*r^2 + d*r^3 = ((d*r + c) * r + b) * r + a;
Definition: rpolator.h:47
int scheme
Requested interpolation scheme (0: nearest, 1: linear, 2: quadratic, 3: natural cubic spline,...
Definition: rpolator.h:73
CsplinePar * set_1d_cubic_params(double *x, double *y, int n, int clamped)
Set up cubic spline parameters for n-1 intervals resulting from n data points.
Definition: rpolator.c:2651
int read_table_v(const char *fname, FILE *fptr, size_t *nrow, size_t ncol, double ***col, const size_t *selcol)
Read tables any length (up to some ridiculous maximum) with the requested columns either in natural o...
Definition: rpolator.c:343
double rpolate(struct rpol_table *rpt, double x, double y, int scheme)
High-level interpolation function (user code only has to keep a pointer to the allocated object) gene...
Definition: rpolator.c:3199
int rpol_set_verbose(int lvl)
Set the verbosity level for the rpolator code, return old level.
Definition: rpolator.c:608
struct rpol_table * simple_rpol1d_table(const char *label, double *x, double *y, int n, int clip)
A simplified way of setting up a 1-D rpol table for local use, without reading any files.
Definition: rpolator.c:2133
int read_table(const char *fname, int maxrow, double *col1, double *col2)
Low-level reading of 2-column data tables up to given number of data rows.
Definition: rpolator.c:102
int use_count
Indicates how often a table is in use, but not safe enough to make it a smart pointer.
Definition: rpolator.h:82
double zmax
Range covered in result values.
Definition: rpolator.h:69
double rpolate_1d_lin(struct rpol_table *rpt, double x)
High-level interpolation function (user code only has to keep a pointer to the allocated object) limi...
Definition: rpolator.c:3079
double dyi
Step size in y and inverse of it, for equidistant only (2-D).
Definition: rpolator.h:67
char * options
Options used in option parameter or NULL pointer.
Definition: rpolator.h:71
double rpolate_2d(struct rpol_table *rpt, double x, double y, int scheme)
High-level interpolation function (user code only has to keep a pointer to the allocated object) limi...
Definition: rpolator.c:3102
double * x
Supporting points in x.
Definition: rpolator.h:57
double rpol_cspline(double *x, double *y, const CsplinePar *csp, int n, double xp, int eq, int clip)
Cubic spline interpolation in 1-D with clipping option outside range.
Definition: rpolator.c:2779
char * fname
Name of the file from which the table was loaded (includes all options).
Definition: rpolator.h:70
double aux
This auxiliary value may be useful to the application but is not used internally.
Definition: rpolator.h:62
Structure describing an interpolation table, interpolation scheme and selected options.
Definition: rpolator.h:53
double rpol_2nd_order(double *x, double *y, int n, double xp, int eq, int clip)
Second/third order interpolation in 1-D with clipping option outside range.
Definition: rpolator.c:2492
double xmax
Range covered in x.
Definition: rpolator.h:63
int equidistant
Equidistant support points make life much easier (bit 0: x, bit 1: y).
Definition: rpolator.h:72
CsplinePar * csp
Cubic spline parameters (scheme 3 and 4 only), need one-time initialisation.
Definition: rpolator.h:81
int rpol_is_verbose(void)
Report what verbosity level is set for the rpolator code.
Definition: rpolator.c:592
double yrise
+1 if y values are in ascending order; -1 for descending
Definition: rpolator.h:68
int remapped
If user code remaps x, y, and/or z values w.r.t.
Definition: rpolator.h:76
int clipping
0: Extrapolate with edge value, 1: zero outside range.
Definition: rpolator.h:75
double rpolate_1d(struct rpol_table *rpt, double x, int scheme)
High-level interpolation function (user code only has to keep a pointer to the allocated object) limi...
Definition: rpolator.c:2966
struct rpol_table * read_rpol1d_table(const char *fn)
Simplified version for loading a 1-d table with two columns.
Definition: rpolator.c:546
double * zxmin
Optional min.
Definition: rpolator.h:61
Cubic spline interpolation (natural cubic splines = scheme 3, clampled cubic splines = scheme 4)
Definition: rpolator.h:45
int read_table3(const char *fname, int maxrow, double *col1, double *col2, double *col3)
read_table3() and so on have more columns than read_table but are still only suitable for 1-D interpo...
Definition: rpolator.c:162
double rpol_linear(double *x, double *y, int n, double xp, int eq, int clip)
Linear interpolation in 1-D with with either direct access for equidistant table or with binary searc...
Definition: rpolator.c:2412
double * y
Supporting points in y (if ndim=2 and ny>1)
Definition: rpolator.h:58
double rpol_2d_linear(double *x, double *y, double *z, int nx, int ny, double xp, double yp, int eq, int clip)
Linear interpolation in 2-D.
Definition: rpolator.c:2841
double rpol_nearest(double *x, double *y, int n, double xp, int eq, int clip)
Nearest value (not actually interpolation) in 1-D with with either direct access for equidistant tabl...
Definition: rpolator.c:2336
struct rpol_table * read_rpol3d_table(const char *fn)
Simplified version for loading a 2-d table with x/y/z in three columns (x/y intervals rectangular).
Definition: rpolator.c:585
void rpol_info(struct rpol_table *rpt)
Show information about given interpolation table.
Definition: rpolator.c:621
double * z
Table values (size nx for 1-dim or nx*ny for 2-dim)
Definition: rpolator.h:59
size_t ny
No.
Definition: rpolator.h:56
double * zxmax
Optional max.
Definition: rpolator.h:60
struct rpol_table * read_rpol2d_table(const char *fn, const char *ymarker)
Simplified version for loading a 2-d table 1+ny columns (ny=available y values in header line).
Definition: rpolator.c:564
int zxreq
Flag activated when options indicate that a set of zxmax values should be provided.
Definition: rpolator.h:79
double rpol(double *x, double *y, int n, double xp)
Linear interpolation with binary search algorithm.
Definition: rpolator.c:2299
int zlog
Log applied to any x/y axis, to x axis, y axis, z axis?
Definition: rpolator.h:80
double dxi
Step size in x and inverse of it, for equidistant only.
Definition: rpolator.h:64
void rpol_free(struct rpol_table *rpt, int removing)
Free a previously allocated interpolation table data structure.
Definition: rpolator.c:778
void rpol_info_lvl(struct rpol_table *rpt, int lvl)
Report table info at given temporary verbosity level.
Definition: rpolator.c:759