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