multx2_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 multx2_1d_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/multx2_1d.C,v 1.2 2002/10/16 14:36:58 j_novak Exp $" ;
00024 
00025 /*
00026  * $Id: multx2_1d.C,v 1.2 2002/10/16 14:36:58 j_novak Exp $
00027  * $Log: multx2_1d.C,v $
00028  * Revision 1.2  2002/10/16 14:36:58  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:53:08  phil
00036  * *** empty log message ***
00037  *
00038  *
00039  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/multx2_1d.C,v 1.2 2002/10/16 14:36:58 j_novak Exp $
00040  *
00041  */
00042 
00043 // Includes
00044 #include <stdlib.h>
00045 #include <assert.h>
00046 
00047 #include "headcpp.h"
00048 #include "type_parite.h"
00049 #include "proto.h"
00050 
00051         //-----------------------------------
00052         // Routine pour les cas non prevus --
00053         //-----------------------------------
00054 
00055 void _multx2_1d_pas_prevu(int nr, double* tb, double *res) {
00056     cout << "multx2 pas prevu..." << tb << "    " << res << endl ;
00057     cout << "nr : " << nr << endl ;
00058     abort() ;
00059     exit(-1) ;
00060 }
00061 
00062             //---------------
00063             // cas R_CHEBP --
00064             //---------------
00065 
00066 void _multx2_1d_r_chebp(int nr, double* tb, double *xo) {
00067     
00068     assert (nr>2) ;
00069     
00070     xo[0] = (2*tb[0]+tb[1])/4 ;
00071     xo[1] = (2*tb[0]+2*tb[1]+tb[2])/4 ;
00072     
00073     for (int i=2 ; i<nr-1 ; i++)
00074     xo[i] = (tb[i-1]+2*tb[i]+tb[i+1])/4 ;
00075     xo[nr-1] = (tb[nr-2]+2*tb[nr-1])/4 ;
00076 }
00077 
00078 
00079             //---------------
00080             // cas R_CHEBI --
00081             //---------------
00082 
00083 void _multx2_1d_r_chebi(int nr, double* tb, double *xo){
00084     assert(nr>1) ;
00085     xo[0] = (3*tb[0]+tb[1])/4 ;
00086     for (int i=1 ; i<nr-1 ; i++)
00087     xo[i] = (tb[i-1]+2*tb[i]+tb[i+1])/4 ;
00088     xo[nr-1] = (tb[nr-2]+2*tb[nr-1])/4 ;
00089 }
00090 
00091             //---------------
00092             // cas R_CHEB --
00093             //---------------
00094 
00095 void _multx2_1d_r_cheb(int nr, double* tb, double *xo){
00096     assert(nr>3) ;
00097     xo[0] = (2*tb[0]+tb[2])/4 ;
00098     xo[1] = (3*tb[1]+tb[3])/4 ;
00099     xo[2] = (2*tb[0]+2*tb[2]+tb[4])/4 ;
00100     for (int i=3 ; i<nr-2 ; i++)
00101     xo[i] = (tb[i-2]+2*tb[i]+tb[i+2])/4 ;
00102     for (int i=nr-2 ; i<nr ; i++)
00103     xo[i] = (tb[i-2]+2*tb[i])/4 ;
00104 }
00105 
00106 
00107 
00108 
00109             //----------------------
00110             // La routine a appeler
00111             //----------------------
00112             
00113 void multx2_1d(int nr, double **tb, int base_r)     // Version appliquee a this
00114 {
00115 
00116 // Routines de derivation
00117 static void (*multx2_1d[MAX_BASE])(int, double *, double*) ;
00118 static int nap = 0 ;
00119 
00120     // Premier appel
00121     if (nap==0) {
00122     nap = 1 ;
00123     for (int i=0 ; i<MAX_BASE ; i++) {
00124         multx2_1d[i] = _multx2_1d_pas_prevu ;
00125     }
00126     // Les routines existantes
00127     multx2_1d[R_CHEB >> TRA_R] = _multx2_1d_r_cheb ;
00128     multx2_1d[R_CHEBP >> TRA_R] = _multx2_1d_r_chebp ;
00129     multx2_1d[R_CHEBI >> TRA_R] = _multx2_1d_r_chebi ;
00130     }
00131     
00132     double *result = new double[nr] ;
00133     multx2_1d[base_r](nr, *tb, result) ;
00134     
00135     delete [] (*tb) ;
00136     (*tb) = result ;
00137 }       

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