00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 char xdsdx_mat_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/xdsdx_mat.C,v 1.3 2007/06/21 20:07:16 k_taniguchi Exp $" ;
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 #include <stdio.h>
00056 #include <stdlib.h>
00057
00058 #include "matrice.h"
00059 #include "type_parite.h"
00060 #include "proto.h"
00061
00062
00063
00064
00065
00066 Matrice _xdsdx_mat_pas_prevu(int n, int) {
00067 cout << "xdsdx_mat pas prevu..." << endl ;
00068 cout << "n : " << n << endl ;
00069 abort() ;
00070 exit(-1) ;
00071 Matrice res(1, 1) ;
00072 return res;
00073 }
00074
00075
00076
00077
00078
00079
00080
00081 Matrice _xdsdx_mat_r_chebp (int n, int) {
00082 const int nmax = 200 ;
00083 static Matrice* tab[nmax] ;
00084 static int nb_dejafait = 0 ;
00085 static int nr_dejafait[nmax] ;
00086
00087 int indice = -1 ;
00088
00089
00090 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00091 if (nr_dejafait[conte] == n)
00092 indice = conte ;
00093
00094
00095 if (indice == -1) {
00096 if (nb_dejafait >= nmax) {
00097 cout << "_laplacien_nul_mat_r_chebp : trop de matrices" << endl ;
00098 abort() ;
00099 exit (-1) ;
00100 }
00101
00102 nr_dejafait[nb_dejafait] = n ;
00103
00104 Matrice res(n-1, n-1) ;
00105 res.set_etat_qcq() ;
00106
00107 double* xdsdx = new double[n] ;
00108
00109 for (int i=0 ; i<n-1 ; i++) {
00110 for (int j=0 ; j<n ; j++)
00111 xdsdx[j] = 0 ;
00112 xdsdx[i] = 1 ;
00113 xdsdx[i+1] = 1 ;
00114 xdsdx_1d (n, &xdsdx, R_CHEBP) ;
00115
00116 for (int j=0 ; j<n-1 ; j++)
00117 res.set(j, i) = xdsdx[j] ;
00118 }
00119 delete [] xdsdx ;
00120 tab[nb_dejafait] = new Matrice(res) ;
00121 nb_dejafait ++ ;
00122 return res ;
00123 }
00124
00125 else
00126 return *tab[indice] ;
00127 }
00128
00129
00130
00131
00132
00133
00134
00135
00136 Matrice _xdsdx_mat_r_chebi (int n, int l) {
00137 const int nmax = 200 ;
00138 static Matrice* tab[nmax] ;
00139 static int nb_dejafait = 0 ;
00140 static int nr_dejafait[nmax] ;
00141 static int nl_dejafait[nmax] ;
00142
00143 int indice = -1 ;
00144
00145 int indic_l = (l == 1) ? 1 : 2 ;
00146
00147
00148 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00149 if ((nr_dejafait[conte] == n) && (nl_dejafait[conte] == indic_l))
00150 indice = conte ;
00151
00152
00153 if (indice == -1) {
00154 if (nb_dejafait >= nmax) {
00155 cout << "_laplacien_nul_mat_r_chebp : trop de matrices" << endl ;
00156 abort() ;
00157 exit (-1) ;
00158 }
00159
00160 nr_dejafait[nb_dejafait] = n ;
00161 nl_dejafait[nb_dejafait] = indic_l ;
00162
00163
00164 int taille = (l==1) ? n : n-1 ;
00165 Matrice res(taille, taille) ;
00166 res.set_etat_qcq() ;
00167
00168 double* xdsdx = new double[n] ;
00169
00170 for (int i=0 ; i<taille ; i++) {
00171 for (int j=0 ; j<n ; j++)
00172 xdsdx[j] = 0 ;
00173
00174
00175 if (taille == n) {
00176 xdsdx[i] = 1 ;
00177 }
00178 else {
00179 xdsdx[i] = 2*i+3 ;
00180 xdsdx[i+1] = 2*i+1 ;
00181 }
00182 xdsdx_1d (n, &xdsdx, R_CHEBI) ;
00183
00184 for (int j=0 ; j<taille ; j++)
00185 res.set(j, i) = xdsdx[j] ;
00186 }
00187
00188 delete [] xdsdx ;
00189 tab[nb_dejafait] = new Matrice(res) ;
00190 nb_dejafait ++ ;
00191 return res ;
00192 }
00193
00194 else
00195 return *tab[indice] ;
00196 }
00197
00198
00199
00200
00201
00202 Matrice xdsdx_mat(int n, int l, int base_r)
00203 {
00204
00205
00206 static Matrice (*xdsdx_mat[MAX_BASE])(int, int) ;
00207 static int nap = 0 ;
00208
00209
00210 if (nap==0) {
00211 nap = 1 ;
00212 for (int i=0 ; i<MAX_BASE ; i++) {
00213 xdsdx_mat[i] = _xdsdx_mat_pas_prevu ;
00214 }
00215
00216 xdsdx_mat[R_CHEBP >> TRA_R] = _xdsdx_mat_r_chebp ;
00217 xdsdx_mat[R_CHEBI >> TRA_R] = _xdsdx_mat_r_chebi ;
00218 }
00219
00220 Matrice res(xdsdx_mat[base_r](n, l)) ;
00221 return res ;
00222 }
00223