| 1 |
/* |
| 2 |
* Copyright (c) 1999-2001 Eric Gourgoulhon |
| 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 |
char cipcossini_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFT991/cipcossini.C,v 1.3 2014/10/13 08:53:16 j_novak Exp $" ; |
| 24 |
|
| 25 |
/* |
| 26 |
* Transformation de Fourier inverse sur le premier indice d'un tableau 3-D |
| 27 |
* Cas d'une fonction antisymetrique par la transformation phi --> phi + Pi |
| 28 |
* |
| 29 |
* |
| 30 |
* Entree: |
| 31 |
* ------- |
| 32 |
* int* deg : tableau du nombre effectif de degres de liberte dans chacune |
| 33 |
* des 3 dimensions: le nombre de points de collocation |
| 34 |
* en phi est np = deg[0] et doit etre de la forme |
| 35 |
* np = 2^p 3^q 5^r |
| 36 |
* int* dimc : tableau du nombre d'elements dans chacune des trois |
| 37 |
* dimensions du tableau cf |
| 38 |
* On doit avoir dimc[0] >= deg[0] + 2 = np + 2. |
| 39 |
* |
| 40 |
* int* dimf : tableau du nombre d'elements dans chacune des trois |
| 41 |
* dimensions du tableau ff |
| 42 |
* On doit avoir dimf[0] >= deg[0] = np . |
| 43 |
* |
| 44 |
* |
| 45 |
* Entree / sortie : |
| 46 |
* ----------------- |
| 47 |
* double* cf : entree: tableau des coefficients de la fonction f; |
| 48 |
* L'espace memoire correspondant a ce |
| 49 |
* pointeur doit etre dimc[0]*dimc[1]*dimc[2] et doit |
| 50 |
* avoir ete alloue avant l'appel a la routine. |
| 51 |
* La convention de stokage est la suivante: |
| 52 |
* cf[ dimc[2]*dimc[1]*k + dimc[2]*j + i ] = c_k 0<= k < np, |
| 53 |
* ou les indices j et i correspondent respectivement |
| 54 |
* a theta et a r et ou les c_k sont les coefficients |
| 55 |
* du developpement de f en series de Fourier: |
| 56 |
* |
| 57 |
* f(phi) = c_0 cos(phi) + c_2 sin(phi) |
| 58 |
* + som_{l=1}^{np/2-1} c_{2l+1} cos( (2l+1) phi ) |
| 59 |
* + c_{2l+2} sin( (2l+1) phi ), |
| 60 |
* |
| 61 |
* En particulier: c_1 = 0 et c_{np+1} = 0 |
| 62 |
* |
| 63 |
* !!!! CE TABLEAU EST DETRUIT EN SORTIE !!!!! |
| 64 |
* |
| 65 |
* Sortie: |
| 66 |
* ------- |
| 67 |
* double* ff : tableau des valeurs de la fonction aux points de |
| 68 |
* de collocation |
| 69 |
* |
| 70 |
* phi_k = Pi k/np 0 <= k <= np-1 |
| 71 |
* |
| 72 |
* suivant la convention de stokage: |
| 73 |
* ff[ dimf[2]*dimf[1]*k + dimf[2]*j + i ] = f(phi_k) 0 <= k <= np-1, |
| 74 |
* les indices j et i correspondant respectivement |
| 75 |
* a theta et a r. |
| 76 |
* L'espace memoire correspondant a ce |
| 77 |
* pointeur doit etre dimf[0]*dimf[1]*dimf[2] et doit |
| 78 |
* avoir ete alloue avant l'appel a la routine. |
| 79 |
*/ |
| 80 |
|
| 81 |
/* |
| 82 |
* $Id: cipcossini.C,v 1.3 2014/10/13 08:53:16 j_novak Exp $ |
| 83 |
* $Log: cipcossini.C,v $ |
| 84 |
* Revision 1.3 2014/10/13 08:53:16 j_novak |
| 85 |
* Lorene classes and functions now belong to the namespace Lorene. |
| 86 |
* |
| 87 |
* Revision 1.2 2014/10/06 15:18:45 j_novak |
| 88 |
* Modified #include directives to use c++ syntax. |
| 89 |
* |
| 90 |
* Revision 1.1 2004/12/21 17:06:01 j_novak |
| 91 |
* Added all files for using fftw3. |
| 92 |
* |
| 93 |
* Revision 1.2 2002/10/16 14:36:53 j_novak |
| 94 |
* Reorganization of #include instructions of standard C++, in order to |
| 95 |
* use experimental version 3 of gcc. |
| 96 |
* |
| 97 |
* Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon |
| 98 |
* LORENE |
| 99 |
* |
| 100 |
* Revision 2.1 2000/09/08 15:55:21 eric |
| 101 |
* Premiere version testee. |
| 102 |
* |
| 103 |
* Revision 2.0 2000/09/07 15:15:17 eric |
| 104 |
* *** empty log message *** |
| 105 |
* |
| 106 |
* |
| 107 |
* $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFT991/cipcossini.C,v 1.3 2014/10/13 08:53:16 j_novak Exp $ |
| 108 |
* |
| 109 |
*/ |
| 110 |
|
| 111 |
// Headers C |
| 112 |
#include <cstdlib> |
| 113 |
|
| 114 |
#include "headcpp.h" |
| 115 |
|
| 116 |
// Headers Lorene |
| 117 |
#include "proto.h" |
| 118 |
|
| 119 |
namespace Lorene { |
| 120 |
//***************************************************************************** |
| 121 |
|
| 122 |
void cipcossini(const int* deg, const int* dimc, const int* dimf, |
| 123 |
double* cf, double* ff) |
| 124 |
{ |
| 125 |
|
| 126 |
// Nombres de degres de liberte en phi: |
| 127 |
int np = deg[0] ; |
| 128 |
|
| 129 |
// Tableaux pour echantillonnage sur [0,2 Pi[ : |
| 130 |
int np2 = 2*np ; |
| 131 |
|
| 132 |
int deg2[] = {np2, deg[1], deg[2]} ; |
| 133 |
int dimc2[] = {np2+2, dimc[1], dimc[2]} ; |
| 134 |
int dimf2[] = {np2, dimf[1], dimf[2]} ; |
| 135 |
|
| 136 |
double* cf2 = new double[ dimc2[0]*dimc2[1]*dimc2[2] ] ; |
| 137 |
double* ff2 = new double[ dimf2[0]*dimf2[1]*dimf2[2] ] ; |
| 138 |
|
| 139 |
// Recopie des coefficients dans cf2 : |
| 140 |
int ntnrc = dimc[1] * dimc[2] ; |
| 141 |
|
| 142 |
// Harmonique m=0 (cosinus et sinus) mise a zero |
| 143 |
for (int ij = 0; ij <2*ntnrc; ij++) { |
| 144 |
cf2[ij] = 0 ; |
| 145 |
} |
| 146 |
|
| 147 |
// Harmonique m=1 (cosinus) |
| 148 |
for (int ij = 0; ij <ntnrc; ij++) { |
| 149 |
cf2[2*ntnrc + ij] = cf[ij] ; |
| 150 |
} |
| 151 |
|
| 152 |
// Harmonique m=1 (sinus) |
| 153 |
for (int ij = 0; ij <ntnrc; ij++) { |
| 154 |
cf2[3*ntnrc + ij] = cf[2*ntnrc + ij] ; |
| 155 |
} |
| 156 |
|
| 157 |
for (int k2=4; k2<np2; k2 +=4) { |
| 158 |
// Harmoniques paires : |
| 159 |
for (int ij = 0; ij <2*ntnrc; ij++) { |
| 160 |
cf2[k2*ntnrc + ij] = 0 ; |
| 161 |
} |
| 162 |
|
| 163 |
// Harmoniques impaires (cosinus et sinus) |
| 164 |
int k = k2 / 2 + 1 ; |
| 165 |
for (int ij = 0; ij <2*ntnrc; ij++) { |
| 166 |
cf2[(k2+2)*ntnrc + ij] = cf[k*ntnrc + ij] ; |
| 167 |
} |
| 168 |
} |
| 169 |
|
| 170 |
// Mise a zero des deux derniers coefficients: |
| 171 |
for (int ij = 0; ij <2*ntnrc; ij++) { |
| 172 |
cf2[np2*ntnrc + ij] = 0 ; |
| 173 |
} |
| 174 |
|
| 175 |
// Transformation de Fourier inverse sur [0, 2 Pi] |
| 176 |
cipcossin(deg2, dimc2, dimf2, cf2, ff2) ; |
| 177 |
|
| 178 |
// Recopie des valeurs de la fonction dans ff : |
| 179 |
int ntnrf = dimf[1] * dimf[2] ; |
| 180 |
for (int k=0; k<np; k++) { |
| 181 |
for (int ij = 0; ij <ntnrf; ij++) { |
| 182 |
ff[k*ntnrf + ij] = ff2[k*ntnrf + ij] ; |
| 183 |
} |
| 184 |
} |
| 185 |
|
| 186 |
|
| 187 |
// Menage |
| 188 |
delete [] cf2 ; |
| 189 |
delete [] ff2 ; |
| 190 |
|
| 191 |
|
| 192 |
} |
| 193 |
} |