LORENE
mult_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 char mult_xm1_1d_cheb_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/mult_xm1_1d_cheb.C,v 1.2 2014/10/13 08:53:24 j_novak Exp $" ;
25 
26 /*
27  * $Id: mult_xm1_1d_cheb.C,v 1.2 2014/10/13 08:53:24 j_novak Exp $
28  * $Log: mult_xm1_1d_cheb.C,v $
29  * Revision 1.2 2014/10/13 08:53:24 j_novak
30  * Lorene classes and functions now belong to the namespace Lorene.
31  *
32  * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
33  * LORENE
34  *
35  * Revision 2.1 1999/10/11 14:28:35 phil
36  * vire double(0.5)
37  *
38  * Revision 2.0 1999/04/26 16:16:08 phil
39  * *** empty log message ***
40  *
41  *
42  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/mult_xm1_1d_cheb.C,v 1.2 2014/10/13 08:53:24 j_novak Exp $
43  *
44  */
45 
46 
47 /*
48  * Operateur (x-1) Id applique a une fonction f(x) developpee en
49  * polynomes de Tchebychev (echantillonnage fin: x ds. [-1, 1]) :
50  *
51  * f(x) = som_{i=0}^{nr-1} c_i T_i(x) (1)
52  *
53  *
54  * Entree:
55  * ------
56  * int nr : Nombre de coefficients de Tchebyshev dans le
57  * developpement (1)
58  *
59  * const double* cf : Tableau des nr coefficients c_i de la fonction f(x)
60  * definis par (1). Le stokage doit etre le suivant
61  * cf[i] = c_i 0 <= i <= nr - 1
62  * L'espace memoire correspondant au pointeur cf doit
63  * etre de taille au moins nr et doit avoir ete
64  * alloue avant l'appel a la routine.
65  * Sortie :
66  * -------
67  * double* cresu : Tableau des nr coefficients de la fonction
68  * (x-1) f(x).
69  * L'espace memoire correspondant au pointeur cresu doit
70  * etre de taille au moins nr et doit avoir ete
71  * alloue avant l'appel a la routine.
72  *
73  */
74 
75 
76  #include <cassert>
77 
78 namespace Lorene {
79 
80 //*****************************************************************************
81 
82 void mult_xm1_1d_cheb(int nr, const double* cf, double* cresu) {
83 
84  double aim1 = 0.5 ;
85  double ai = -1. ;
86  double aip1 = 0.5 ;
87 
88  assert(nr>=3) ;
89 
90 // Coefficient i=0 du resultat :
91 
92  cresu[0] = ai*cf[0] + aip1*cf[1] ;
93 
94 // Coefficient i=1 du resultat :
95 
96  cresu[1] = cf[0] + ai*cf[1] + aip1*cf[2] ;
97 
98 
99 // Coefficients 2 <= i <= nr-2 du resultat :
100 
101  int i ;
102  for (i=2; i<nr-1; i++) {
103  cresu[i] = aim1*cf[i-1] + ai*cf[i] + aip1*cf[i+1] ;
104  }
105 
106 // Coefficient i=nr-1 du resultat :
107 
108  cresu[nr-1] = aim1*cf[nr-2] + ai*cf[nr-1] ;
109 
110 }
111 
112 
113 
114 }
Lorene prototypes.
Definition: app_hor.h:64