ope_sec_order_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_mat_C[] = "$Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_sec_order/ope_sec_order_mat.C,v 1.1 2004/06/22 12:43:58 p_grandclement Exp $" ;
00022 
00023 /*
00024  * $Id: ope_sec_order_mat.C,v 1.1 2004/06/22 12:43:58 p_grandclement Exp $
00025  * $Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_sec_order/ope_sec_order_mat.C,v 1.1 2004/06/22 12:43:58 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_mat_pas_prevu(int, double, double, double, double) {
00040   cout << "Sec_order : base not implemented..." << endl ;
00041   abort() ;
00042   exit(-1) ;
00043   Matrice res(1, 1) ;
00044   return res;
00045 }
00046 
00047 
00048 
00049                     //-------------------------
00050             //--   CAS R_CHEB   -----
00051             //------------------------
00052 
00053 Matrice _sec_order_mat_r_cheb (int n, double alpha, 
00054                    double a, double b, double c) {
00055   
00056   double* vect = new double[n] ;
00057   
00058   Matrice dd (n,n) ;
00059   dd.set_etat_qcq() ;
00060   Matrice df (n,n) ;
00061   df.set_etat_qcq() ;
00062   Matrice ff (n,n) ;
00063   ff.set_etat_qcq() ;
00064 
00065 
00066   // Calcul terme en d^2...
00067   for (int i=0 ; i<n ; i++) {
00068     for (int j=0 ; j<n ; j++)
00069       vect[j] = 0 ;
00070     vect[i] = 1 ;
00071   
00072     d2sdx2_1d (n, &vect, R_CHEB) ;  // appel dans le cas fin
00073 
00074     for (int j=0 ; j<n ; j++)
00075       dd.set(j,i) = vect[j] ;
00076   }
00077 
00078   // Calcul terme en d...
00079   for (int i=0 ; i<n ; i++) {
00080     for (int j=0 ; j<n ; j++)
00081       vect[j] = 0 ;
00082     vect[i] = 1 ;
00083   
00084     sxdsdx_1d (n, &vect, R_CHEB) ;  // appel dans le cas fin
00085     
00086     for (int j=0 ; j<n ; j++)
00087       df.set(j,i) = vect[j] ;
00088   }
00089 
00090   // Calcul terme Id
00091   for (int i=0 ; i<n ; i++) {
00092     for (int j=0 ; j<n ; j++)
00093       ff.set(j,i) = 0 ;
00094     ff.set(i,i) = 1 ;
00095   }
00096 
00097   delete [] vect ;
00098 
00099   return a*dd/alpha/alpha+b*df/alpha+c*ff ;
00100 }
00101 
00102 void Ope_sec_order::do_ope_mat() const {
00103   if (ope_mat != 0x0) 
00104     delete ope_mat ;
00105 
00106   // Routines de derivation
00107   static Matrice (*sec_order_mat[MAX_BASE])(int, double, 
00108                         double, double, double);
00109   static int nap = 0 ;
00110   
00111   // Premier appel
00112   if (nap==0) {
00113     nap = 1 ;
00114     for (int i=0 ; i<MAX_BASE ; i++) {
00115       sec_order_mat[i] = _sec_order_mat_pas_prevu ;
00116     }
00117     // Les routines existantes
00118     sec_order_mat[R_CHEB >> TRA_R] = _sec_order_mat_r_cheb ;
00119   }
00120   ope_mat = new Matrice(sec_order_mat[base_r](nr, alpha, 
00121                           a_param, b_param, c_param)) ;
00122 }

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