| 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 mult2_xm1_1d_cheb_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/mult2_xm1_1d_cheb.C,v 1.2 2014/10/13 08:53:24 j_novak Exp $" ; |
| 25 |
|
| 26 |
/* |
| 27 |
* $Id: mult2_xm1_1d_cheb.C,v 1.2 2014/10/13 08:53:24 j_novak Exp $ |
| 28 |
* $Log: mult2_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:27:55 phil |
| 36 |
* vire (double(0.5)) |
| 37 |
* |
| 38 |
* Revision 2.0 1999/04/26 16:28:15 phil |
| 39 |
* *** empty log message *** |
| 40 |
* |
| 41 |
* |
| 42 |
* $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/mult2_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)^2 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)^2 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 |
#include <cassert> |
| 76 |
|
| 77 |
namespace Lorene { |
| 78 |
|
| 79 |
//***************************************************************************** |
| 80 |
|
| 81 |
void mult2_xm1_1d_cheb(int nr, const double* cf, double* cresu) { |
| 82 |
|
| 83 |
double aim2 = 0.25 ; |
| 84 |
double aim1 = -1. ; |
| 85 |
double ai = 1.5 ; |
| 86 |
double aip1 = -1. ; |
| 87 |
double aip2 = 0.25 ; |
| 88 |
|
| 89 |
assert(nr>=3) ; |
| 90 |
|
| 91 |
// Coefficient i=0 du resultat : |
| 92 |
|
| 93 |
cresu[0] = ai*cf[0] + aip1*cf[1] + aip2*cf[2] ; |
| 94 |
|
| 95 |
// Coefficient i=1 du resultat : |
| 96 |
|
| 97 |
cresu[1] = double(-2)*cf[0] + double(1.75)*cf[1] + aip1*cf[2] + aip2*cf[3] ; |
| 98 |
|
| 99 |
// Coefficient i=2 du resultat : |
| 100 |
|
| 101 |
cresu[2] = double(0.5)*cf[0] + aim1*cf[1] + ai*cf[2] + aip1*cf[3] |
| 102 |
+ aip2*cf[4] ; |
| 103 |
|
| 104 |
// Coefficients 3 <= i <= nr-3 du resultat : |
| 105 |
|
| 106 |
int i ; |
| 107 |
for (i=3; i<nr-2; i++) { |
| 108 |
cresu[i] = aim2*cf[i-2] + aim1*cf[i-1] + ai*cf[i] + aip1*cf[i+1] |
| 109 |
+ aip2*cf[i+2] ; |
| 110 |
} |
| 111 |
|
| 112 |
// Coefficient i=nr-2 du resultat : |
| 113 |
|
| 114 |
cresu[nr-2] = aim2*cf[nr-4] + aim1*cf[nr-3] + ai*cf[nr-2] + aip1*cf[nr-1] ; |
| 115 |
|
| 116 |
// Coefficient i=nr-1 du resultat : |
| 117 |
|
| 118 |
cresu[nr-1] = aim2*cf[nr-3] + aim1*cf[nr-2] + ai*cf[nr-1] ; |
| 119 |
|
| 120 |
} |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
} |