137 #include "utilitaires.h" 147 Tbl::Tbl(
int n1) : etat(ETATNONDEF), dim(n1), t(0x0) {}
150 Tbl::Tbl(
int n1,
int n0) : etat(ETATNONDEF), dim(n1, n0), t(0x0) {}
153 Tbl::Tbl(
int n2,
int n1,
int n0) : etat(ETATNONDEF), dim(n2, n1, n0), t(0x0) {}
157 dim(g.get_np(), g.get_nt(), g.get_nr()),
166 int* dims =
new int[n] ;
167 for (
int i=0 ; i<n ; i++)
181 if (tc.
etat == ETATQCQ) {
186 for (
int i=0 ; i<n ; i++) {
203 if (
etat == ETATQCQ) {
214 dim( (aa.get_array()).dim ) {
231 if (
etat == ETATQCQ) {
266 assert(tx.
get_etat() != ETATNONDEF) ;
278 for (
int i=0 ; i<n ; i++) {
286 cout <<
"Erreur bizarre !" << endl ;
295 if ( a ==
double(0) ) {
301 for (
int i=0 ; i<n ; i++) {
316 for (
int i=0 ; i<n ; i++) {
333 if (
etat == ETATQCQ) {
351 if (
etat == ETATZERO) return ;
358 if (
etat == ETATNONDEF) return ;
365 if (
etat == ETATQCQ) return ;
368 assert( (
etat == ETATZERO) || (
etat == ETATNONDEF) ) ;
394 ostream& operator<<(ostream& o,
const Tbl& t) {
398 o.setf(ios::showpoint);
399 o <<
"*** Tbl " << ndim <<
"D" <<
" size: " ;
400 for (
int i = 0; i<ndim-1; i++) {
408 o <<
"Identically ZERO" << endl ;
413 o <<
"UNDEFINED STATE" << endl ;
417 assert(t.
etat == ETATQCQ) ;
421 for (
int i=0 ; i<t.
get_dim(0) ; i++) {
430 for (
int j=0 ; j<t.
get_dim(1) ; j++) {
431 o <<
" j = " << j <<
" : " << endl ;
432 for (
int i=0 ; i<t.
get_dim(0) ; i++) {
433 o <<
" " << t(j, i) ;
442 for (
int k=0 ; k<t.
get_dim(2) ; k++) {
443 o <<
"k = " << k <<
" : " << endl ;
444 for (
int j=0 ; j<t.
get_dim(1) ; j++) {
445 o <<
"j = " << j <<
" : " ;
446 for (
int i=0 ; i<t.
get_dim(0) ; i++) {
447 o <<
" " << t(k, j, i) ;
458 cout <<
"operator<< Tbl : unexpected dimension !" << endl ;
459 cout <<
" ndim = " << ndim << endl ;
474 ost <<
"*** Tbl " << ndim <<
"D" <<
" size: " ;
475 for (
int i = 0; i<ndim-1; i++) {
483 if (
etat == ETATNONDEF) {
484 ost <<
" state: UNDEFINED" << endl ;
488 if (
etat == ETATZERO) {
489 ost <<
" state: ZERO" << endl ;
496 ost <<
" threshold for display : " << seuil << endl ;
497 ost.precision(precis);
498 ost.setf(ios::showpoint);
503 for (
int i=0; i<
get_dim(0); i++) {
504 ost <<
" " << setw(precis) << (*this)(i) ;
512 for (
int j=0; j<
get_dim(1); j++) {
513 ost <<
" #j=" << j <<
" : " ;
514 for (
int i=0; i<
get_dim(0); i++){
515 ost <<
" " << setw(precis) << (*this)(j, i) ;
524 for (
int k=0; k<
get_dim(2); k++) {
525 for (
int j=0; j<
get_dim(1); j++){
527 for (
int i=0; i<
get_dim(0); i++){
528 if ( fabs( (*
this)(k, j, i) ) >= seuil )
531 if (test_imp == 1 ) {
532 ost <<
" #k=" << k <<
",j=" << j <<
" : " ;
533 for (
int i=0; i<
get_dim(0); i++){
534 ost <<
" " << setw(precis) << (*this)(k, j, i) ;
545 cout <<
"Tbl:affiche_seuil : unexpected dimension !" << endl ;
546 cout <<
" get_ndim() = " <<
get_ndim() << endl ;
555 ost.unsetf(ios::showpoint);
void sauve(FILE *) const
Save in a file.
Tbl get_array() const
Returns the array of matrix elements.
int taille
Total size of the array Tbl::t.
Basic integer array class.
int get_etat() const
Gives the logical state.
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
int get_ndim() const
Gives the number of dimensions (ie dim.ndim)
Tbl(int size0)
1D constructor
Dim_tbl dim
Number of dimensions, size,...
double * t
The array of double.
void set_etat_nondef()
Sets the logical state to ETATNONDEF (undefined).
int fwrite_be(const int *aa, int size, int nb, FILE *fich)
Writes integer(s) into a binary file according to the big endian convention.
int get_dim(int i) const
Gives the i-th dimension (ie dim.dim[i])
int etat
logical state (ETATNONDEF, ETATQCQ or ETATZERO).
void set_etat_zero()
Sets the logical state to ETATZERO (zero).
void affiche_seuil(ostream &ostr, int precision=4, double threshold=1.e-7) const
Prints only the values greater than a given threshold.
int ndim
Number of dimensions of the Tbl: can be 1, 2 or 3.
int fread_be(int *aa, int size, int nb, FILE *fich)
Reads integer(s) from a binary file according to the big endian convention.
Storage of array dimensions.
void del_t()
Logical destructor: dellocates the memory occupied by the array t and sets the logical state to ETATN...
int get_taille() const
Gives the total size (ie dim.taille)
int get_dim(int i) const
Gives the i th dimension (ie {tt dim.dim[i] )
void sauve(FILE *) const
Save in a file.
void annule_hard()
Sets the Tbl to zero in a hard way.
void operator=(const Tbl &)
Assignment to another Tbl.
3D grid class in one domain.
int * dim
Array of dimensions (size: ndim).