ope_sec_order_r2_mat.C

00001 /*
00002  *   Copyright (c) 2003 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_sec_order_r2_mat_C[] = "$Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_sec_order_r2/ope_sec_order_r2_mat.C,v 1.1 2004/03/05 09:22:24 p_grandclement Exp $" ;
00022 
00023 /*
00024  * $Id: ope_sec_order_r2_mat.C,v 1.1 2004/03/05 09:22:24 p_grandclement Exp $
00025  * $Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_sec_order_r2/ope_sec_order_r2_mat.C,v 1.1 2004/03/05 09:22:24 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                       //-----------------------------------
00036                      // Routine pour les cas non prevus -- 
00037                      //-----------------------------------
00038 
00039 Matrice _sec_order_r2_mat_pas_prevu(int, double, double, double, 
00040                     double, double) {
00041   cout << "Sec_order_r2 : base not implemented..." << endl ;
00042   abort() ;
00043   exit(-1) ;
00044   Matrice res(1, 1) ;
00045   return res;
00046 }
00047 
00048 
00049 
00050                     //-------------------------
00051             //--   CAS R_CHEB   -----
00052             //------------------------
00053 
00054 Matrice _sec_order_r2_mat_r_cheb (int n, double alpha, double beta, 
00055                   double a, double b, double c) {
00056 
00057   double echelle = beta / alpha ;
00058   
00059   double* vect = new double[n] ;
00060   double* auxi = new double[n] ;
00061   double* res = new double[n] ;
00062   
00063   Matrice dd (n,n) ;
00064   dd.set_etat_qcq() ;
00065   Matrice df (n,n) ;
00066   df.set_etat_qcq() ;
00067   Matrice ff (n,n) ;
00068   ff.set_etat_qcq() ;
00069 
00070 
00071   // Calcul terme en R2 d^2...
00072   for (int i=0 ; i<n ; i++) {
00073     for (int j=0 ; j<n ; j++)
00074       vect[j] = 0 ;
00075     vect[i] = 1 ;
00076   
00077     d2sdx2_1d (n, &vect, R_CHEB) ;  // appel dans le cas fin
00078     
00079     for (int j=0 ; j<n ; j++)
00080       auxi[j] = vect[j] ;  
00081     multx_1d (n, &auxi, R_CHEB) ;
00082     multx_1d (n, &auxi, R_CHEB) ;
00083     for (int j=0 ; j<n ; j++)
00084       res[j] = auxi[j] ;
00085     
00086     for (int j=0 ; j<n ; j++)
00087       auxi[j] = vect[j] ;  
00088     multx_1d (n, &auxi, R_CHEB) ;
00089     for (int j=0 ; j<n ; j++)
00090       res[j] += auxi[j]*2*echelle ;
00091 
00092     for (int j=0 ; j<n ; j++)
00093       res[j] += echelle*echelle*vect[j] ;
00094 
00095     for (int j=0 ; j<n ; j++)
00096       dd.set(j,i) = res[j] ;
00097   }
00098 
00099   // Calcul terme en R d...
00100   for (int i=0 ; i<n ; i++) {
00101     for (int j=0 ; j<n ; j++)
00102       vect[j] = 0 ;
00103     vect[i] = 1 ;
00104   
00105     sxdsdx_1d (n, &vect, R_CHEB) ;  // appel dans le cas fin
00106     
00107     for (int j=0 ; j<n ; j++)
00108       auxi[j] = vect[j] ;  
00109     multx_1d (n, &auxi, R_CHEB) ;
00110     for (int j=0 ; j<n ; j++)
00111       res[j] = auxi[j] ;
00112     
00113     for (int j=0 ; j<n ; j++)
00114       res[j] += echelle*vect[j] ;
00115 
00116     for (int j=0 ; j<n ; j++)
00117       df.set(j,i) = res[j] ;
00118   }
00119 
00120   // Calcul terme en R d...
00121   for (int i=0 ; i<n ; i++) {
00122     for (int j=0 ; j<n ; j++)
00123       ff.set(j,i) = 0 ;
00124     ff.set(i,i) = 1 ;
00125   }
00126 
00127   delete [] vect ;
00128   delete [] auxi ;
00129   delete [] res ;
00130 
00131   return a*dd+b*df+c*ff ;
00132 }
00133 
00134 void Ope_sec_order_r2::do_ope_mat() const {
00135   if (ope_mat != 0x0) 
00136     delete ope_mat ;
00137 
00138   // Routines de derivation
00139   static Matrice (*sec_order_r2_mat[MAX_BASE])(int, double, double, double, 
00140                            double, double);
00141   static int nap = 0 ;
00142   
00143   // Premier appel
00144   if (nap==0) {
00145     nap = 1 ;
00146     for (int i=0 ; i<MAX_BASE ; i++) {
00147       sec_order_r2_mat[i] = _sec_order_r2_mat_pas_prevu ;
00148     }
00149     // Les routines existantes
00150     sec_order_r2_mat[R_CHEB >> TRA_R] = _sec_order_r2_mat_r_cheb ;
00151   }
00152   ope_mat = new Matrice(sec_order_r2_mat[base_r](nr, alpha, beta, a_param, 
00153                          b_param, c_param)) ;
00154 }

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