X-shooter Pipeline Reference Manual 3.8.15
xsh_utils_polynomial.h
Go to the documentation of this file.
1/*
2 * This file is part of the ESO X-Shooter 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-09 10:05:37 $
23 * $Revision: 1.3 $
24 * $Name: not supported by cvs2svn $
25 *
26 */
27#ifndef XSH_UTILS_POLYNOMIAL_H
28#define XSH_UTILS_POLYNOMIAL_H
29
30/*-----------------------------------------------------------------------------
31 Includes
32 -----------------------------------------------------------------------------*/
33
34//#include <xsh_propertylist.h>
35#include <cpl.h>
36#include <xsh_cpl_size.h>
37/*-----------------------------------------------------------------------------
38 Typedefs
39 -----------------------------------------------------------------------------*/
40
41typedef struct _polynomial polynomial ;
42
43/*-----------------------------------------------------------------------------
44 Prototypes
45 -----------------------------------------------------------------------------*/
46
47
48polynomial *xsh_polynomial_new(const cpl_polynomial *pol);
51
52
54polynomial *xsh_polynomial_collapse(const polynomial *p, int varno, double value);
55polynomial * xsh_polynomial_fit_1d(const cpl_vector * x_pos,
56 const cpl_vector * values,
57 const cpl_vector * sigmas,
58 int poly_deg,
59 double * mse);
60polynomial *xsh_polynomial_fit_2d(const cpl_bivector * xy_pos,
61 const cpl_vector * values,
62 const cpl_vector * sigmas,
63 int poly_deg1,
64 int poly_deg2,
65 double * mse,
66 double * red_chisq,
67 polynomial ** variance);
68
70
72
75
78void xsh_polynomial_dump(const polynomial *p, FILE *stream);
79cpl_error_code xsh_polynomial_shift(polynomial *p, int varno, double shift);
80cpl_error_code xsh_polynomial_rescale(polynomial *p, int varno, double scale);
83 int degree1, int degree2);
84double xsh_polynomial_evaluate_1d(const polynomial *p, double x);
85double xsh_polynomial_evaluate_2d(const polynomial *p, double x1, double x2);
86double xsh_polynomial_solve_1d(const polynomial *p, double value,
87 double guess, int multiplicity);
88double xsh_polynomial_solve_2d(const polynomial *p, double value,
89 double guess, int multiplicity,
90 int varno, double x_value);
91double xsh_polynomial_derivative_1d(const polynomial *p, double x);
92double xsh_polynomial_derivative_2d(const polynomial *p, double x1,
93 double x2, int varno);
94cpl_error_code xsh_polynomial_derivative(polynomial *p, int varno);
95
96#endif
static int degree
int * x
polynomial * xsh_polynomial_new_zero(int dim)
Create a zero polynomial.
polynomial * xsh_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.
void xsh_polynomial_delete(polynomial **p)
Delete a polynomial.
double xsh_polynomial_evaluate_1d(const polynomial *p, double x)
Evaluate a 1d polynomial.
double xsh_polynomial_solve_1d(const polynomial *p, double value, double guess, int multiplicity)
Solve p(x) = value.
polynomial * xsh_polynomial_collapse(const polynomial *p, int varno, double value)
Collapse a polynomial by fixing one variable to a constant.
void xsh_polynomial_delete_const(const polynomial **p)
Delete a const polynomial.
double xsh_polynomial_get_coeff_1d(const polynomial *p, int degree)
Get a coefficient of a 1D polynomial.
double xsh_polynomial_solve_2d(const polynomial *p, double value, double guess, int multiplicity, int varno, double x_value)
Solve p(x1, x2) = value.
polynomial * xsh_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.
cpl_error_code xsh_polynomial_rescale(polynomial *p, int varno, double scale)
Rescale a polynomial.
double xsh_polynomial_derivative_1d(const polynomial *p, double x)
Evaluate the derivative of a 1d polynomial.
polynomial * xsh_polynomial_new(const cpl_polynomial *pol)
Create a polynomial.
polynomial * xsh_polynomial_add_2d(const polynomial *p1, const polynomial *p2)
Add two polynomials.
int xsh_polynomial_get_dimension(const polynomial *p)
Get the dimension of a polynomial.
int xsh_polynomial_get_degree(const polynomial *p)
Get degree.
polynomial * xsh_polynomial_convert_from_table(cpl_table *t)
Convert a table to a polynomial.
double xsh_polynomial_get_coeff_2d(const polynomial *p, int degree1, int degree2)
Get a coefficient of a 2D polynomial.
double xsh_polynomial_derivative_2d(const polynomial *p, double x1, double x2, int varno)
Evaluate the partial derivative of a 2d polynomial.
void xsh_polynomial_dump(const polynomial *p, FILE *stream)
Print a polynomial.
cpl_error_code xsh_polynomial_derivative(polynomial *p, int varno)
Calculate the partial derivative of a polynomial.
cpl_error_code xsh_polynomial_shift(polynomial *p, int varno, double shift)
Shift a polynomial.
cpl_table * xsh_polynomial_convert_to_table(const polynomial *p)
Convert a polynomial to a table.
double xsh_polynomial_evaluate_2d(const polynomial *p, double x1, double x2)
Evaluate a 2d polynomial.
polynomial * xsh_polynomial_duplicate(const polynomial *p)
Copy a polynomial.
cpl_polynomial * pol