diff_xdsdx2.C

00001 /*
00002  *  Methods for the class Diff_xdsdx2
00003  *
00004  *    (see file diff.h for documentation).
00005  *
00006  */
00007 
00008 /*
00009  *   Copyright (c) 2005 Jerome Novak
00010  *
00011  *   This file is part of LORENE.
00012  *
00013  *   LORENE is free software; you can redistribute it and/or modify
00014  *   it under the terms of the GNU General Public License version 2
00015  *   as published by the Free Software Foundation.
00016  *
00017  *   LORENE is distributed in the hope that it will be useful,
00018  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  *   GNU General Public License for more details.
00021  *
00022  *   You should have received a copy of the GNU General Public License
00023  *   along with LORENE; if not, write to the Free Software
00024  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025  *
00026  */
00027 
00028 char diff_xdsdx2_C[] = "$Header: /cvsroot/Lorene/C++/Source/Diff/diff_xdsdx2.C,v 1.2 2007/12/11 15:28:11 jl_cornou Exp $" ;
00029 
00030 /*
00031  * $Id: diff_xdsdx2.C,v 1.2 2007/12/11 15:28:11 jl_cornou Exp $
00032  * $Log: diff_xdsdx2.C,v $
00033  * Revision 1.2  2007/12/11 15:28:11  jl_cornou
00034  * Jacobi(0,2) polynomials partially implemented
00035  *
00036  * Revision 1.1  2005/01/10 16:34:52  j_novak
00037  * New class for 1D mono-domain differential operators.
00038  *
00039  *
00040  * $Header: /cvsroot/Lorene/C++/Source/Diff/diff_xdsdx2.C,v 1.2 2007/12/11 15:28:11 jl_cornou Exp $
00041  *
00042  */
00043 
00044 // C headers
00045 #include <assert.h>
00046 #include <stdlib.h>
00047 
00048 // Lorene headers
00049 #include "diff.h"
00050 #include "proto.h"
00051 
00052 void multxpun_1d(int, double**, int) ;
00053 
00054 namespace {
00055     int nap = 0 ;
00056     Matrice* tab[MAX_BASE*Diff::max_points] ;
00057     int nr_done[Diff::max_points] ;
00058 }
00059 
00060 Diff_xdsdx2::Diff_xdsdx2(int base_r, int nr) : Diff(base_r, nr) {
00061     initialize() ;
00062     assert ((base != R_CHEBP)&&(base != R_CHEBI)) ;
00063 }
00064 
00065 Diff_xdsdx2::Diff_xdsdx2(const Diff_xdsdx2& diff_in) : Diff(diff_in) {
00066     assert (nap != 0) ;
00067     assert ((base != R_CHEBP)&&(base != R_CHEBI)) ;
00068 } 
00069 
00070 Diff_xdsdx2::~Diff_xdsdx2() {}
00071 
00072 void Diff_xdsdx2::initialize() {
00073     if (nap == 0) {
00074     for (int i=0; i<max_points; i++) {
00075         nr_done[i] = -1 ;
00076         for (int j=0; j<MAX_BASE; j++) 
00077         tab[j*max_points+i] = 0x0 ;
00078     }
00079     nap = 1 ;
00080     }
00081     return ;
00082 }
00083 
00084 void Diff_xdsdx2::operator=(const Diff_xdsdx2& diff_in) {
00085     assert (nap != 0) ;
00086     Diff::operator=(diff_in) ;
00087 
00088 }
00089 
00090 const Matrice& Diff_xdsdx2::get_matrice() const {
00091     
00092     bool done = false ;
00093     int indice ;
00094     for (indice =0; indice<max_points; indice++) {
00095     if (nr_done[indice] == npoints) {
00096         if (tab[base*max_points + indice] != 0x0) done = true ;
00097         break ;
00098     }
00099     if (nr_done[indice] == -1)
00100         break ;
00101     }
00102     if (!done) { //The computation must be done ...
00103     if (indice == max_points) {
00104         cerr << "Diff_xdsdx2::get_matrice() : no space left!!" << '\n'
00105          << "The value of Diff.max_points must be increased..." << endl ;
00106         abort() ;
00107     }
00108     nr_done[indice] = npoints ;
00109     tab[base*max_points + indice] = new Matrice(npoints, npoints) ;
00110     Matrice& resu = *tab[base*max_points + indice] ;
00111     resu.set_etat_qcq() ;
00112 
00113     double* vect = new double[npoints] ;
00114     double* cres = new double[npoints] ;
00115     for (int i=0; i<npoints; i++) {
00116         for (int j=0; j<npoints; j++)
00117         vect[j] = 0. ;
00118         vect[i] = 1. ;
00119         d2sdx2_1d(npoints, &vect, base << TRA_R) ;
00120         if (base == R_CHEBU) {
00121         mult_xm1_1d_cheb(npoints, vect, cres) ;
00122         for (int j=0; j<npoints; j++)
00123             resu.set(j,i) = cres[j] ;
00124         }
00125         else if (base == R_JACO02) {
00126         multxpun_1d(npoints, &vect, base << TRA_R) ;
00127         for (int j=0; j<npoints; j++)
00128             resu.set(j,i) = vect[j] ;
00129         }
00130         else {
00131         multx_1d(npoints, &vect, base << TRA_R) ;
00132         for (int j=0; j<npoints; j++)
00133             resu.set(j,i) = vect[j] ;
00134         }
00135     }
00136     delete [] vect ;
00137     delete [] cres ;
00138     }
00139     return *tab[base*max_points + indice] ;
00140 }
00141 
00142 ostream& Diff_xdsdx2::operator>>(ostream& ost) const {
00143 
00144     ost << " x d2 / dx2 " << endl ;
00145 
00146     return ost ;
00147 
00148 }

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