SDDSlib
|
Basis functions for Least Squares Fits (LSFs) using ordinary and Chebyshev polynomials. More...
#include "mdb.h"
Go to the source code of this file.
Functions | |
void | set_argument_offset (double offset) |
Set the offset applied to the input argument of basis functions. | |
void | set_argument_scale (double scale) |
Set the scale factor applied to the input argument of basis functions. | |
double | get_argument_offset () |
Get the current argument offset applied before function evaluations. | |
double | get_argument_scale () |
Get the current argument scale factor used before function evaluations. | |
double | tcheby (double x, long n) |
Evaluate the Chebyshev polynomial of the first kind T_n(x). | |
double | dtcheby (double x, long n) |
Evaluate the derivative of the Chebyshev polynomial T_n(x). | |
double | ipower (double x, long n) |
Evaluate a power function x^n. | |
double | dipower (double x, long n) |
Evaluate the derivative of x^n. | |
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. | |
Variables | |
static double | x_offset = 0 |
static double | x_scale = 1 |
Basis functions for Least Squares Fits (LSFs) using ordinary and Chebyshev polynomials.
This file provides a set of functions for evaluating basis functions and their derivatives for least squares fitting. It includes functions to set and retrieve scaling offsets, as well as polynomial and Chebyshev polynomial basis functions and their derivatives.
Definition in file lsfBasisFns.c.
double dipower | ( | double | x, |
long | n ) |
Evaluate the derivative of x^n.
This function returns d/dx [ (x - x_offset)/x_scale ]^n = n * ((x - x_offset)/x_scale)^(n-1) / x_scale.
x | The point at which to evaluate the derivative. |
n | The exponent. |
Definition at line 127 of file lsfBasisFns.c.
double dtcheby | ( | double | x, |
long | n ) |
Evaluate the derivative of the Chebyshev polynomial T_n(x).
This function returns d/dx [T_n((x - x_offset)/x_scale)]. If x is out of the domain [-1,1], it is clipped to ±1 before evaluation.
x | The point at which to evaluate the derivative of T_n. |
n | The order of the Chebyshev polynomial. |
Definition at line 92 of file lsfBasisFns.c.
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.
Given a pointer to a function that evaluates a basis function fn(x,order), this function computes the weighted sum of these functions at x0 using the provided coefficients.
fn | A pointer to the basis function to evaluate (fn(x, order)). |
coef | An array of coefficients for each basis function. |
order | An array of orders corresponding to each coefficient. |
n_coefs | The number of coefficients (and basis functions). |
x0 | The point at which to evaluate the sum. |
Definition at line 145 of file lsfBasisFns.c.
double get_argument_offset | ( | ) |
Get the current argument offset applied before function evaluations.
Definition at line 53 of file lsfBasisFns.c.
double get_argument_scale | ( | ) |
Get the current argument scale factor used before function evaluations.
Definition at line 60 of file lsfBasisFns.c.
double ipower | ( | double | x, |
long | n ) |
Evaluate a power function x^n.
This function returns ( (x - x_offset)/x_scale )^n.
x | The point at which to evaluate the power. |
n | The exponent. |
Definition at line 113 of file lsfBasisFns.c.
void set_argument_offset | ( | double | offset | ) |
Set the offset applied to the input argument of basis functions.
This function updates the global variable used to shift the input argument before evaluating polynomial or Chebyshev functions.
offset | The new offset to apply to the argument. |
Definition at line 33 of file lsfBasisFns.c.
void set_argument_scale | ( | double | scale | ) |
Set the scale factor applied to the input argument of basis functions.
This function updates the global variable used to scale the input argument before evaluating polynomial or Chebyshev functions. It ensures the scale factor is not zero.
scale | The new scale factor for the argument. |
Definition at line 43 of file lsfBasisFns.c.
double tcheby | ( | double | x, |
long | n ) |
Evaluate the Chebyshev polynomial of the first kind T_n(x).
Given x and an order n, this function returns T_n((x - x_offset) / x_scale). If x is out of the domain [-1,1], it is clipped to ±1 before evaluation.
x | The point at which to evaluate the Chebyshev polynomial. |
n | The order of the Chebyshev polynomial. |
Definition at line 72 of file lsfBasisFns.c.
|
static |
Definition at line 22 of file lsfBasisFns.c.
|
static |
Definition at line 23 of file lsfBasisFns.c.