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_x3dsdx2_C[] = "$Header: /cvsroot/Lorene/C++/Source/Diff/diff_x3dsdx2.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
00046
00047
00048 #include <assert.h>
00049 #include <stdlib.h>
00050
00051
00052 #include "diff.h"
00053 #include "proto.h"
00054
00055 void multxpun_1d(int, double**, int) ;
00056 void mult2_xp1_1d(int, double**, int) ;
00057
00058 namespace {
00059 int nap = 0 ;
00060 Matrice* tab[MAX_BASE*Diff::max_points] ;
00061 int nr_done[Diff::max_points] ;
00062 }
00063
00064 Diff_x3dsdx2::Diff_x3dsdx2(int base_r, int nr) : Diff(base_r, nr) {
00065 initialize() ;
00066 assert ((base != R_CHEBP)&&(base != R_CHEBI)) ;
00067 }
00068
00069 Diff_x3dsdx2::Diff_x3dsdx2(const Diff_x3dsdx2& diff_in) : Diff(diff_in) {
00070 assert (nap != 0) ;
00071 assert ((base != R_CHEBP)&&(base != R_CHEBI)) ;
00072 }
00073
00074 Diff_x3dsdx2::~Diff_x3dsdx2() {}
00075
00076 void Diff_x3dsdx2::initialize() {
00077 if (nap == 0) {
00078 for (int i=0; i<max_points; i++) {
00079 nr_done[i] = -1 ;
00080 for (int j=0; j<MAX_BASE; j++)
00081 tab[j*max_points+i] = 0x0 ;
00082 }
00083 nap = 1 ;
00084 }
00085 return ;
00086 }
00087
00088 void Diff_x3dsdx2::operator=(const Diff_x3dsdx2& diff_in) {
00089 assert (nap != 0) ;
00090 Diff::operator=(diff_in) ;
00091
00092 }
00093
00094 const Matrice& Diff_x3dsdx2::get_matrice() const {
00095
00096 bool done = false ;
00097 int indice ;
00098 for (indice =0; indice<max_points; indice++) {
00099 if (nr_done[indice] == npoints) {
00100 if (tab[base*max_points + indice] != 0x0) done = true ;
00101 break ;
00102 }
00103 if (nr_done[indice] == -1)
00104 break ;
00105 }
00106 if (!done) {
00107 if (indice == max_points) {
00108 cerr << "Diff_x3dsdx2::get_matrice() : no space left!!" << '\n'
00109 << "The value of Diff.max_points must be increased..." << endl ;
00110 abort() ;
00111 }
00112 nr_done[indice] = npoints ;
00113 tab[base*max_points + indice] = new Matrice(npoints, npoints) ;
00114 Matrice& resu = *tab[base*max_points + indice] ;
00115 resu.set_etat_qcq() ;
00116
00117 double* vect = new double[npoints] ;
00118 double* cres = new double[npoints] ;
00119 for (int i=0; i<npoints; i++) {
00120 for (int j=0; j<npoints; j++)
00121 vect[j] = 0. ;
00122 vect[i] = 1. ;
00123 d2sdx2_1d(npoints, &vect, base << TRA_R) ;
00124 if (base == R_CHEBU) {
00125 mult_xm1_1d_cheb(npoints, vect, cres) ;
00126 mult2_xm1_1d_cheb(npoints, cres, vect) ;
00127 for (int j=0; j<npoints; j++)
00128 resu.set(j,i) = vect[j] ;
00129 }
00130 else if (base == R_JACO02) {
00131 multxpun_1d(npoints, &vect, base << TRA_R) ;
00132 mult2_xp1_1d(npoints, &vect, base << TRA_R) ;
00133 for (int j=0; j<npoints ; j++)
00134 resu.set(j,i) = vect[j] ;
00135 }
00136 else {
00137 multx_1d(npoints, &vect, base << TRA_R) ;
00138 multx2_1d(npoints, &vect, base << TRA_R) ;
00139 for (int j=0; j<npoints; j++)
00140 resu.set(j,i) = vect[j] ;
00141 }
00142 }
00143 delete [] vect ;
00144 delete [] cres ;
00145 }
00146 return *tab[base*max_points + indice] ;
00147 }
00148
00149 ostream& Diff_x3dsdx2::operator>>(ostream& ost) const {
00150
00151 ost << " x^3 d2 / dx2 " << endl ;
00152
00153 return ost ;
00154
00155 }