Data Structures | |
| struct | _polynomial |
Functions | |
| polynomial * | uves_polynomial_new (const cpl_polynomial *pol) |
| Create a polynomial. | |
| polynomial * | uves_polynomial_new_zero (int dim) |
| Create a zero polynomial. | |
| void | uves_polynomial_delete (polynomial **p) |
| Delete a polynomial. | |
| void | uves_polynomial_delete_const (const polynomial **p) |
| Delete a const polynomial. | |
| int | uves_polynomial_get_degree (const polynomial *p) |
| Get degree. | |
| polynomial * | uves_polynomial_duplicate (const polynomial *p) |
| Copy a polynomial. | |
| cpl_table * | uves_polynomial_convert_to_table (const polynomial *p) |
| Convert a polynomial to a table. | |
| polynomial * | uves_polynomial_convert_from_table (cpl_table *t) |
| Convert a table to a polynomial. | |
| polynomial * | uves_polynomial_convert_from_plist_midas (const uves_propertylist *plist, const char *regression_name) |
| Read a polynomial produced by REGRESSION/POLYNOMIAL (MIDAS). | |
| int | uves_polynomial_get_dimension (const polynomial *p) |
| Get the dimension of a polynomial. | |
| void | uves_polynomial_dump (const polynomial *p, FILE *stream) |
| Print a polynomial. | |
| cpl_error_code | uves_polynomial_rescale (polynomial *p, int varno, double scale) |
| Rescale a polynomial. | |
| cpl_error_code | uves_polynomial_shift (polynomial *p, int varno, double shift) |
| Shift a polynomial. | |
| double | uves_polynomial_evaluate_1d (const polynomial *p, double x) |
| Evaluate a 1d polynomial. | |
| double | uves_polynomial_evaluate_2d (const polynomial *p, double x1, double x2) |
| Evaluate a 2d polynomial. | |
| double | uves_polynomial_solve_1d (const polynomial *p, double value, double guess, int multiplicity) |
| Solve p(x) = value. | |
| double | uves_polynomial_solve_2d (const polynomial *p, double value, double guess, int multiplicity, int varno, double x_value) |
| Solve p(x1, x2) = value. | |
| double | uves_polynomial_derivative_2d (const polynomial *p, double x1, double x2, int varno) |
| Evaluate the partial derivative of a 2d polynomial. | |
| double | uves_polynomial_derivative_1d (const polynomial *p, double x) |
| Evaluate the derivative of a 1d polynomial. | |
| polynomial * | uves_polynomial_add_2d (const polynomial *p1, const polynomial *p2) |
| Add two polynomials. | |
| static cpl_error_code | derivative_cpl_polynomial (cpl_polynomial *p, int varno) |
| Calculate the partial derivative of a CPL-polynomial. | |
| cpl_error_code | uves_polynomial_derivative (polynomial *p, int varno) |
| Calculate the partial derivative of a polynomial. | |
| double | uves_polynomial_get_coeff_2d (const polynomial *p, int degree1, int degree2) |
| Get a coefficient of a 2D polynomial. | |
| double | uves_polynomial_get_coeff_1d (const polynomial *p, int degree) |
| Get a coefficient of a 1D polynomial. | |
| polynomial * | uves_polynomial_collapse (const polynomial *p, int varno, double value) |
| Collapse a polynomial by fixing one variable to a constant. | |
| polynomial * | uves_polynomial_fit_1d (const cpl_vector *x_pos, const cpl_vector *values, const cpl_vector *sigmas, int poly_deg, double *mse) |
| Fit a 1d function with a polynomial. | |
| polynomial * | uves_polynomial_fit_2d (const cpl_bivector *xy_pos, const cpl_vector *values, const cpl_vector *sigmas, int poly_deg1, int poly_deg2, double *mse, double *red_chisq, polynomial **variance) |
| Fit a 2d surface with a polynomial in x and y. | |
This class is a wrapper of CPL's polynomial class, but it improves the accuracy of the fitting routine (related to DFS ticket: DFS02237), and it allows fitting with a 2d polynomial with different degree of the independent variables (which CPL does not support), and also allows propagation of the uncertainty of the fit.
Also, the module adds simple functionalities like shifting a 2d polynomial, collapsing a 2d polynomial to a 1d polynomial, and conversion of a polynomial to/from a CPL table (which can be used for I/O).
The functionality in this module has been implemented only as needed. Therefore, 1) some functionality which "should" to be there (like collapsing a polynomial of any dimension) is missing, but 2) all the functionality present has been tested.
|
|
Create a polynomial.
Definition at line 204 of file uves_utils_polynomial.c. References assure, assure_mem, check, _polynomial::dimension, _polynomial::pol, _polynomial::scale, _polynomial::shift, uves_polynomial_delete(), _polynomial::vec, and _polynomial::vec_data. Referenced by test_polynomial(), uves_polynomial_duplicate(), and uves_polynomial_new_zero(). |
|
|
Create a zero polynomial.
Definition at line 251 of file uves_utils_polynomial.c. References assure, assure_mem, and uves_polynomial_new(). Referenced by test_extract(). |
|
|
Delete a polynomial.
Definition at line 279 of file uves_utils_polynomial.c. References uves_polynomial_delete_const(). Referenced by calibrate_global(), extract_ff_rebin_merge(), test_iterate(), test_load_linetable(), test_polynomial(), test_polynomial_fit_2d(), uves_lt_delete(), uves_physmod_calmap(), uves_polynomial_fit_2d_test(), uves_polynomial_get_coeff_1d(), uves_polynomial_get_coeff_2d(), uves_polynomial_new(), uves_polynomial_regression_1d(), uves_polynomial_regression_2d(), uves_polynomial_solve_2d(), uves_reduce_scired(), uves_response_efficiency(), and uves_wavecal_identify(). |
|
|
Delete a const polynomial.
Definition at line 293 of file uves_utils_polynomial.c. Referenced by uves_polynomial_delete(), and uves_reduce_scired(). |
|
|
Get degree.
Definition at line 312 of file uves_utils_polynomial.c. References assure, and _polynomial::pol. Referenced by uves_polynomial_add_2d(). |
|
|
Copy a polynomial.
Definition at line 331 of file uves_utils_polynomial.c. References assure, check, _polynomial::pol, _polynomial::scale, _polynomial::shift, uves_polynomial_get_dimension(), and uves_polynomial_new(). Referenced by extract_ff_rebin_merge(), uves_extract(), uves_polynomial_get_coeff_1d(), and uves_polynomial_get_coeff_2d(). |
|
|
Convert a polynomial to a table.
uves_polynomial_convert_from_table() .
Definition at line 373 of file uves_utils_polynomial.c. References assure, _polynomial::pol, _polynomial::scale, _polynomial::shift, and uves_polynomial_get_dimension(). Referenced by extract_ff_rebin_merge(). |
|
|
Convert a table to a polynomial.
uves_polynomial_convert_to_table() .
Definition at line 453 of file uves_utils_polynomial.c. References assure, check, uves_msg_debug, and uves_tostring_cpl_type(). |
|
||||||||||||
|
Read a polynomial produced by REGRESSION/POLYNOMIAL (MIDAS).
Definition at line 540 of file uves_utils_polynomial.c. References assure, check, uves_msg_debug, uves_propertylist_get_const(), and uves_propertylist_get_size(). Referenced by create_order_table(). |
|
|
Get the dimension of a polynomial.
Definition at line 714 of file uves_utils_polynomial.c. References assure, and _polynomial::dimension. Referenced by compute_lambda(), uves_draw_lines(), uves_extract(), uves_polynomial_add_2d(), uves_polynomial_collapse(), uves_polynomial_convert_to_table(), uves_polynomial_derivative(), uves_polynomial_derivative_1d(), uves_polynomial_derivative_2d(), uves_polynomial_dump(), uves_polynomial_duplicate(), uves_polynomial_evaluate_1d(), uves_polynomial_get_coeff_1d(), uves_polynomial_get_coeff_2d(), uves_polynomial_rescale(), uves_polynomial_shift(), and uves_polynomial_solve_1d(). |
|
||||||||||||
|
Print a polynomial.
Definition at line 735 of file uves_utils_polynomial.c. References _polynomial::pol, _polynomial::scale, _polynomial::shift, and uves_polynomial_get_dimension(). |
|
||||||||||||||||
|
Rescale a polynomial.
If varno is zero, a the polynomial itself is rescaled: p(x) := p(x) * scale . Negative values of varno are illegal. Definition at line 768 of file uves_utils_polynomial.c. References assure, _polynomial::scale, _polynomial::shift, and uves_polynomial_get_dimension(). Referenced by test_polynomial(). |
|
||||||||||||||||
|
Shift a polynomial.
If varno is zero, a constant is added to the polynomial: p(x) := p(x) + shift . Negative values of varno are illegal. Definition at line 809 of file uves_utils_polynomial.c. References assure, _polynomial::shift, and uves_polynomial_get_dimension(). Referenced by test_extract(). |
|
||||||||||||
|
Evaluate a 1d polynomial.
uves_polynomial_evaluate_2d() .
Definition at line 841 of file uves_utils_polynomial.c. References assure, check, _polynomial::pol, _polynomial::scale, _polynomial::shift, and uves_polynomial_get_dimension(). Referenced by fit_order_linear(), opt_get_redchisq(), uves_polynomial_get_coeff_1d(), and uves_polynomial_regression_1d(). |
|
||||||||||||||||
|
Evaluate a 2d polynomial.
uves_polynomial_evaluate_1d() .
Definition at line 872 of file uves_utils_polynomial.c. References assure, _polynomial::dimension, _polynomial::pol, _polynomial::scale, _polynomial::shift, _polynomial::vec, and _polynomial::vec_data. Referenced by compute_lambda(), detect_lines(), extract_order_simple(), get_offset(), opt_get_order_width(), opt_get_redchisq(), repeat_orderdef(), test_polynomial_fit_2d(), uves_draw_lines(), uves_iterate_increment(), uves_iterate_set_first(), uves_physmod_msrawxy(), uves_polynomial_fit_2d_test(), uves_polynomial_get_coeff_2d(), and uves_polynomial_regression_2d(). |
|
||||||||||||||||||||
|
Solve p(x) = value.
cpl_polynomial_solve_1d() to solve the equation p (x) = value . See cpl_polynomial_solve_1d() for a description of the algorithm.
Definition at line 910 of file uves_utils_polynomial.c. References assure, check, _polynomial::pol, _polynomial::scale, _polynomial::shift, and uves_polynomial_get_dimension(). Referenced by uves_polynomial_solve_2d(), and uves_response_efficiency(). |
|
||||||||||||||||||||||||||||
|
Solve p(x1, x2) = value.
For example, to solve the equation p (37, x) = 500 for x, call Definition at line 964 of file uves_utils_polynomial.c. References assure, check, uves_polynomial_collapse(), uves_polynomial_delete(), and uves_polynomial_solve_1d(). Referenced by opt_get_order_width(), and uves_draw_lines(). |
|
||||||||||||||||||||
|
Evaluate the partial derivative of a 2d polynomial.
Definition at line 995 of file uves_utils_polynomial.c. References assure, _polynomial::pol, _polynomial::scale, _polynomial::shift, and uves_polynomial_get_dimension(). Referenced by compute_lambda(), detect_ripples(), and uves_response_efficiency(). |
|
||||||||||||
|
Evaluate the derivative of a 1d polynomial.
Definition at line 1084 of file uves_utils_polynomial.c. References assure, check, _polynomial::pol, _polynomial::scale, _polynomial::shift, and uves_polynomial_get_dimension(). |
|
||||||||||||
|
Add two polynomials.
Definition at line 1109 of file uves_utils_polynomial.c. References assure, uves_max_int(), uves_polynomial_get_coeff_2d(), uves_polynomial_get_degree(), and uves_polynomial_get_dimension(). Referenced by test_polynomial(). |
|
||||||||||||
|
Calculate the partial derivative of a CPL-polynomial.
1D and 2D polynomials are supported. Definition at line 1174 of file uves_utils_polynomial.c. References assure. Referenced by uves_polynomial_derivative(). |
|
||||||||||||
|
Calculate the partial derivative of a polynomial.
Definition at line 1240 of file uves_utils_polynomial.c. References assure, check, derivative_cpl_polynomial(), _polynomial::pol, _polynomial::scale, _polynomial::shift, and uves_polynomial_get_dimension(). Referenced by uves_polynomial_get_coeff_1d(), and uves_polynomial_get_coeff_2d(). |
|
||||||||||||||||
|
Get a coefficient of a 2D polynomial.
Definition at line 1283 of file uves_utils_polynomial.c. References assure, check, uves_polynomial_delete(), uves_polynomial_derivative(), uves_polynomial_duplicate(), uves_polynomial_evaluate_2d(), and uves_polynomial_get_dimension(). Referenced by test_polynomial(), test_polynomial_fit_2d(), uves_physmod_msrawxy(), and uves_polynomial_add_2d(). |
|
||||||||||||
|
Get a coefficient of a 1D polynomial.
Definition at line 1339 of file uves_utils_polynomial.c. References assure, check, uves_polynomial_delete(), uves_polynomial_derivative(), uves_polynomial_duplicate(), uves_polynomial_evaluate_1d(), and uves_polynomial_get_dimension(). Referenced by fit_order_linear(), and uves_physmod_calmap(). |
|
||||||||||||||||
|
Collapse a polynomial by fixing one variable to a constant.
Currently, only n=2 is supported. Definition at line 1394 of file uves_utils_polynomial.c. References assure, assure_mem, _polynomial::pol, _polynomial::scale, _polynomial::shift, and uves_polynomial_get_dimension(). Referenced by uves_polynomial_solve_2d(), and uves_response_efficiency(). |
|
||||||||||||||||||||||||
|
Fit a 1d function with a polynomial.
cpl_polynomial_fit_1d_create() . But before performing the fit, all values are shifted, so that they are centered around zero. This improves the accuracy of the fit.Also, there's support for taking into account the uncertainties of the dependent variable.
See also Definition at line 1500 of file uves_utils_polynomial.c. References assure, assure_nomsg, and uves_pow_int(). Referenced by uves_polynomial_regression_1d(). |
|
||||||||||||||||||||||||||||||||||||
|
Fit a 2d surface with a polynomial in x and y.
This function is an adaption of CPL's And before performing the fit, all values are shifted, so that they are centered around zero, which improves the accuracy of the fit. Rescaling with stdev makes the fit worse (empirically) so this is not done. If mse is non-NULL, the mean squared error of the fit is returned through this variable. If red_chisq is non-NULL, the reduced chi square of the fit is returned through this variable. If variance is non-NULL the variance polynomial defined as (using the error propagation formula for correlated coefficients {coeff_i}) variance(x,y) = sum_{ij} d(p_fit)/d(coeff_i) * cov_{ij} * d(p_fit)/d(coeff_j) = sum_{ij} x^degx[i]*y^degy[i] * cov_{ij} * x^degx[j]*y^degy[j] = sum_{ij} cov_{ij} * x^(degx[i]+degx[j]) * y^(degy[i]+degy[j]) will be returned through this variable (i.e. the parameter must be the address of a (polynomial*) variable. The variance polynomial gives the associated uncertainty when evaluating the fitted polynomial, i.e. the variance of p_fit(x, y) = sum_{ij} (a_{ij} * x^i * y^j)
See also Definition at line 1680 of file uves_utils_polynomial.c. References assure, and assure_mem. Referenced by test_polynomial_fit_2d(), uves_polynomial_fit_2d_test(), and uves_polynomial_regression_2d(). |
1.4.6