LORENE
sxm1_1d_cheb.C
1 /*
2  * Copyright (c) 1999-2001 Eric Gourgoulhon
3  *
4  * This file is part of LORENE.
5  *
6  * LORENE is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * LORENE is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with LORENE; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */
21 
22 
23 
24 
25 /*
26  * Operateur [f(x) - f(1)]/(x-1) applique a une fonction f(x) developpee en
27  * polynomes de Tchebychev (echantillonnage fin: x ds. [-1, 1]) :
28  *
29  * f(x) = som_{i=0}^{nr-1} c_i T_i(x) (1)
30  *
31  *
32  * Entree:
33  * ------
34  * int nr : Nombre de coefficients de Tchebyshev dans le
35  * developpement (2)
36  *
37  * Entree/Sortie :
38  * -------------
39  * double* cf : entree: Tableau des nr coefficients c_i de la fonction f(x)
40  * definis par (1). Le stokage doit etre le suivant
41  * cf[i] = c_i 0 <= i <= nr - 1
42  * L'espace memoire correspondant au pointeur cf doit
43  * etre de taille au moins nr et doit avoir ete
44  * alloue avant l'appel a la routine
45  * sortie: Tableau des nr coefficients c_i de la fonction
46  * f(x)/(x-1). On a cf[nr-1] = 0.
47  *
48  */
49 
50 
51 /*
52  * $Id: sxm1_1d_cheb.C,v 1.3 2016/12/05 16:18:09 j_novak Exp $
53  * $Log: sxm1_1d_cheb.C,v $
54  * Revision 1.3 2016/12/05 16:18:09 j_novak
55  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
56  *
57  * Revision 1.2 2014/10/13 08:53:27 j_novak
58  * Lorene classes and functions now belong to the namespace Lorene.
59  *
60  * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
61  * LORENE
62  *
63  * Revision 2.0 1999/04/26 14:59:56 phil
64  * *** empty log message ***
65  *
66  *
67  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/sxm1_1d_cheb.C,v 1.3 2016/12/05 16:18:09 j_novak Exp $
68  *
69  */
70 
71 namespace Lorene {
72 
73 
74 //*****************************************************************************
75 
76 void sxm1_1d_cheb(int nr, double* cf) {
77 
78 //-------------------------------------------------------
79 // Formulation effectuant f(x)-f(1)/(x-1) (le coef. c_0 n'intervient donc pas)
80 //-------------------------------------------------------
81 
82  int i, j ;
83 
84 // Coefficient i=0 du resultat :
85 
86  double som = cf[1] ;
87  for (j=2; j<nr; j++) {
88  som += j * cf[j] ;
89  }
90  cf[0] = som ;
91 
92 // Coefficients 1 <= i <= nr-2 du resultat :
93 
94  for (i=1; i<nr-1; i++) {
95  som = cf[i+1] ;
96  for (j=i+2; j<nr; j++) {
97  som += (j-i) * cf[j] ;
98  }
99  cf[i] = 2 * som ;
100  }
101 
102 // Coefficient i=nr-1 du resultat :
103  cf[nr-1] = 0 ;
104 
105 
106 /*
107 //-------------------------------------------------------
108 // Formulation privilegiant c_{0} au detriment de c_{N-1}
109 //-------------------------------------------------------
110 
111 
112  // Coefficient i=0 du resultat :
113  // ---------------------------
114  int nrm1 = nr - 1 ;
115  double som = nrm1*cf[0] ;
116  double cfim1 = cf[0] ; // pour ne pas perdre le coef c_0 de l'entree
117  int i ;
118  for (i=1; i<nrm1; i++) {
119  som += (nrm1-i)*cf[i] ;
120  }
121  cf[0] = - som ;
122 
123  // Coefficient i=1 du resultat :
124  // ---------------------------
125  som = cfim1 ; // coef c_0 de l'entree
126  cfim1 = cf[1] ; // coef c_1 de l'entree
127  cf[1] = 2 * (cf[0] + som) ;
128  som += cfim1 ; // a ce stade som = c_0 + c_1 de l'entree
129 
130  // Coefficients 2 <= i <= nr-2 du resultat :
131  // ----------============-----------------
132  for (i=2; i<nrm1; i++) {
133  cfim1 = cf[i] ; // coef c_i de l'entree
134  cf[i] = cf[i-1] + 2*som ;
135  som += cfim1 ; // som = c_0 + c_1 + ... + c_i de l'entree
136  }
137 
138  // Coefficient i=nr-1 du resultat :
139  // ------------------------------
140  cf[nrm1] = 0 ;
141 
142 */
143 
144 }
145 
146 
147 
148 }
Lorene prototypes.
Definition: app_hor.h:67