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_dsdx2_C[] = "$Header: /cvsroot/Lorene/C++/Source/Diff/diff_dsdx2.C,v 1.1 2005/01/10 16:34:52 j_novak Exp $" ;
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include <assert.h>
00043 #include <stdlib.h>
00044
00045
00046 #include "diff.h"
00047 #include "proto.h"
00048
00049 namespace {
00050 int nap = 0 ;
00051 Matrice* tab[MAX_BASE*Diff::max_points] ;
00052 int nr_done[Diff::max_points] ;
00053 }
00054
00055 Diff_dsdx2::Diff_dsdx2(int base_r, int nr) : Diff(base_r, nr) {
00056 initialize() ;
00057 }
00058
00059 Diff_dsdx2::Diff_dsdx2(const Diff_dsdx2& diff_in) : Diff(diff_in) {
00060 assert (nap != 0) ;
00061 }
00062
00063 Diff_dsdx2::~Diff_dsdx2() {}
00064
00065 void Diff_dsdx2::initialize() {
00066 if (nap == 0) {
00067 for (int i=0; i<max_points; i++) {
00068 nr_done[i] = -1 ;
00069 for (int j=0; j<MAX_BASE; j++)
00070 tab[j*max_points+i] = 0x0 ;
00071 }
00072 nap = 1 ;
00073 }
00074 return ;
00075 }
00076
00077 void Diff_dsdx2::operator=(const Diff_dsdx2& diff_in) {
00078 assert (nap != 0) ;
00079 Diff::operator=(diff_in) ;
00080
00081 }
00082
00083 const Matrice& Diff_dsdx2::get_matrice() const {
00084
00085 bool done = false ;
00086 int indice ;
00087 for (indice =0; indice<max_points; indice++) {
00088 if (nr_done[indice] == npoints) {
00089 if (tab[base*max_points + indice] != 0x0) done = true ;
00090 break ;
00091 }
00092 if (nr_done[indice] == -1)
00093 break ;
00094 }
00095 if (!done) {
00096 if (indice == max_points) {
00097 cerr << "Diff_dsdx2::get_matrice() : no space left!!" << '\n'
00098 << "The value of Diff.max_points must be increased..." << endl ;
00099 abort() ;
00100 }
00101 nr_done[indice] = npoints ;
00102 tab[base*max_points + indice] = new Matrice(npoints, npoints) ;
00103 Matrice& resu = *tab[base*max_points + indice] ;
00104 resu.set_etat_qcq() ;
00105
00106 double* vect = new double[npoints] ;
00107 for (int i=0; i<npoints; i++) {
00108 for (int j=0; j<npoints; j++)
00109 vect[j] = 0. ;
00110 vect[i] = 1. ;
00111 d2sdx2_1d(npoints, &vect, base << TRA_R) ;
00112 for (int j=0; j<npoints; j++)
00113 resu.set(j,i) = vect[j] ;
00114 }
00115 delete [] vect ;
00116 }
00117
00118 return *tab[base*max_points + indice] ;
00119 }
00120
00121 ostream& Diff_dsdx2::operator>>(ostream& ost) const {
00122
00123 ost << " d2 / dx2 " << endl ;
00124 return ost ;
00125
00126 }