poly.h 2.77 KB
Newer Older
1
2
3
4
5
6
/*
*				poly.h
*
* Include file for poly.c.
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Emmanuel Bertin's avatar
Emmanuel Bertin committed
7
*
8
*	This file part of:	AstrOmatic software
Emmanuel Bertin's avatar
Emmanuel Bertin committed
9
*
10
*	Copyright:		(C) 1998-2011 IAP/CNRS/UPMC
Emmanuel Bertin's avatar
Emmanuel Bertin committed
11
*
12
*	License:		GNU General Public License
Emmanuel Bertin's avatar
Emmanuel Bertin committed
13
*
14
15
16
17
18
19
20
21
22
23
24
25
*	AstrOmatic software is free software: you can redistribute it and/or
*	modify it under the terms of the GNU General Public License as
*	published by the Free Software Foundation, either version 3 of the
*	License, or (at your option) any later version.
*	AstrOmatic software is distributed in the hope that it will be useful,
*	but WITHOUT ANY WARRANTY; without even the implied warranty of
*	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*	GNU General Public License for more details.
*	You should have received a copy of the GNU General Public License
*	along with AstrOmatic software.
*	If not, see <http://www.gnu.org/licenses/>.
*
26
*	Last modified:		20/11/2012
27
28
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
Emmanuel Bertin's avatar
Emmanuel Bertin committed
29
30
31
32
33
34
35

#ifndef _POLY_H_
#define _POLY_H_

/*--------------------------------- constants -------------------------------*/

#define	POLY_MAXDIM		4	/* Max dimensionality of polynom */
36
37
#define POLY_MAXDEGREE		40	/* Max degree of the polynom */
#define	POLY_TINY		1e-30	/* A tiny number */
Emmanuel Bertin's avatar
Emmanuel Bertin committed
38
39
40
41
42
43
44
45

/*---------------------------------- macros ---------------------------------*/

/*--------------------------- structure definitions -------------------------*/

typedef struct poly
  {
  double	*basis;		/* Current values of the basis functions */
46
  double	*orthobasis;	/* Curr orthonormalized basis function values */
Emmanuel Bertin's avatar
Emmanuel Bertin committed
47
48
49
50
51
52
  double	*coeff;		/* Polynom coefficients */
  int		ncoeff;		/* Number of coefficients */
  int		*group;		/* Groups */
  int		ndim;		/* dimensionality of the polynom */
  int		*degree;	/* Degree in each group */
  int		ngroup;		/* Number of different groups */
53
54
  double	*orthomat;	/* Orthonormalization matrix */
  double	*deorthomat;	/* "Deorthonormalization" matrix */
Emmanuel Bertin's avatar
Emmanuel Bertin committed
55
56
57
58
  }	polystruct;

/*---------------------------------- protos --------------------------------*/

59
60
extern polystruct	*poly_copy(polystruct *poly),
			*poly_init(int *group,int ndim,int *degree,int ngroup);
Emmanuel Bertin's avatar
Emmanuel Bertin committed
61

62
extern double		poly_func(polystruct *poly, double *pos);
Emmanuel Bertin's avatar
Emmanuel Bertin committed
63
64
65

extern int		cholsolve(double *a, double *b, int n),
			poly_fit(polystruct *poly, double *x, double *y,
66
67
68
				double *w, int ndata, double *extbasis,
				double regul),
			*poly_powers(polystruct *poly),
69
			poly_solve(double *a, double *b, int n);
70
71
72
73
74
75
76
77
78
79
80

extern void		poly_addcste(polystruct *poly, double *cste),
			poly_end(polystruct *poly);

extern double		*poly_deortho(polystruct *poly, double *datain,
				double *dataout),
			*poly_ortho(polystruct *poly, double *datain,
				double *dataout);
extern void		poly_initortho(polystruct *poly, double *data,
				int ndata);

Emmanuel Bertin's avatar
Emmanuel Bertin committed
81
82
#endif