| 1 |
/* |
| 2 |
* Method Mtbl_cf::display |
| 3 |
* |
| 4 |
* (see file mtbl_cf.h for documentation). |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
/* |
| 9 |
* Copyright (c) 2003 Eric Gourgoulhon |
| 10 |
* |
| 11 |
* This file is part of LORENE. |
| 12 |
* |
| 13 |
* LORENE is free software; you can redistribute it and/or modify |
| 14 |
* it under the terms of the GNU General Public License version 2 |
| 15 |
* as published by the Free Software Foundation. |
| 16 |
* |
| 17 |
* LORENE is distributed in the hope that it will be useful, |
| 18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 |
* GNU General Public License for more details. |
| 21 |
* |
| 22 |
* You should have received a copy of the GNU General Public License |
| 23 |
* along with LORENE; if not, write to the Free Software |
| 24 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 |
* |
| 26 |
*/ |
| 27 |
|
| 28 |
char mtbl_cf_display_C[] = "$Header: /cvsroot/Lorene/C++/Source/Mtbl_cf/mtbl_cf_display.C,v 1.3 2014/10/13 08:53:08 j_novak Exp $" ; |
| 29 |
|
| 30 |
/* |
| 31 |
* $Id: mtbl_cf_display.C,v 1.3 2014/10/13 08:53:08 j_novak Exp $ |
| 32 |
* $Log: mtbl_cf_display.C,v $ |
| 33 |
* Revision 1.3 2014/10/13 08:53:08 j_novak |
| 34 |
* Lorene classes and functions now belong to the namespace Lorene. |
| 35 |
* |
| 36 |
* Revision 1.2 2014/10/06 15:13:15 j_novak |
| 37 |
* Modified #include directives to use c++ syntax. |
| 38 |
* |
| 39 |
* Revision 1.1 2003/10/19 19:51:58 e_gourgoulhon |
| 40 |
* First version |
| 41 |
* |
| 42 |
* |
| 43 |
* |
| 44 |
* $Header: /cvsroot/Lorene/C++/Source/Mtbl_cf/mtbl_cf_display.C,v 1.3 2014/10/13 08:53:08 j_novak Exp $ |
| 45 |
* |
| 46 |
*/ |
| 47 |
|
| 48 |
// C headers |
| 49 |
#include <cstdlib> |
| 50 |
#include <cmath> |
| 51 |
|
| 52 |
// Lorene headers |
| 53 |
#include "mtbl_cf.h" |
| 54 |
|
| 55 |
namespace Lorene { |
| 56 |
void Mtbl_cf::display(double thres, int precis, ostream& ost) const { |
| 57 |
|
| 58 |
ost << "Spectral expansion (Mtbl_cf, threshold for display = " |
| 59 |
<< thres << ")" << endl ; |
| 60 |
ost << base << endl ; |
| 61 |
|
| 62 |
if (etat == ETATNONDEF) { |
| 63 |
ost << " state: UNDEFINED" << endl ; |
| 64 |
return ; |
| 65 |
} |
| 66 |
|
| 67 |
if (etat == ETATZERO) { |
| 68 |
ost << " state: ZERO" << endl ; |
| 69 |
return ; |
| 70 |
} |
| 71 |
|
| 72 |
ost.precision(precis); |
| 73 |
ost.setf(ios::showpoint); |
| 74 |
assert(etat == ETATQCQ) ; |
| 75 |
char namep[12] ; |
| 76 |
char namet[12] ; |
| 77 |
char namer[12] ; |
| 78 |
|
| 79 |
for (int l=0; l<nzone; l++) { |
| 80 |
|
| 81 |
int nr = mg->get_nr(l) ; |
| 82 |
int nt = mg->get_nt(l) ; |
| 83 |
int np = mg->get_np(l) ; |
| 84 |
|
| 85 |
ost << " --------- Domain no. " << l << " ------- nr x nt x np = " |
| 86 |
<< nr << " x " << nt << " x " << np << " ------" << endl ; |
| 87 |
const Tbl& tcf = *(t[l]) ; |
| 88 |
if (tcf.get_etat() == ETATZERO) { |
| 89 |
ost << "*** identically ZERO ***" << endl << endl ; |
| 90 |
continue ; |
| 91 |
} |
| 92 |
if (tcf.get_etat() == ETATNONDEF) { |
| 93 |
ost << "*** UNDEFINED ***" << endl << endl ; |
| 94 |
continue ; |
| 95 |
} |
| 96 |
assert( tcf.get_etat() == ETATQCQ ) ; |
| 97 |
|
| 98 |
for (int k=0; k<=np; k++) { |
| 99 |
base.name_phi(l, k, namep) ; |
| 100 |
if (namep[0] == 'u') continue ; // unused phi coefficient |
| 101 |
|
| 102 |
for (int j=0; j<nt; j++) { |
| 103 |
|
| 104 |
bool test_display = false ; |
| 105 |
for (int i=0; i<nr; i++) { |
| 106 |
if (fabs( tcf(k, j, i) ) >= thres) test_display = true ; |
| 107 |
} |
| 108 |
|
| 109 |
base.name_theta(l, k, j, namet) ; |
| 110 |
|
| 111 |
test_display = test_display && ( namet[0] != 'u' ) ; |
| 112 |
|
| 113 |
if (test_display) { |
| 114 |
ost << "# " << namep << " " << namet << " :" ; |
| 115 |
for (int i=0; i<nr; i++) { |
| 116 |
double cx = tcf(k, j, i) ; |
| 117 |
if (fabs( cx ) >= thres) { |
| 118 |
base.name_r(l, k, j, i, namer) ; |
| 119 |
if (namer[0] == 'u') continue ; // unused r coefficient |
| 120 |
if ( (i>0) && (cx >= 0.) ) { |
| 121 |
ost << " +" << setw(precis) << cx |
| 122 |
<< " " << namer ; |
| 123 |
} |
| 124 |
else { |
| 125 |
ost << " " << setw(precis) << cx |
| 126 |
<< " " << namer ; |
| 127 |
} |
| 128 |
} |
| 129 |
} |
| 130 |
ost << endl ; |
| 131 |
} |
| 132 |
|
| 133 |
} // end of theta loop (index j) |
| 134 |
|
| 135 |
} // end of phi loop (index k) |
| 136 |
|
| 137 |
ost << endl ; |
| 138 |
|
| 139 |
} // end of loop on the domains (index l) |
| 140 |
|
| 141 |
} |
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
} |