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_dsdx_C[] = "$Header: /cvsroot/Lorene/C++/Source/Diff/diff_dsdx.C,v 1.2 2006/04/10 15:20:52 j_novak 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 namespace {
00053 int nap = 0 ;
00054 Matrice* tab[MAX_BASE*Diff::max_points] ;
00055 int nr_done[Diff::max_points] ;
00056 }
00057
00058 Diff_dsdx::Diff_dsdx(int base_r, int nr) : Diff(base_r, nr) {
00059 initialize() ;
00060 }
00061
00062 Diff_dsdx::Diff_dsdx(const Diff_dsdx& diff_in) : Diff(diff_in) {
00063 assert (nap != 0) ;
00064 }
00065
00066 Diff_dsdx::~Diff_dsdx() {}
00067
00068 void Diff_dsdx::initialize() {
00069 if (nap == 0) {
00070 for (int i=0; i<max_points; i++) {
00071 nr_done[i] = -1 ;
00072 for (int j=0; j<MAX_BASE; j++)
00073 tab[j*max_points+i] = 0x0 ;
00074 }
00075 nap = 1 ;
00076 }
00077 return ;
00078 }
00079
00080 void Diff_dsdx::operator=(const Diff_dsdx& diff_in) {
00081 assert (nap != 0) ;
00082 Diff::operator=(diff_in) ;
00083
00084 }
00085
00086 const Matrice& Diff_dsdx::get_matrice() const {
00087
00088 bool done = false ;
00089 int indice ;
00090 for (indice =0; indice<max_points; indice++) {
00091 if (nr_done[indice] == npoints) {
00092 if (tab[base*max_points + indice] != 0x0) done = true ;
00093 break ;
00094 }
00095 if (nr_done[indice] == -1)
00096 break ;
00097 }
00098 if (!done) {
00099 if (indice == max_points) {
00100 cerr << "Diff_dsdx::get_matrice() : no space left!!" << '\n'
00101 << "The value of Diff.max_points must be increased..." << endl ;
00102 abort() ;
00103 }
00104 nr_done[indice] = npoints ;
00105 tab[base*max_points + indice] = new Matrice(npoints, npoints) ;
00106 Matrice& resu = *tab[base*max_points + indice] ;
00107 resu.set_etat_qcq() ;
00108
00109 double* vect = new double[npoints] ;
00110 for (int i=0; i<npoints; i++) {
00111 for (int j=0; j<npoints; j++)
00112 vect[j] = 0. ;
00113 vect[i] = 1. ;
00114 dsdx_1d(npoints, &vect, base << TRA_R) ;
00115 for (int j=0; j<npoints; j++)
00116 resu.set(j,i) = vect[j] ;
00117 }
00118 delete [] vect ;
00119 }
00120 return *tab[base*max_points + indice] ;
00121 }
00122
00123 ostream& Diff_dsdx::operator>>(ostream& ost) const {
00124
00125 ost << " d / dx " << endl ;
00126
00127 return ost ;
00128
00129 }