ope_poisson_pseudo_1d_mat.C

00001 /*
00002  *   Copyright (c) 2004 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 version 2
00008  *   as published by the Free Software Foundation.
00009  *
00010  *   LORENE is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with LORENE; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  *
00019  */
00020 
00021 char ope_poisson_pseudo_1d_mat_C[] = "$Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_poisson_pseudo_1d/ope_poisson_pseudo_1d_mat.C,v 1.1 2004/08/24 09:14:48 p_grandclement Exp $" ;
00022 
00023 /*
00024  * $Id: ope_poisson_pseudo_1d_mat.C,v 1.1 2004/08/24 09:14:48 p_grandclement Exp $
00025  * $Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_poisson_pseudo_1d/ope_poisson_pseudo_1d_mat.C,v 1.1 2004/08/24 09:14:48 p_grandclement Exp $
00026  *
00027  */
00028 #include <math.h>
00029 #include <stdlib.h>
00030 
00031 #include "proto.h"
00032 #include "ope_elementary.h"
00033 
00034         //-----------------------------------
00035         // Routine pour les cas non prevus --
00036         //-----------------------------------
00037 
00038 Matrice _poisson_pseudo_1d_mat_pas_prevu(int, int, double, double) {
00039     cout << "Operator pas prevu..." << endl ;
00040     abort() ;
00041     exit(-1) ;
00042     Matrice res(1, 1) ;
00043     return res;
00044 }
00045 
00046 
00047            //-------------------------
00048            //--   CAS R_CHEBP    -----
00049            //--------------------------
00050             
00051 
00052 Matrice _poisson_pseudo_1d_mat_r_chebp (int n, int l, double, double) {
00053 
00054   Matrice dd(n, n) ;
00055   dd.set_etat_qcq() ;
00056   Matrice xx(n, n) ;
00057   xx.set_etat_qcq() ;
00058   
00059   double* vect  = new double[n] ;
00060     
00061   for (int i=0 ; i<n ; i++) {
00062     for (int j=0 ; j<n ; j++)
00063       vect[j] = 0 ;
00064     vect[i] = 1 ;
00065     d2sdx2_1d (n, &vect, R_CHEBP) ;
00066     
00067     for (int j=0 ; j<n ; j++)
00068       dd.set(j, i) = vect[j] ; 
00069   }
00070   
00071   for (int i=0 ; i<n ; i++) {
00072     for (int j=0 ; j<n ; j++)
00073       vect[j] = 0 ;
00074     vect[i] = 1 ;
00075     sx2_1d (n, &vect, R_CHEBP) ;
00076     for (int j=0 ; j<n ; j++)
00077       xx.set(j, i) = vect[j] ;
00078   }
00079   
00080   delete [] vect ;
00081   
00082   Matrice res(n, n) ;
00083   res = dd-l*(l-1)*xx ;
00084     
00085   return res ;
00086 }
00087 
00088 
00089            //------------------------
00090            //--   CAS R_CHEBI    ----
00091            //------------------------
00092             
00093 
00094 Matrice _poisson_pseudo_1d_mat_r_chebi (int n, int l,
00095                     double, double) {
00096   
00097     Matrice dd(n, n) ;
00098     dd.set_etat_qcq() ;
00099     Matrice xx(n, n) ;
00100     xx.set_etat_qcq() ;
00101 
00102     double* vect = new double[n] ;
00103     
00104     for (int i=0 ; i<n ; i++) {
00105     for (int j=0 ; j<n ; j++)
00106         vect[j] = 0 ;
00107     vect[i] = 1 ;
00108     d2sdx2_1d (n, &vect, R_CHEBI) ;  // appel dans le cas impair
00109     for (int j=0 ; j<n ; j++)
00110         dd.set(j, i) = vect[j] ;
00111     }
00112     
00113     for (int i=0 ; i<n ; i++) {
00114     for (int j=0 ; j<n ; j++)
00115         vect[j] = 0 ;
00116     vect[i] = 1 ;
00117     sx2_1d (n, &vect, R_CHEBI) ;
00118     for (int j=0 ; j<n ; j++)
00119         xx.set(j, i) = vect[j] ;
00120     }
00121     
00122     delete [] vect ;
00123     
00124     Matrice res(n, n) ;
00125     res = dd-l*(l-1)*xx ;
00126     return res ;
00127 } 
00128 
00129            //-------------------------
00130            //--   CAS R_CHEB    -----
00131            //-----------------------
00132             
00133 
00134 Matrice _poisson_pseudo_1d_mat_r_cheb (int n, int l, 
00135                        double alf, double bet) {
00136             
00137   double echelle = bet / alf ;
00138 
00139   
00140     Matrice dd(n, n) ;
00141     dd.set_etat_qcq() ;
00142     Matrice xx(n, n) ;
00143     xx.set_etat_qcq() ;
00144 
00145     double* vect = new double[n] ;
00146     
00147     for (int i=0 ; i<n ; i++) {
00148     for (int j=0 ; j<n ; j++)
00149         vect[j] = 0 ;
00150     vect[i] = 1 ;
00151     d2sdx2_1d (n, &vect, R_CHEB) ;  // appel dans le cas fin
00152     for (int j=0 ; j<n ; j++)
00153         dd.set(j, i) = vect[j]*echelle*echelle ;
00154     }
00155     
00156     for (int i=0 ; i<n ; i++) {
00157     for (int j=0 ; j<n ; j++)
00158         vect[j] = 0 ;
00159     vect[i] = 1 ;
00160     d2sdx2_1d (n, &vect, R_CHEB) ;  // appel dans le cas fin
00161     multx_1d (n, &vect, R_CHEB) ;
00162     for (int j=0 ; j<(n>i+1 ? i+1 : n) ; j++)
00163         dd.set(j, i) += 2*echelle*vect[j] ;
00164     }
00165     
00166     for (int i=0 ; i<n ; i++) {
00167     for (int j=0 ; j<n ; j++)
00168         vect[j] = 0 ;
00169     vect[i] = 1 ;
00170     d2sdx2_1d (n, &vect, R_CHEB) ;  // appel dans le cas fin
00171     multx_1d (n, &vect, R_CHEB) ;
00172     multx_1d (n, &vect, R_CHEB) ;
00173     for (int j=0 ; j<(n>i+1 ? i+1 : n) ; j++)
00174         dd.set(j, i) += vect[j] ;
00175     }
00176        
00177     for (int i=0 ; i<n ; i++) {
00178     for (int j=0 ; j<n ; j++)
00179         vect[j] = 0 ;
00180     vect[i] = 1 ;
00181     sx2_1d (n, &vect, R_CHEB) ;
00182     for (int j=0 ; j<n ; j++)
00183         xx.set(j, i) = vect[j] ;
00184     }
00185     
00186     delete [] vect ;
00187     
00188     Matrice res(n, n) ;
00189     res = dd-l*(l-1)*xx ;
00190     return res ;
00191 } 
00192 
00193 
00194 void Ope_poisson_pseudo_1d::do_ope_mat() const {
00195   if (ope_mat != 0x0) 
00196     delete ope_mat ;
00197 
00198   // Routines de derivation
00199   static Matrice (*poisson_pseudo_1d_mat[MAX_BASE])(int, int, double, double);
00200   static int nap = 0 ;
00201   
00202   // Premier appel
00203   if (nap==0) {
00204     nap = 1 ;
00205     for (int i=0 ; i<MAX_BASE ; i++) {
00206       poisson_pseudo_1d_mat[i] = _poisson_pseudo_1d_mat_pas_prevu ;
00207     }
00208     // Les routines existantes
00209     poisson_pseudo_1d_mat[R_CHEB >> TRA_R] = _poisson_pseudo_1d_mat_r_cheb ;
00210     poisson_pseudo_1d_mat[R_CHEBP >> TRA_R] = _poisson_pseudo_1d_mat_r_chebp ;
00211     poisson_pseudo_1d_mat[R_CHEBI >> TRA_R] = _poisson_pseudo_1d_mat_r_chebi ;
00212   }
00213   ope_mat = new Matrice(poisson_pseudo_1d_mat[base_r](nr, l_quant, 
00214                               alpha, beta)) ;
00215 }

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