22static double x_offset = 0;
23static double x_scale = 1;
44 if (!(x_scale = scale))
45 bomb(
"argument scale factor is zero", NULL);
73 x = (x - x_offset) / x_scale;
74 if (x > 1 || x < -1) {
79 return (cos(n * acos(x)));
93 x = (x - x_offset) / x_scale;
94 if (x > 1 || x < -1) {
99 if (x != 1 && x != -1)
100 return (n * sin(n * acos(x)) / sqrt(1 - sqr(x)));
101 return (1.0 * n * n);
114 x = (x - x_offset) / x_scale;
128 x = (x - x_offset) / x_scale;
129 return (n *
ipow(x, n - 1));
145double eval_sum(
double (*fn)(
double x,
long ord),
double *coef, int32_t *order,
146 long n_coefs,
double x0) {
150 for (i = sum = 0; i < n_coefs; i++)
151 sum += (fn)(x0, order[i]) * coef[i];
void bomb(char *error, char *usage)
Reports error messages to the terminal and aborts the program.
double ipow(const double x, const int64_t p)
Compute x raised to the power p (x^p).
void set_argument_scale(double scale)
Set the scale factor applied to the input argument of basis functions.
double dtcheby(double x, long n)
Evaluate the derivative of the Chebyshev polynomial T_n(x).
void set_argument_offset(double offset)
Set the offset applied to the input argument of basis functions.
double ipower(double x, long n)
Evaluate a power function x^n.
double get_argument_offset()
Get the current argument offset applied before function evaluations.
double dipower(double x, long n)
Evaluate the derivative of x^n.
double tcheby(double x, long n)
Evaluate the Chebyshev polynomial of the first kind T_n(x).
double get_argument_scale()
Get the current argument scale factor used before function evaluations.
double eval_sum(double(*fn)(double x, long ord), double *coef, int32_t *order, long n_coefs, double x0)
Evaluate a sum of basis functions.