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