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