ope_helmholtz_minus_2d_cl.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_helmholtz_minus_2d_cl_C[] = "$Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_helmholtz_minus_2d/ope_helmholtz_minus_2d_cl.C,v 1.1 2004/08/24 09:14:46 p_grandclement Exp $" ;
00022 
00023 /*
00024  * $Id: ope_helmholtz_minus_2d_cl.C,v 1.1 2004/08/24 09:14:46 p_grandclement Exp $
00025  * $Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_helmholtz_minus_2d/ope_helmholtz_minus_2d_cl.C,v 1.1 2004/08/24 09:14:46 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 // Version Matrice --> Matrice
00035 Matrice _cl_helmholtz_minus_2d_pas_prevu (const Matrice & source, int) {
00036     cout << "Combinaison lineaire pas prevu..." << endl ;
00037     abort() ;
00038     exit(-1) ;
00039     return source;
00040 }
00041 
00042 
00043         //-------------------
00044            //--  R_CHEB   ------
00045           //-------------------
00046 
00047 Matrice _cl_helmholtz_minus_2d_r_cheb (const Matrice &source, int) {
00048    int n = source.get_dim(0) ;
00049     assert (n == source.get_dim(1)) ;
00050     Matrice barre(source) ;
00051     int dirac = 1 ;
00052     for (int i=0 ; i<n-2 ; i++) {
00053     for (int j=0 ; j<n ; j++)
00054         barre.set(i, j) = ((1+dirac)*source(i, j)-source(i+2, j))
00055                 /(i+1) ;
00056     if (i==0) dirac = 0 ;
00057     }
00058     
00059     Matrice res(barre) ;
00060     for (int i=0 ; i<n-4 ; i++)
00061     for (int j=0 ; j<n ; j++)
00062         res.set(i, j) = barre(i, j)-barre(i+2, j) ;
00063     
00064     return res ;
00065 }
00066 
00067         //-------------------
00068            //--  R_CHEBU   -----
00069           //-------------------
00070 
00071 Matrice _cl_helmholtz_minus_2d_r_chebu_deux (const Matrice&) ;
00072 
00073 
00074 Matrice _cl_helmholtz_minus_2d_r_chebu (const Matrice &source, int puis) {
00075     int n = source.get_dim(0) ;
00076     assert (n == source.get_dim(1)) ;
00077     
00078     Matrice res(n, n) ;
00079     res.set_etat_qcq() ;
00080     
00081     switch (puis) {
00082     case 2 :
00083         res = _cl_helmholtz_minus_2d_r_chebu_deux(source) ;
00084         break ;
00085     default :
00086         abort() ;
00087         exit(-1) ;
00088     }
00089     
00090     return res ;
00091 }
00092 
00093 
00094 //Cas dzpuis == 2
00095 Matrice _cl_helmholtz_minus_2d_r_chebu_deux (const Matrice &source) {
00096 
00097   int n = source.get_dim(0) ;
00098   assert (n == source.get_dim(1)) ;
00099     
00100   Matrice barre(source) ;
00101   int dirac = 1 ;
00102   for (int i=0 ; i<n-2 ; i++) {
00103     for (int j=0 ; j<n ; j++)
00104       barre.set(i, j) = ((1+dirac)*source(i, j)-source(i+2, j)) ;
00105     if (i==0) dirac = 0 ;
00106   }
00107    
00108   Matrice tilde(barre) ;
00109   for (int i=0 ; i<n-4 ; i++)
00110     for (int j=0 ; j<n ; j++)
00111       tilde.set(i, j) = (barre(i, j)-barre(i+2, j)) ;
00112   
00113   Matrice bis(tilde) ;
00114   for (int i=0 ; i<n-4 ; i++)
00115     for (int j=0 ; j<n ; j++)
00116       bis.set(i, j) = (tilde(i, j)+tilde(i+1, j)) ;
00117 
00118   Matrice res (bis) ;
00119   for (int i=0 ; i<n-4 ; i++)
00120     for (int j=0 ; j<n ; j++)
00121       res.set(i, j) = (bis(i, j)-bis(i+1, j)) ;
00122 
00123   return res ;
00124 }
00125 
00126 void Ope_helmholtz_minus_2d::do_ope_cl() const {
00127   if (ope_mat == 0x0)
00128     do_ope_mat() ;
00129 
00130   if (ope_cl != 0x0)
00131     delete ope_cl ;
00132   
00133   // Routines de derivation
00134   static Matrice (*cl_helmholtz_minus_2d[MAX_BASE])(const Matrice&, int);
00135   static int nap = 0 ;
00136   
00137   // Premier appel
00138   if (nap==0) {
00139     nap = 1 ;
00140     for (int i=0 ; i<MAX_BASE ; i++) {
00141       cl_helmholtz_minus_2d[i] = _cl_helmholtz_minus_2d_pas_prevu ;
00142     }
00143     // Les routines existantes
00144     cl_helmholtz_minus_2d[R_CHEB >> TRA_R] = _cl_helmholtz_minus_2d_r_cheb ;
00145     cl_helmholtz_minus_2d[R_CHEBU >> TRA_R] = _cl_helmholtz_minus_2d_r_chebu ;
00146   }
00147   ope_cl = new Matrice(cl_helmholtz_minus_2d[base_r](*ope_mat, dzpuis)) ;
00148 }
00149 
00150 

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