/* * 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 citcossinci_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFT991/citcossinci.C,v 1.4 2014/10/15 12:48:22 j_novak Exp $" ; /* * Transformation inverse 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 routine FFT Fortran FFT991 * * 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 3^q 5^r + 1 * int* dimc : tableau du nombre d'elements de cf dans chacune des trois * dimensions. * On doit avoir dimc[1] >= deg[1] = nt. * * 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 * avoir ete alloue avant l'appel a la routine. * Le coefficient c_l (0 <= l <= nt-1) doit etre stoke dans * le tableau cf comme suit * c_l = cf[ dimc[1]*dimc[2] * j + k + dimc[2] * l ] * ou j et k sont les indices correspondant a * phi et r respectivement. * * int* dimf : tableau du nombre d'elements de ff dans chacune des trois * dimensions. * On doit avoir dimf[1] >= deg[1] = nt. * * Sortie: * ------- * 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 * avoir ete alloue avant l'appel a la routine. * Les valeurs de la fonction sont stokees * dans le tableau ff comme suit * f( theta_l ) = ff[ dimf[1]*dimf[2] * j + k + dimf[2] * l ] * ou j et k sont les indices correspondant a * phi et r respectivement. * * NB: Si le pointeur cf est egal a ff, la routine ne travaille que sur un * seul tableau, qui constitue une entree/sortie. * */ /* * $Id: citcossinci.C,v 1.4 2014/10/15 12:48:22 j_novak Exp $ * $Log: citcossinci.C,v $ * Revision 1.4 2014/10/15 12:48:22 j_novak * Corrected namespace declaration. * * Revision 1.3 2014/10/13 08:53:17 j_novak * Lorene classes and functions now belong to the namespace Lorene. * * Revision 1.2 2014/10/06 15:18:46 j_novak * Modified #include directives to use c++ syntax. * * Revision 1.1 2004/12/21 17:06:01 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:53 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:40 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:42:35 hyc * *** empty log message *** * * * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFT991/citcossinci.C,v 1.4 2014/10/15 12:48:22 j_novak Exp $ * */ // headers du C #include #include // Prototypes of F77 subroutines #include "headcpp.h" #include "proto_f77.h" // Prototypage des sous-routines utilisees: namespace Lorene { int* facto_ini(int ) ; double* trigo_ini(int ) ; double* cheb_ini(const int) ; double* chebimp_ini(const int ) ; //***************************************************************************** void citcossinci(const int* deg, const int* dimc, double* cf, const int* dimf, double* ff) { 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] ; // Nombres de degres de liberte en theta : int nt = deg[1] ; // Tests de dimension: if (nt > n2f) { cout << "citcossinci: nt > n2f : nt = " << nt << " , n2f = " << n2f << endl ; abort () ; } if (nt > n2c) { cout << "citcossinci: nt > n2c : nt = " << nt << " , n2c = " << n2c << endl ; abort () ; } if (n1c > n1f) { cout << "citcossinci: n1c > n1f : n1c = " << n1c << " , n1f = " << n1f << endl ; abort () ; } if (n3c > n3f) { cout << "citcossinci: n3c > n3f : n3c = " << n3c << " , n3f = " << n3f << endl ; abort () ; } // Nombre de points pour la FFT: int nm1 = nt - 1; int nm1s2 = nm1 / 2; // Recherche des tables pour la FFT: int* facto = facto_ini(nm1) ; double* trigo = trigo_ini(nm1) ; // 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) ; // tableau de travail t1 et g // (la dimension nm1+2 = nt+1 est exigee par la routine fft991) double* g = (double*)( malloc( (nm1+2)*sizeof(double) ) ) ; double* t1 = (double*)( malloc( (nm1+2)*sizeof(double) ) ) ; // Parametres pour la routine FFT991 int jump = 1 ; int inc = 1 ; int lot = 1 ; int isign = 1 ; // 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