LORENE
mult_xp1_1d_cheb.C
1/*
2 * Copyright (c) 2021 Gaƫl Servignat
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 * Operateur (x+1) Id applique a une fonction f(x) developpee en
26 * polynomes de Tchebychev (echantillonnage fin: x ds. [-1, 1]) :
27 *
28 * f(x) = som_{i=0}^{nr-1} c_i T_i(x) (1)
29 *
30 *
31 * Entree:
32 * ------
33 * int nr : Nombre de coefficients de Tchebyshev dans le
34 * developpement (1)
35 *
36 * const double* cf : Tableau des nr coefficients c_i de la fonction f(x)
37 * definis par (1). Le stokage doit etre le suivant
38 * cf[i] = c_i 0 <= i <= nr - 1
39 * L'espace memoire correspondant au pointeur cf doit
40 * etre de taille au moins nr et doit avoir ete
41 * alloue avant l'appel a la routine.
42 * Sortie :
43 * -------
44 * double* cresu : Tableau des nr coefficients de la fonction
45 * (x+1) f(x).
46 * L'espace memoire correspondant au pointeur cresu doit
47 * etre de taille au moins nr et doit avoir ete
48 * alloue avant l'appel a la routine.
49 *
50 */
51
52
53 #include <cassert>
54
55namespace Lorene {
56
57//*****************************************************************************
58
59void mult_xp1_1d_cheb(int nr, const double* cf, double* cresu) {
60
61 double aim1 = 0.5 ;
62 double ai = 1. ;
63 double aip1 = 0.5 ;
64
65 assert(nr>=3) ;
66
67// Coefficient i=0 du resultat :
68
69 cresu[0] = ai*cf[0] + aip1*cf[1] ;
70
71// Coefficient i=1 du resultat :
72
73 cresu[1] = cf[0] + ai*cf[1] + aip1*cf[2] ;
74
75
76// Coefficients 2 <= i <= nr-2 du resultat :
77
78 int i ;
79 for (i=2; i<nr-1; i++) {
80 cresu[i] = aim1*cf[i-1] + ai*cf[i] + aip1*cf[i+1] ;
81 }
82
83// Coefficient i=nr-1 du resultat :
84
85 cresu[nr-1] = aim1*cf[nr-2] + ai*cf[nr-1] ;
86
87}
88
89
90
91}
Lorene prototypes.
Definition app_hor.h:67