31 char tbl_C[] =
"$Header: /cvsroot/Lorene/C++/Source/Tbl/tbl.C,v 1.11 2014/10/13 08:53:41 j_novak Exp $" ;
134 #include "utilitaires.h"
144 Tbl::Tbl(
int n1) : etat(ETATNONDEF), dim(n1), t(0x0) {}
147 Tbl::Tbl(
int n1,
int n0) : etat(ETATNONDEF), dim(n1, n0), t(0x0) {}
150 Tbl::Tbl(
int n2,
int n1,
int n0) : etat(ETATNONDEF), dim(n2, n1, n0), t(0x0) {}
154 dim(g.get_np(), g.get_nt(), g.get_nr()),
163 int* dims =
new int[n] ;
164 for (
int i=0 ; i<n ; i++)
178 if (tc.
etat == ETATQCQ) {
183 for (
int i=0 ; i<n ; i++) {
200 if (
etat == ETATQCQ) {
211 dim( (aa.get_array()).dim ) {
228 if (
etat == ETATQCQ) {
263 assert(tx.
get_etat() != ETATNONDEF) ;
275 for (
int i=0 ; i<n ; i++) {
283 cout <<
"Erreur bizarre !" << endl ;
292 if ( a ==
double(0) ) {
298 for (
int i=0 ; i<n ; i++) {
313 for (
int i=0 ; i<n ; i++) {
330 if (
etat == ETATQCQ) {
348 if (
etat == ETATZERO) return ;
355 if (
etat == ETATNONDEF) return ;
362 if (
etat == ETATQCQ) return ;
365 assert( (
etat == ETATZERO) || (
etat == ETATNONDEF) ) ;
391 ostream& operator<<(ostream& o,
const Tbl& t) {
395 o.setf(ios::showpoint);
396 o <<
"*** Tbl " << ndim <<
"D" <<
" size: " ;
397 for (
int i = 0; i<ndim-1; i++) {
405 o <<
"Identically ZERO" << endl ;
410 o <<
"UNDEFINED STATE" << endl ;
414 assert(t.
etat == ETATQCQ) ;
418 for (
int i=0 ; i<t.
get_dim(0) ; i++) {
427 for (
int j=0 ; j<t.
get_dim(1) ; j++) {
428 o <<
" j = " << j <<
" : " << endl ;
429 for (
int i=0 ; i<t.
get_dim(0) ; i++) {
430 o <<
" " << t(j, i) ;
439 for (
int k=0 ; k<t.
get_dim(2) ; k++) {
440 o <<
"k = " << k <<
" : " << endl ;
441 for (
int j=0 ; j<t.
get_dim(1) ; j++) {
442 o <<
"j = " << j <<
" : " ;
443 for (
int i=0 ; i<t.
get_dim(0) ; i++) {
444 o <<
" " << t(k, j, i) ;
455 cout <<
"operator<< Tbl : unexpected dimension !" << endl ;
456 cout <<
" ndim = " << ndim << endl ;
471 ost <<
"*** Tbl " << ndim <<
"D" <<
" size: " ;
472 for (
int i = 0; i<ndim-1; i++) {
480 if (
etat == ETATNONDEF) {
481 ost <<
" state: UNDEFINED" << endl ;
485 if (
etat == ETATZERO) {
486 ost <<
" state: ZERO" << endl ;
493 ost <<
" threshold for display : " << seuil << endl ;
494 ost.precision(precis);
495 ost.setf(ios::showpoint);
500 for (
int i=0; i<
get_dim(0); i++) {
501 ost <<
" " << setw(precis) << (*this)(i) ;
509 for (
int j=0; j<
get_dim(1); j++) {
510 ost <<
" #j=" << j <<
" : " ;
511 for (
int i=0; i<
get_dim(0); i++){
512 ost <<
" " << setw(precis) << (*this)(j, i) ;
521 for (
int k=0; k<
get_dim(2); k++) {
522 for (
int j=0; j<
get_dim(1); j++){
524 for (
int i=0; i<
get_dim(0); i++){
525 if ( fabs( (*
this)(k, j, i) ) >= seuil )
528 if (test_imp == 1 ) {
529 ost <<
" #k=" << k <<
",j=" << j <<
" : " ;
530 for (
int i=0; i<
get_dim(0); i++){
531 ost <<
" " << setw(precis) << (*this)(k, j, i) ;
542 cout <<
"Tbl:affiche_seuil : unexpected dimension !" << endl ;
543 cout <<
" get_ndim() = " <<
get_ndim() << endl ;
552 ost.unsetf(ios::showpoint);
void sauve(FILE *) const
Save in a file.
3D grid class in one domain.
Storage of array dimensions.
void annule_hard()
Sets the Tbl to zero in a hard way.
int get_dim(int i) const
Gives the i th dimension (ie {tt dim.dim[i] )
int * dim
Array of dimensions (size: ndim).
int get_ndim() const
Gives the number of dimensions (ie dim.ndim)
Basic integer array class.
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).
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
int taille
Total size of the array Tbl::t.
int get_dim(int i) const
Gives the i-th dimension (ie dim.dim[i])
void set_etat_zero()
Sets the logical state to ETATZERO (zero).
void del_t()
Logical destructor: dellocates the memory occupied by the array t and sets the logical state to ETATN...
int fread_be(int *aa, int size, int nb, FILE *fich)
Reads integer(s) from a binary file according to the big endian convention.
void operator=(const Tbl &)
Assignment to another Tbl.
int etat
logical state (ETATNONDEF, ETATQCQ or ETATZERO).
void sauve(FILE *) const
Save in a file.
int ndim
Number of dimensions of the Tbl: can be 1, 2 or 3.
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_taille() const
Gives the total size (ie dim.taille)
int get_etat() const
Gives the logical state.
Tbl get_array() const
Returns the array of matrix elements.
void affiche_seuil(ostream &ostr, int precision=4, double threshold=1.e-7) const
Prints only the values greater than a given threshold.