| 1 |
2 |
bertin |
/*
|
| 2 |
|
|
poly.h
|
| 3 |
|
|
|
| 4 |
|
|
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
| 5 |
|
|
*
|
| 6 |
|
|
* Part of: A program using polynomial fits
|
| 7 |
|
|
*
|
| 8 |
|
|
* Author: E.BERTIN (IAP)
|
| 9 |
|
|
*
|
| 10 |
|
|
* Contents: Include for poly.c
|
| 11 |
|
|
*
|
| 12 |
|
|
* Last modify: 03/03/2004
|
| 13 |
|
|
*
|
| 14 |
|
|
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
| 15 |
|
|
*/
|
| 16 |
|
|
|
| 17 |
|
|
#ifndef _POLY_H_
|
| 18 |
|
|
#define _POLY_H_
|
| 19 |
|
|
|
| 20 |
|
|
/*--------------------------------- constants -------------------------------*/
|
| 21 |
|
|
|
| 22 |
|
|
#define POLY_MAXDIM 4 /* Max dimensionality of polynom */
|
| 23 |
|
|
#define POLY_MAXDEGREE 10 /* Max degree of the polynom */
|
| 24 |
|
|
|
| 25 |
|
|
/*---------------------------------- macros ---------------------------------*/
|
| 26 |
|
|
|
| 27 |
|
|
/*--------------------------- structure definitions -------------------------*/
|
| 28 |
|
|
|
| 29 |
|
|
typedef struct poly
|
| 30 |
|
|
{
|
| 31 |
|
|
double *basis; /* Current values of the basis functions */
|
| 32 |
|
|
double *coeff; /* Polynom coefficients */
|
| 33 |
|
|
int ncoeff; /* Number of coefficients */
|
| 34 |
|
|
int *group; /* Groups */
|
| 35 |
|
|
int ndim; /* dimensionality of the polynom */
|
| 36 |
|
|
int *degree; /* Degree in each group */
|
| 37 |
|
|
int ngroup; /* Number of different groups */
|
| 38 |
|
|
} polystruct;
|
| 39 |
|
|
|
| 40 |
|
|
/*---------------------------------- protos --------------------------------*/
|
| 41 |
|
|
|
| 42 |
|
|
extern polystruct *poly_init(int *group,int ndim,int *degree,int ngroup);
|
| 43 |
|
|
|
| 44 |
|
|
extern double poly_func(polystruct *poly, double *pos);
|
| 45 |
|
|
|
| 46 |
|
|
extern int cholsolve(double *a, double *b, int n),
|
| 47 |
|
|
*poly_powers(polystruct *poly);
|
| 48 |
|
|
|
| 49 |
|
|
extern void poly_addcste(polystruct *poly, double *cste),
|
| 50 |
|
|
poly_end(polystruct *poly),
|
| 51 |
|
|
poly_fit(polystruct *poly, double *x, double *y,
|
| 52 |
|
|
double *w, int ndata, double *extbasis),
|
| 53 |
|
|
poly_solve(double *a, double *b, int n),
|
| 54 |
|
|
svdsolve(double *a, double *b, int m, int n,
|
| 55 |
|
|
double *vmat, double *wmat);
|
| 56 |
|
|
|
| 57 |
|
|
#endif
|
| 58 |
|
|
|