00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 char diff_x2dsdx2_C[] = "$Header: /cvsroot/Lorene/C++/Source/Diff/diff_x2dsdx2.C,v 1.2 2007/12/11 15:28:11 jl_cornou Exp $" ;
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #include <assert.h>
00046 #include <stdlib.h>
00047
00048
00049 #include "diff.h"
00050 #include "proto.h"
00051
00052 void mult2_xp1_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_x2dsdx2::Diff_x2dsdx2(int base_r, int nr) : Diff(base_r, nr) {
00061 initialize() ;
00062 }
00063
00064 Diff_x2dsdx2::Diff_x2dsdx2(const Diff_x2dsdx2& diff_in) : Diff(diff_in) {
00065 assert (nap != 0) ;
00066 }
00067
00068 Diff_x2dsdx2::~Diff_x2dsdx2() {}
00069
00070 void Diff_x2dsdx2::initialize() {
00071 if (nap == 0) {
00072 for (int i=0; i<max_points; i++) {
00073 nr_done[i] = -1 ;
00074 for (int j=0; j<MAX_BASE; j++)
00075 tab[j*max_points+i] = 0x0 ;
00076 }
00077 nap = 1 ;
00078 }
00079 return ;
00080 }
00081
00082 void Diff_x2dsdx2::operator=(const Diff_x2dsdx2& diff_in) {
00083 assert (nap != 0) ;
00084 Diff::operator=(diff_in) ;
00085
00086 }
00087
00088 const Matrice& Diff_x2dsdx2::get_matrice() const {
00089
00090 bool done = false ;
00091 int indice ;
00092 for (indice =0; indice<max_points; indice++) {
00093 if (nr_done[indice] == npoints) {
00094 if (tab[base*max_points + indice] != 0x0) done = true ;
00095 break ;
00096 }
00097 if (nr_done[indice] == -1)
00098 break ;
00099 }
00100 if (!done) {
00101 if (indice == max_points) {
00102 cerr << "Diff_x2dsdx2::get_matrice() : no space left!!" << '\n'
00103 << "The value of Diff.max_points must be increased..." << endl ;
00104 abort() ;
00105 }
00106 nr_done[indice] = npoints ;
00107 tab[base*max_points + indice] = new Matrice(npoints, npoints) ;
00108 Matrice& resu = *tab[base*max_points + indice] ;
00109 resu.set_etat_qcq() ;
00110
00111 double* vect = new double[npoints] ;
00112 double* cres = new double[npoints] ;
00113 for (int i=0; i<npoints; i++) {
00114 for (int j=0; j<npoints; j++)
00115 vect[j] = 0. ;
00116 vect[i] = 1. ;
00117 d2sdx2_1d(npoints, &vect, base << TRA_R) ;
00118 if (base == R_CHEBU) {
00119 mult2_xm1_1d_cheb(npoints, vect, cres) ;
00120 for (int j=0; j<npoints; j++)
00121 resu.set(j,i) = cres[j] ;
00122 }
00123 else if (base == R_JACO02) {
00124 mult2_xp1_1d(npoints, &vect, base << TRA_R) ;
00125 for (int j=0; j<npoints; j++)
00126 resu.set(j,i)= vect[j] ;
00127 }
00128 else {
00129 multx2_1d(npoints, &vect, base << TRA_R) ;
00130 for (int j=0; j<npoints; j++)
00131 resu.set(j,i) = vect[j] ;
00132 }
00133 }
00134 delete [] vect ;
00135 delete [] cres ;
00136 }
00137
00138 return *tab[base*max_points + indice] ;
00139 }
00140
00141 ostream& Diff_x2dsdx2::operator>>(ostream& ost) const {
00142
00143 ost << " x^2 d2 / dx2 " << endl ;
00144 return ost ;
00145
00146 }