/* * 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 chb_legp_cossincp_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/chb_legp_cossincp.C,v 1.7 2014/10/13 08:53:11 j_novak Exp $" ; /* * Calcule les coefficients du developpement (suivant theta) * en cos(2*j*theta) [m pair] / sin( (2*j+1) * theta) [m impair] * a partir des coefficients du developpement en fonctions * associees de Legendre P_l^m(cos(theta)) * pour une une fonction 3-D symetrique par rapport au plan equatorial * z = 0. * * Entree: * ------- * const int* deg : tableau du nombre effectif de degres de liberte dans chacune * des 3 dimensions: * deg[0] = np : nombre de points de collocation en phi * deg[1] = nt : nombre de points de collocation en theta * deg[2] = nr : nombre de points de collocation en r * * const double* cfi : tableau des coefficients a_l du develop. en fonctions de * Legendre associees P_n^m: * * pour m pair: f(theta) = * som_{l=m/2}^{nt-1} a_l P_{2l}^m( cos(theta) ) * * pour m impair: f(theta) = * som_{l=(m-1)/2}^{nt-2} a_l P_{2l+1}^m( cos(theta) ) * * ou P_n^m(x) represente la fonction de Legendre associee * de degre n et d'ordre m normalisee de facon a ce que * * int_0^pi [ P_n^m(cos(theta)) ]^2 sin(theta) dtheta = 1 * * L'espace memoire correspondant au pointeur cfi doit etre * nr*nt*(np+2) et doit avoir ete alloue avant * l'appel a la routine. * Le coefficient a_l (0 <= l <= nt-1) doit etre stoke dans le * tableau cfi comme suit * a_l = cfi[ nr*nt* k + i + nr* l ] * ou k et i sont les indices correspondant a phi et r * respectivement: m = k/2. * NB: pour m pair et l < m/2, a_l = 0 * pour m impair et l < (m-1)/2, a_l = 0 * * Sortie: * ------- * double* cfo : tableau des coefficients c_j du develop. en cos/sin definis * comme suit (a r et phi fixes) : * * pour m pair: f(theta) = som_{j=0}^{nt-1} c_j cos( 2 j theta ) * * pour m impair: f(theta) = som_{j=0}^{nt-2} c_j sin( (2 j+1) theta ) * * L'espace memoire correspondant au pointeur cfo doit etre * nr*nt*(np+2) et doit avoir ete alloue avant * l'appel a la routine. * Le coefficient c_j (0 <= j <= nt-1) est stoke dans le * tableau cfo comme suit * c_j = cfo[ nr*nt* k + i + nr* j ] * ou k et i sont les indices correspondant a * phi et r respectivement: m = k/2. * Pour m impair, c_0 = c_{nt-1} = 0. * * NB: * --- * Il n'est pas possible d'avoir le pointeur cfo egal a cfi. */ /* * $Id: chb_legp_cossincp.C,v 1.7 2014/10/13 08:53:11 j_novak Exp $ * $Log: chb_legp_cossincp.C,v $ * Revision 1.7 2014/10/13 08:53:11 j_novak * Lorene classes and functions now belong to the namespace Lorene. * * Revision 1.6 2014/10/06 15:16:00 j_novak * Modified #include directives to use c++ syntax. * * Revision 1.5 2013/04/25 15:46:05 j_novak * Added special treatment in the case np = 1, for type_p = NONSYM. * * Revision 1.4 2005/02/18 13:14:10 j_novak * Changing of malloc/free to new/delete + suppression of some unused variables * (trying to avoid compilation warnings). * * Revision 1.3 2003/01/31 10:31:23 e_gourgoulhon * Suppressed the directive #include for malloc is defined * in * * Revision 1.2 2002/10/16 14:36:52 j_novak * Reorganization of #include instructions of standard C++, in order to * use experimental version 3 of gcc. * * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon * LORENE * * Revision 2.0 1999/02/22 15:45:03 hyc * *** empty log message *** * * * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/chb_legp_cossincp.C,v 1.7 2014/10/13 08:53:11 j_novak Exp $ * */ // headers du C #include #include // Prototypage #include "headcpp.h" #include "proto.h" namespace Lorene { //****************************************************************************** void chb_legp_cossincp(const int* deg , const double* cfi, double* cfo) { int ip, k2, l, j, i, m ; // Nombres de degres de liberte en phi et theta : int np = deg[0] ; int nt = deg[1] ; int nr = deg[2] ; assert(np < 4*nt) ; // Tableau de travail double* som = new double[nr] ; // Recherche de la matrice de passage Legendre --> cos/sin double* bb = mat_legp_cossincp(np, nt) ; // Increment en m pour la matrice bb : int mbb = nt * nt ; // Pointeurs de travail : double* resu = cfo ; const double* cc = cfi ; // Increment en phi : int ntnr = nt * nr ; // Indice courant en phi : int k = 0 ; //---------------------------------------------------------------- // Cas axisymetrique //---------------------------------------------------------------- if (np == 1) { m = 0 ; // Boucle sur l'indice j du developpement en cos(2 j theta) for (j=0; j