/* * Copyright (c) 1999-2001 Eric Gourgoulhon * * This file is part of LORENE. * * LORENE is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * LORENE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with LORENE; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ char cftcossinci_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFTW3/cftcossinci.C,v 1.3 2014/10/13 08:53:19 j_novak Exp $" ; /* * Transformation en cos((2*l+1)*theta) ou sin(2*l*theta)(suivant la parite * de l'indice m en phi) sur le deuxieme indice (theta) * d'un tableau 3-D representant une fonction antisymetrique par rapport * au plan z=0. * Utilise la bibliotheque fftw. * * Entree: * ------- * int* deg : tableau du nombre effectif de degres de liberte dans chacune * des 3 dimensions: le nombre de points de collocation * en theta est nt = deg[1] et doit etre de la forme * nt = 2*p + 1 * int* dimf : tableau du nombre d'elements de ff dans chacune des trois * dimensions. * On doit avoir dimf[1] >= deg[1] = nt. * * double* ff : tableau des valeurs de la fonction aux nt points de * de collocation * * theta_l = pi/2 l/(nt-1) 0 <= l <= nt-1 * * L'espace memoire correspondant a ce * pointeur doit etre dimf[0]*dimf[1]*dimf[2] et doit * etre alloue avant l'appel a la routine. * Les valeurs de la fonction doivent etre stokees * dans le tableau ff comme suit * f( theta_l ) = ff[ dimf[1]*dimf[2] * m + k + dimf[2] * l ] * ou m et k sont les indices correspondant a * phi et r respectivement. * NB: cette routine suppose que la transformation en phi a deja ete * effectuee: ainsi m est un indice de Fourier, non un indice de * point de collocation en phi. * * int* dimc : tableau du nombre d'elements de cf dans chacune des trois * dimensions. * On doit avoir dimc[1] >= deg[1] = nt. * Sortie: * ------- * double* cf : tableau des coefficients c_l de la fonction definis * comme suit (a r et phi fixes) * * pour m pair: * f(theta) = som_{l=0}^{nt-2} c_l cos( (2 l+1) theta ) . * pour m impair: * f(theta) = som_{l=0}^{nt-2} c_l sin( 2 l theta ) . * * L'espace memoire correspondant a ce * pointeur doit etre dimc[0]*dimc[1]*dimc[2] et doit * etre alloue avant l'appel a la routine. * Le coefficient c_l (0 <= l <= nt-1) est stoke dans * le tableau cf comme suit * c_l = cf[ dimc[1]*dimc[2] * m + k + dimc[2] * l ] * ou m et k sont les indices correspondant a * phi et r respectivement. * Pour m pair, c_{nt-1} = 0. * Pour m impair, c_0 = c_{nt-1} = 0 . * * NB: Si le pointeur ff est egal a cf, la routine ne travaille que sur un * seul tableau, qui constitue une entree/sortie. * */ /* * $Id: cftcossinci.C,v 1.3 2014/10/13 08:53:19 j_novak Exp $ * $Log: cftcossinci.C,v $ * Revision 1.3 2014/10/13 08:53:19 j_novak * Lorene classes and functions now belong to the namespace Lorene. * * Revision 1.2 2014/10/06 15:18:48 j_novak * Modified #include directives to use c++ syntax. * * Revision 1.1 2004/12/21 17:06:02 j_novak * Added all files for using fftw3. * * Revision 1.4 2003/01/31 10:31:23 e_gourgoulhon * Suppressed the directive #include for malloc is defined * in * * Revision 1.3 2002/10/16 14:36:46 j_novak * Reorganization of #include instructions of standard C++, in order to * use experimental version 3 of gcc. * * Revision 1.2 2002/09/09 13:00:39 e_gourgoulhon * Modification of declaration of Fortran 77 prototypes for * a better portability (in particular on IBM AIX systems): * All Fortran subroutine names are now written F77_* and are * defined in the new file C++/Include/proto_f77.h. * * Revision 1.1.1.1 2001/11/20 15:19:28 e_gourgoulhon * LORENE * * Revision 2.0 1999/02/22 15:47:40 hyc * *** empty log message *** * * * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFTW3/cftcossinci.C,v 1.3 2014/10/13 08:53:19 j_novak Exp $ * */ // headers du C #include #include //Lorene prototypes #include "tbl.h" // Prototypage des sous-routines utilisees: namespace Lorene { fftw_plan prepare_fft(int, Tbl*&) ; double* cheb_ini(const int) ; double* chebimp_ini(const int ) ; //***************************************************************************** void cftcossinci(const int* deg, const int* dimf, double* ff, const int* dimc, double* cf) { int i, j, k ; // Dimensions des tableaux ff et cf : int n1f = dimf[0] ; int n2f = dimf[1] ; int n3f = dimf[2] ; int n1c = dimc[0] ; int n2c = dimc[1] ; int n3c = dimc[2] ; // Nombre de degres de liberte en theta : int nt = deg[1] ; // Tests de dimension: if (nt > n2f) { cout << "cftcossinci: nt > n2f : nt = " << nt << " , n2f = " << n2f << endl ; abort () ; } if (nt > n2c) { cout << "cftcossinci: nt > n2c : nt = " << nt << " , n2c = " << n2c << endl ; abort () ; } if (n1f > n1c) { cout << "cftcossinci: n1f > n1c : n1f = " << n1f << " , n1c = " << n1c << endl ; abort () ; } if (n3f > n3c) { cout << "cftcossinci: n3f > n3c : n3f = " << n3f << " , n3c = " << n3c << endl ; abort () ; } // Nombre de points pour la FFT: int nm1 = nt - 1; int nm1s2 = nm1 / 2; // Recherche des tables pour la FFT: Tbl* pg = 0x0 ; fftw_plan p = prepare_fft(nm1, pg) ; Tbl& g = *pg ; // Recherche de la table des sin(psi) : double* sinp = cheb_ini(nt); // Recherche de la table des points de collocations x_k = cos(theta_{nt-1-k}) : double* x = chebimp_ini(nt); // boucle sur phi et r (les boucles vont resp. de 0 a dimf[0]-1 // et 0 a dimf[2]) int n2n3f = n2f * n3f ; int n2n3c = n2c * n3c ; //======================================================================= // Cas m pair //======================================================================= j = 0 ; while (j