UVES Pipeline Reference Manual  5.4.6
uves_utils_polynomial.h
1 /*
2  * This file is part of the ESO UVES Pipeline
3  * Copyright (C) 2004,2005 European Southern Observatory
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
18  */
19 
20 /*
21  * $Author: amodigli $
22  * $Date: 2011-12-08 13:54:13 $
23  * $Revision: 1.25 $
24  * $Name: not supported by cvs2svn $
25  * $Log: not supported by cvs2svn $
26  * Revision 1.24 2010/09/24 09:32:09 amodigli
27  * put back QFITS dependency to fix problem spot by NRI on FIBER mode (with MIDAS calibs) data
28  *
29  * Revision 1.22 2007/09/11 17:08:49 amodigli
30  * mooved uves_polynomial_convert_from_plist_midas to uves_dfs
31  *
32  * Revision 1.21 2007/06/20 08:30:03 amodigli
33  * added index parameter to support FIBER mode lintab in uves_polynomial_convert_from_plist_midas
34  *
35  * Revision 1.20 2007/06/06 08:17:33 amodigli
36  * replace tab with 4 spaces
37  *
38  * Revision 1.19 2007/05/03 15:18:31 jmlarsen
39  * Added function to add polynomials
40  *
41  * Revision 1.18 2007/04/24 12:50:29 jmlarsen
42  * Replaced cpl_propertylist -> uves_propertylist which is much faster
43  *
44  * Revision 1.17 2007/03/19 15:04:57 jmlarsen
45  * Added get_degree function
46  *
47  * Revision 1.16 2007/03/05 10:20:51 jmlarsen
48  * Added uves_polynomial_delete_const()
49  *
50  * Revision 1.15 2006/08/17 13:56:53 jmlarsen
51  * Reduced max line length
52  *
53  * Revision 1.14 2006/04/24 09:28:29 jmlarsen
54  * Added function to create zero-polynomial
55  *
56  * Revision 1.13 2005/12/19 16:17:56 jmlarsen
57  * Replaced bool -> int
58  *
59  */
60 #ifndef UVES_UTILS_POLYNOMIAL_H
61 #define UVES_UTILS_POLYNOMIAL_H
62 
63 /*-----------------------------------------------------------------------------
64  Includes
65  -----------------------------------------------------------------------------*/
66 
67 #include <uves_propertylist.h>
68 #include <cpl.h>
69 #include <uves_cpl_size.h>
70 /*-----------------------------------------------------------------------------
71  Typedefs
72  -----------------------------------------------------------------------------*/
73 
74 typedef struct _polynomial polynomial ;
75 
76 /*-----------------------------------------------------------------------------
77  Prototypes
78  -----------------------------------------------------------------------------*/
79 
80 
81 polynomial *uves_polynomial_new(const cpl_polynomial *pol);
84 
85 
87 polynomial *uves_polynomial_collapse(const polynomial *p, int varno, double value);
88 polynomial * uves_polynomial_fit_1d(const cpl_vector * x_pos,
89  const cpl_vector * values,
90  const cpl_vector * sigmas,
91  int poly_deg,
92  double * mse);
93 polynomial *uves_polynomial_fit_2d(const cpl_bivector * xy_pos,
94  const cpl_vector * values,
95  const cpl_vector * sigmas,
96  int poly_deg1,
97  int poly_deg2,
98  double * mse,
99  double * red_chisq,
100  polynomial ** variance);
101 
103 
105 
108 
109 cpl_table *uves_polynomial_convert_to_table(const polynomial *p);
111 void uves_polynomial_dump(const polynomial *p, FILE *stream);
112 cpl_error_code uves_polynomial_shift(polynomial *p, int varno, double shift);
113 cpl_error_code uves_polynomial_rescale(polynomial *p, int varno, double scale);
114 double uves_polynomial_get_coeff_1d(const polynomial *p, int degree);
116  int degree1, int degree2);
117 double uves_polynomial_evaluate_1d(const polynomial *p, double x);
118 double uves_polynomial_evaluate_2d(const polynomial *p, double x1, double x2);
119 double uves_polynomial_solve_1d(const polynomial *p, double value,
120  double guess, int multiplicity);
121 double uves_polynomial_solve_2d(const polynomial *p, double value,
122  double guess, int multiplicity,
123  int varno, double x_value);
124 double uves_polynomial_derivative_1d(const polynomial *p, double x);
125 double uves_polynomial_derivative_2d(const polynomial *p, double x1,
126  double x2, int varno);
127 cpl_error_code uves_polynomial_derivative(polynomial *p, int varno);
128 
129 #endif
int uves_polynomial_get_dimension(const polynomial *p)
Get the dimension of a 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.
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_1d(const polynomial *p, double x)
Evaluate the derivative of a 1d polynomial.
void uves_polynomial_delete(polynomial **p)
Delete a polynomial.
cpl_error_code uves_polynomial_derivative(polynomial *p, int varno)
Calculate the partial derivative of a polynomial.
polynomial * uves_polynomial_add_2d(const polynomial *p1, const polynomial *p2)
Add two polynomials.
polynomial * uves_polynomial_convert_from_table(cpl_table *t)
Convert a table to a polynomial.
cpl_table * uves_polynomial_convert_to_table(const polynomial *p)
Convert a polynomial to a table.
cpl_polynomial * pol
double uves_polynomial_get_coeff_2d(const polynomial *p, int degree1, int degree2)
Get a coefficient of a 2D polynomial.
double uves_polynomial_derivative_2d(const polynomial *p, double x1, double x2, int varno)
Evaluate the partial derivative of a 2d polynomial.
int uves_polynomial_get_degree(const polynomial *p)
Get degree.
polynomial * uves_polynomial_duplicate(const polynomial *p)
Copy a polynomial.
void uves_polynomial_delete_const(const polynomial **p)
Delete a const polynomial.
cpl_error_code uves_polynomial_rescale(polynomial *p, int varno, double scale)
Rescale a polynomial.
polynomial * uves_polynomial_new(const cpl_polynomial *pol)
Create a polynomial.
double uves_polynomial_evaluate_2d(const polynomial *p, double x1, double x2)
Evaluate a 2d polynomial.
double uves_polynomial_evaluate_1d(const polynomial *p, double x)
Evaluate a 1d polynomial.
double uves_polynomial_get_coeff_1d(const polynomial *p, int degree)
Get a coefficient of a 1D polynomial.
void uves_polynomial_dump(const polynomial *p, FILE *stream)
Print a polynomial.
cpl_error_code uves_polynomial_shift(polynomial *p, int varno, double shift)
Shift a polynomial.
polynomial * uves_polynomial_new_zero(int dim)
Create a zero polynomial.
double uves_polynomial_solve_1d(const polynomial *p, double value, double guess, int multiplicity)
Solve p(x) = value.
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.