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
23char sxm1_1d_cheb_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/sxm1_1d_cheb.C,v 1.2 2014/10/13 08:53:27 j_novak Exp $" ;
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.2 2014/10/13 08:53:27 j_novak Exp $
53 * $Log: sxm1_1d_cheb.C,v $
54 * Revision 1.2 2014/10/13 08:53:27 j_novak
55 * Lorene classes and functions now belong to the namespace Lorene.
56 *
57 * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
58 * LORENE
59 *
60 * Revision 2.0 1999/04/26 14:59:56 phil
61 * *** empty log message ***
62 *
63 *
64 * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/sxm1_1d_cheb.C,v 1.2 2014/10/13 08:53:27 j_novak Exp $
65 *
66 */
67
68namespace Lorene {
69
70
71//*****************************************************************************
72
73void sxm1_1d_cheb(int nr, double* cf) {
74
75//-------------------------------------------------------
76// Formulation effectuant f(x)-f(1)/(x-1) (le coef. c_0 n'intervient donc pas)
77//-------------------------------------------------------
78
79 int i, j ;
80
81// Coefficient i=0 du resultat :
82
83 double som = cf[1] ;
84 for (j=2; j<nr; j++) {
85 som += j * cf[j] ;
86 }
87 cf[0] = som ;
88
89// Coefficients 1 <= i <= nr-2 du resultat :
90
91 for (i=1; i<nr-1; i++) {
92 som = cf[i+1] ;
93 for (j=i+2; j<nr; j++) {
94 som += (j-i) * cf[j] ;
95 }
96 cf[i] = 2 * som ;
97 }
98
99// Coefficient i=nr-1 du resultat :
100 cf[nr-1] = 0 ;
101
102
103/*
104//-------------------------------------------------------
105// Formulation privilegiant c_{0} au detriment de c_{N-1}
106//-------------------------------------------------------
107
108
109 // Coefficient i=0 du resultat :
110 // ---------------------------
111 int nrm1 = nr - 1 ;
112 double som = nrm1*cf[0] ;
113 double cfim1 = cf[0] ; // pour ne pas perdre le coef c_0 de l'entree
114 int i ;
115 for (i=1; i<nrm1; i++) {
116 som += (nrm1-i)*cf[i] ;
117 }
118 cf[0] = - som ;
119
120 // Coefficient i=1 du resultat :
121 // ---------------------------
122 som = cfim1 ; // coef c_0 de l'entree
123 cfim1 = cf[1] ; // coef c_1 de l'entree
124 cf[1] = 2 * (cf[0] + som) ;
125 som += cfim1 ; // a ce stade som = c_0 + c_1 de l'entree
126
127 // Coefficients 2 <= i <= nr-2 du resultat :
128 // ----------============-----------------
129 for (i=2; i<nrm1; i++) {
130 cfim1 = cf[i] ; // coef c_i de l'entree
131 cf[i] = cf[i-1] + 2*som ;
132 som += cfim1 ; // som = c_0 + c_1 + ... + c_i de l'entree
133 }
134
135 // Coefficient i=nr-1 du resultat :
136 // ------------------------------
137 cf[nrm1] = 0 ;
138
139*/
140
141}
142
143
144
145}
Lorene prototypes.
Definition app_hor.h:64