LORENE
som_asymy.C
1 /*
2  * Copyright (c) 2000-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  * Ensemble des routine pour la sommation directe en r, theta et phi dans
27  * le cas symetrie equatoriale (plan z=0) + antisymetrie par rapport au plan y=0
28  *
29  * SYNOPSYS:
30  * double som_r_XX_asymy
31  * (double* ti, int nr, int nt, int np, double x, double* trtp)
32  *
33  * x est l'argument du polynome de Chebychev: x in [0, 1] ou x in [-1, 1]
34  *
35  *
36  * double som_tet_XX_asymy
37  * (double* ti, int nt, int np, double tet, double* to)
38  *
39  * double som_phi_XX_asymy
40  * (double* ti, int np, double phi, double* xo)
41  *
42  * ATTENTION: np est suppose etre le nombre de points (sans le +2)
43  * on suppose que trtp tient compte de ca.
44  */
45 
46 /*
47  * $Id: som_asymy.C,v 1.5 2017/02/24 15:34:59 j_novak Exp $
48  * $Log: som_asymy.C,v $
49  * Revision 1.5 2017/02/24 15:34:59 j_novak
50  * Removal of spurious comments
51  *
52  * Revision 1.4 2016/12/05 16:18:08 j_novak
53  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
54  *
55  * Revision 1.3 2014/10/13 08:53:26 j_novak
56  * Lorene classes and functions now belong to the namespace Lorene.
57  *
58  * Revision 1.2 2014/10/06 15:16:06 j_novak
59  * Modified #include directives to use c++ syntax.
60  *
61  * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
62  * LORENE
63  *
64  * Revision 2.0 2000/03/06 10:27:45 eric
65  * *** empty log message ***
66  *
67  *
68  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/som_asymy.C,v 1.5 2017/02/24 15:34:59 j_novak Exp $
69  *
70  */
71 
72 
73 // Headers C
74 #include <cmath>
75 
76 namespace Lorene {
77 
78 //****************************************************************************
79 // Sommation en r
80 //****************************************************************************
81 
83  // Cas R_CHEB //
85 
86 void som_r_cheb_asymy(double* ti, const int nr, const int nt, const int np,
87  const double x, double* trtp) {
88 
89 // Variables diverses
90 int i, j, k ;
91 double* pi = ti ; // pointeur courant sur l'entree
92 double* po = trtp ; // pointeur courant sur la sortie
93 
94  // Valeurs des polynomes de Chebyshev au point x demande
95  double* cheb = new double [nr] ;
96  cheb[0] = 1. ;
97  cheb[1] = x ;
98  for (i=2; i<nr; i++) {
99  cheb[i] = 2*x* cheb[i-1] - cheb[i-2] ;
100  }
101 
102  // On saute les 3 premiers coef. en phi, qui sont respectivemment
103  // cos(0 phi), sin(0 phi) et cos(phi)
104  pi += 3*nr*nt ;
105  po += 3*nt ;
106 
107  // Sommation sur les phi suivants (pour k=3,...,np)
108  // en sautant les cosinus (d'ou le k+=2)
109  for (k=3 ; k<np+1 ; k+=2) {
110  for (j=0 ; j<nt ; j++) {
111  // Sommation sur r
112  *po = 0 ;
113  for (i=0 ; i<nr ; i++) {
114  *po += (*pi) * cheb[i] ;
115  pi++ ; // R suivant
116  }
117  po++ ; // Theta suivant
118  }
119  // On saute le cos(m*phi) :
120  pi += nr*nt ;
121  po += nt ;
122  }
123 
124  // Menage
125  delete [] cheb ;
126 }
127 
128 
129 
131  // Cas R_CHEBU //
133 
134 void som_r_chebu_asymy(double* ti, const int nr, const int nt, const int np,
135  const double x, double* trtp) {
136 
137 // Variables diverses
138 int i, j, k ;
139 double* pi = ti ; // pointeur courant sur l'entree
140 double* po = trtp ; // pointeur courant sur la sortie
141 
142  // Valeurs des polynomes de Chebyshev au point x demande
143  double* cheb = new double [nr] ;
144  cheb[0] = 1. ;
145  cheb[1] = x ;
146  for (i=2; i<nr; i++) {
147  cheb[i] = 2*x* cheb[i-1] - cheb[i-2] ;
148  }
149 
150  // On saute les 3 premiers coef. en phi, qui sont respectivemment
151  // cos(0 phi), sin(0 phi) et cos(phi)
152  pi += 3*nr*nt ;
153  po += 3*nt ;
154 
155  // Sommation sur les phi suivants (pour k=3,...,np)
156  // en sautant les cosinus (d'ou le k+=2)
157  for (k=3 ; k<np+1 ; k+=2) {
158  for (j=0 ; j<nt ; j++) {
159  // Sommation sur r
160  *po = 0 ;
161  for (i=0 ; i<nr ; i++) {
162  *po += (*pi) * cheb[i] ;
163  pi++ ; // R suivant
164  }
165  po++ ; // Theta suivant
166  }
167  // On saute le cos(m*phi) :
168  pi += nr*nt ;
169  po += nt ;
170  }
171 
172  // Menage
173  delete [] cheb ;
174 
175 }
176 
177 
178 
180  // Cas R_CHEBPIM_P //
182 
183 void som_r_chebpim_p_asymy(double* ti, const int nr, const int nt,
184  const int np, const double x, double* trtp) {
185 
186 // Variables diverses
187 int i, j, k ;
188 double* pi = ti ; // pointeur courant sur l'entree
189 double* po = trtp ; // pointeur courant sur la sortie
190 
191  // Valeurs des polynomes de Chebyshev au point x demande
192  double* cheb = new double [2*nr] ;
193  cheb[0] = 1. ;
194  cheb[1] = x ;
195  for (i=2 ; i<2*nr ; i++) {
196  cheb[i] = 2*x* cheb[i-1] - cheb[i-2] ;
197  }
198 
199 
200  // On saute les 3 premiers coef. en phi, qui sont respectivemment
201  // cos(0 phi), sin(0 phi) et cos(phi)
202  pi += 3*nr*nt ;
203  po += 3*nt ;
204 
205  // Sommation sur les phi suivants (pour k=3,...,np)
206  // en sautant les cosinus (d'ou le k+=2)
207  for (k=3 ; k<np+1 ; k+=2) {
208  int m = (k/2) % 2 ; // parite: 0 <-> 1
209  for (j=0 ; j<nt ; j++) {
210  // Sommation sur r
211  *po = 0 ;
212  for (i=0 ; i<nr ; i++) {
213  *po += (*pi) * cheb[2*i + m] ;
214  pi++ ; // R suivant
215  }
216  po++ ; // Theta suivant
217  }
218  // On saute le cos(m*phi) :
219  pi += nr*nt ;
220  po += nt ;
221  }
222 
223 
224  // Menage
225  delete [] cheb ;
226 
227 }
228 
230  // Cas R_CHEBPIM_I //
232 
233 void som_r_chebpim_i_asymy(double* ti, const int nr, const int nt,
234  const int np, const double x, double* trtp) {
235 
236 // Variables diverses
237 int i, j, k ;
238 double* pi = ti ; // pointeur courant sur l'entree
239 double* po = trtp ; // pointeur courant sur la sortie
240 
241  // Valeurs des polynomes de Chebyshev au point x demande
242  double* cheb = new double [2*nr] ;
243  cheb[0] = 1. ;
244  cheb[1] = x ;
245  for (i=2 ; i<2*nr ; i++) {
246  cheb[i] = 2*x* cheb[i-1] - cheb[i-2] ;
247  }
248 
249  // On saute les 3 premiers coef. en phi, qui sont respectivemment
250  // cos(0 phi), sin(0 phi) et cos(phi)
251  pi += 3*nr*nt ;
252  po += 3*nt ;
253 
254  // Sommation sur les phi suivants (pour k=3,...,np)
255  // en sautant les cosinus (d'ou le k+=2)
256  for (k=3 ; k<np+1 ; k+=2) {
257  int m = (k/2) % 2 ; // parite: 0 <-> 1
258  for (j=0 ; j<nt ; j++) {
259  // Sommation sur r
260  *po = 0 ;
261  for (i=0 ; i<nr ; i++) {
262  *po += (*pi) * cheb[2*i + 1 - m] ;
263  pi++ ; // R suivant
264  }
265  po++ ; // Theta suivant
266  }
267  // On saute le cos(m*phi) :
268  pi += nr*nt ;
269  po += nt ;
270  }
271 
272  // Menage
273  delete [] cheb ;
274 
275 }
276 
277 
278 
279 //****************************************************************************
280 // Sommation en theta
281 //****************************************************************************
282 
284  // Cas T_COSSIN_CP //
286 
287 void som_tet_cossin_cp_asymy(double* ti, const int nt, const int np,
288  const double tet, double* to) {
289 
290 // Variables diverses
291 int j, k ;
292 double* pi = ti ; // Pointeur courant sur l'entree
293 double* po = to ; // Pointeur courant sur la sortie
294 
295  // Initialisation des tables trigo
296  double* cossin = new double [2*nt] ;
297  for (j=0 ; j<2*nt ; j +=2) {
298  cossin[j] = cos(j * tet) ;
299  cossin[j+1] = sin((j+1) * tet) ;
300  }
301 
302  // On saute les 3 premiers coef. en phi, qui sont respectivemment
303  // cos(0 phi), sin(0 phi) et cos(phi)
304  pi += 3*nt ;
305  po += 3 ;
306 
307  // Sommation sur le reste des phi (pour k=3,...,np), suivant parite de m
308  for (k=3 ; k<np+1 ; k+=2) {
309  int m = (k/2) % 2 ; // parite: 0 <-> 1
310  (*po) = 0 ;
311  for (j=0 ; j<nt ; j++) {
312  *po += (*pi) * cossin[2*j + m] ;
313  pi++ ; // Theta suivant
314  }
315  po++ ; // Phi suivant
316 
317  // On saute le cos(m*phi) :
318  pi += nt ;
319  po++ ;
320 
321  }
322 
323  // Menage
324  delete [] cossin ;
325 }
326 
328  // Cas T_COSSIN_CI //
330 
331 void som_tet_cossin_ci_asymy(double* ti, const int nt, const int np,
332  const double tet, double* to) {
333 
334 // Variables diverses
335 int j, k ;
336 double* pi = ti ; // Pointeur courant sur l'entree
337 double* po = to ; // Pointeur courant sur la sortie
338 
339  // Initialisation des tables trigo
340  double* cossin = new double [2*nt] ;
341  for (j=0 ; j<2*nt ; j +=2) {
342  cossin[j] = cos((j+1) * tet) ;
343  cossin[j+1] = sin(j * tet) ;
344  }
345 
346  // On saute les 3 premiers coef. en phi, qui sont respectivemment
347  // cos(0 phi), sin(0 phi) et cos(phi)
348  pi += 3*nt ;
349  po += 3 ;
350 
351  // Sommation sur le reste des phi (pour k=3,...,np), suivant parite de m
352  for (k=3 ; k<np+1 ; k+=2) {
353  int m = (k/2) % 2 ; // parite: 0 <-> 1
354  (*po) = 0 ;
355  for (j=0 ; j<nt ; j++) {
356  *po += (*pi) * cossin[2*j + m] ;
357  pi++ ; // Theta suivant
358  }
359  po++ ; // Phi suivant
360 
361  // On saute le cos(m*phi) :
362  pi += nt ;
363  po++ ;
364 
365  }
366 
367  // Menage
368  delete [] cossin ;
369 }
370 
371 
372 //****************************************************************************
373 // Sommation en phi
374 //****************************************************************************
375 
376 void som_phi_cossin_asymy(double* ti, const int np, const double phi,
377  double* xo) {
378 
379  *xo = 0 ;
380 
381  // Sommation sur les sinus seulement
382  for (int k=3 ; k<np+1 ; k +=2 ) {
383  int m = k/2 ;
384  *xo += ti[k] * sin(m * phi) ;
385  }
386 
387 }
388 
389 }
Lorene prototypes.
Definition: app_hor.h:67
Cmp cos(const Cmp &)
Cosine.
Definition: cmp_math.C:97
Cmp sin(const Cmp &)
Sine.
Definition: cmp_math.C:72