xdsdx_1d.C

00001 /*
00002  *   Copyright (c) 1999-2001 Philippe Grandclement
00003  *
00004  *   This file is part of LORENE.
00005  *
00006  *   LORENE is free software; you can redistribute it and/or modify
00007  *   it under the terms of the GNU General Public License as published by
00008  *   the Free Software Foundation; either version 2 of the License, or
00009  *   (at your option) any later version.
00010  *
00011  *   LORENE is distributed in the hope that it will be useful,
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *   GNU General Public License for more details.
00015  *
00016  *   You should have received a copy of the GNU General Public License
00017  *   along with LORENE; if not, write to the Free Software
00018  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 
00023 char xdsdx_1d_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/xdsdx_1d.C,v 1.2 2002/10/16 14:37:11 j_novak Exp $" ;
00024 
00025 /*
00026  * $Id: xdsdx_1d.C,v 1.2 2002/10/16 14:37:11 j_novak Exp $
00027  * $Log: xdsdx_1d.C,v $
00028  * Revision 1.2  2002/10/16 14:37:11  j_novak
00029  * Reorganization of #include instructions of standard C++, in order to
00030  * use experimental version 3 of gcc.
00031  *
00032  * Revision 1.1.1.1  2001/11/20 15:19:29  e_gourgoulhon
00033  * LORENE
00034  *
00035  * Revision 2.0  1999/10/11  09:55:46  phil
00036  * *** empty log message ***
00037  *
00038  *
00039  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/xdsdx_1d.C,v 1.2 2002/10/16 14:37:11 j_novak Exp $
00040  *
00041  */
00042  
00043  // Includes
00044 #include <stdlib.h>
00045 
00046 #include "headcpp.h"
00047 #include "type_parite.h"
00048 
00049 
00050 
00051         //----------------------------------
00052         // Routine pour les cas non prevus --
00053         //----------------------------------
00054 
00055 void _xdsdx_1d_pas_prevu(int nr, double* tb, double *xo) {
00056     cout << "xdsdx pas prevu..." << endl ;
00057     cout << "Nombre de points : " << nr << endl ;
00058     cout << "Valeurs : " << tb << "  " << xo <<endl ;
00059     abort() ;
00060     exit(-1) ;
00061 }
00062 
00063 
00064             //---------------
00065             // cas R_CHEB ---
00066             //---------------
00067 
00068 void _xdsdx_1d_r_cheb(int nr, double* tb, double *xo) {
00069     
00070     double somme = 0 ;
00071     //Premiere boucle sur r :
00072     for (int i=nr-1 ; i>= 0 ; i-=2) {
00073     if (i==nr-1) 
00074         somme += i*tb[i] ;
00075     else somme += i*tb[i]+(i+2)*tb[i+2] ;
00076     xo[i] = somme ;
00077     }
00078     
00079     //Seconde boucle sur r :
00080     somme = 0 ;
00081     for (int i=nr-2 ; i>=0 ; i-=2) {
00082     if (i==nr-2)
00083         somme += i*tb[i] ;
00084     else
00085         somme += i*tb[i]+(i+2)*tb[i+2] ;
00086     xo[i] = somme ;
00087     }
00088     xo[0] *= .5 ;   
00089 }
00090 
00091             //-----------------
00092             // cas R_CHEBP ---
00093             //----------------
00094 
00095 void _xdsdx_1d_r_chebp(int nr, double* tb, double *xo) {
00096     
00097     double somme = 0 ;
00098     for (int i=nr-1 ; i>=0 ; i--) {
00099     if (i==nr-1)
00100         somme += (2*i)*tb[i] ;
00101     else 
00102         somme += (2*i)*tb[i]+(2*i+2)*tb[i+1] ;
00103     xo[i] = somme ;
00104     }
00105     
00106     xo[0] *= .5 ;
00107 }
00108 
00109             //---------------
00110             // cas R_CHEBI --
00111             //---------------
00112 
00113 void _xdsdx_1d_r_chebi(int nr, double* tb, double *xo) {
00114 
00115     double somme = 0 ;
00116     for (int i=nr-1 ; i>=0 ; i--) {
00117     if (i==nr-1)
00118         somme += (2*i+1)*tb[i] ;
00119     else
00120         somme += (2*i+1)*tb[i]+(2*i+3)*tb[i+1] ;
00121     xo[i] = somme ;
00122     
00123     }
00124 }
00125 
00126 
00127         // ---------------------
00128         // La routine a appeler
00129         //----------------------
00130         
00131         
00132 void xdsdx_1d(int nr, double** tb, int base_r)
00133 {
00134 
00135         // Routines de derivation
00136     static void (*xdsdx_1d[MAX_BASE])(int, double*, double *) ;
00137     static int nap = 0 ;
00138 
00139         // Premier appel
00140     if (nap==0) {
00141     nap = 1 ;
00142     for (int i=0 ; i<MAX_BASE ; i++) {
00143         xdsdx_1d[i] = _xdsdx_1d_pas_prevu ;
00144     }
00145         // Les routines existantes
00146     xdsdx_1d[R_CHEB >> TRA_R] = _xdsdx_1d_r_cheb ;
00147     xdsdx_1d[R_CHEBP >> TRA_R] = _xdsdx_1d_r_chebp ;
00148     xdsdx_1d[R_CHEBI >> TRA_R] = _xdsdx_1d_r_chebi ;
00149     }
00150     
00151     double *result = new double[nr] ;
00152     
00153     xdsdx_1d[base_r](nr, *tb, result) ;
00154     
00155     delete [] (*tb) ;
00156     (*tb) = result ;
00157 }

Generated on Tue Feb 7 01:35:21 2012 for LORENE by  doxygen 1.4.6