/usr/include/lorene/C++/Include/mtbl.h is in liblorene-dev 0.0.0~cvs20161116+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 | /*
* Definition of Lorene class Mtbl
*
*/
/*
* Copyright (c) 1999-2000 Jean-Alain Marck
* Copyright (c) 1999-2001 Eric Gourgoulhon
*
* This file is part of LORENE.
*
* LORENE is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* LORENE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LORENE; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef __MTBL_H_
#define __MTBL_H_
/*
* $Id: mtbl.h,v 1.7 2014/10/13 08:52:36 j_novak Exp $
* $Log: mtbl.h,v $
* Revision 1.7 2014/10/13 08:52:36 j_novak
* Lorene classes and functions now belong to the namespace Lorene.
*
* Revision 1.6 2012/01/17 10:22:13 j_penner
* function added: Heaviside
*
* Revision 1.5 2004/03/22 13:12:42 j_novak
* Modification of comments to use doxygen instead of doc++
*
* Revision 1.4 2003/11/06 14:43:37 e_gourgoulhon
* Gave a name to const arguments in certain method prototypes (e.g.
* constructors) to correct a bug of DOC++.
*
* Revision 1.3 2002/09/13 09:17:33 j_novak
* Modif. commentaires
*
* Revision 1.2 2002/06/17 14:05:17 j_novak
* friend functions are now also declared outside the class definition
*
* Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon
* LORENE
*
* Revision 2.9 2000/08/16 10:29:45 eric
* Suppression du membre dzpuis.
*
* Revision 2.8 2000/08/04 11:40:58 eric
* Ajout de l'operateur (int l) et de la fonction set(int l) pour l'acces
* individuel aux Tbl.
*
* Revision 2.7 1999/12/02 17:55:07 phil
* *** empty log message ***
*
* Revision 2.6 1999/10/29 15:05:43 eric
* Suppression des fonctions membres min() et max():
* elles deviennent des fonctions externes.
* Ajout de fonctions mathematiques (abs, norme, etc...).
*
* Revision 2.5 1999/10/18 15:06:25 eric
* La fonction membre annule() est rebaptisee annule_hard().
* Introduction de la fonction membre annule(int, int).
*
* Revision 2.4 1999/10/01 10:35:58 eric
* Amelioration des commentaires.
*
* Revision 2.3 1999/10/01 10:08:25 eric
* Depoussierage
* Documentation.
*
* Revision 2.2 1999/03/02 18:54:50 eric
* Ajout de la fonction affiche_seuil.
*
* Revision 2.1 1999/02/22 15:23:49 hyc
* *** empty log message ***
*
*
* Revision 2.0 1999/01/15 09:10:39 hyc
* *** empty log message ***
*
*
* $Header: /cvsroot/Lorene/C++/Include/mtbl.h,v 1.7 2014/10/13 08:52:36 j_novak Exp $
*
*/
// Headers Lorene
#include "tbl.h"
#include "grilles.h"
namespace Lorene {
class Coord ;
/**
* Multi-domain array. \ingroup (spec)
*
* This class is essentially an array of \c Tbl . It is intended to be
* used in conjunction with the class \c Mtbl_cf .
* A \c Mtbl is initialy created with a \a logical state \c NONDEF .
* Arithmetic operations are provided with the usual meaning (see
* below).
*
* @version #$Id: mtbl.h,v 1.7 2014/10/13 08:52:36 j_novak Exp $#
*
*/
class Mtbl {
// Data :
// -----
private:
/// Pointer on the multi-grid \c Mgd3 on which \c this is defined
const Mg3d* mg ;
/// Number of domains (zones)
int nzone ;
/// Logical state (\c ETATNONDEF , \c ETATQCQ or \c ETATZERO ).
int etat ;
public:
/// Array (size \c nzone ) of pointers on the \c Tbl 's
Tbl** t;
// Constructors - Destructor
// -------------------------
public:
/// Constructor
explicit Mtbl(const Mg3d& mgrid) ;
/// Constructor
explicit Mtbl(const Mg3d* p_mgrid) ;
/// Constructor from a file (see \c sauve(FILE*))
Mtbl(const Mg3d&, FILE* ) ;
/// Constructor from a Coord
Mtbl(const Coord& c) ;
/// Copy constructor
Mtbl(const Mtbl& a) ;
/// Destructor
~Mtbl() ;
// Assignement
// -----------
public:
/// Assignement to another \c Mtbl
void operator=(const Mtbl& ) ;
/// Assignement to a \c double
void operator=(double ) ;
/// Assignement to a \c int
void operator=(int ) ;
// Memory management
// -----------------
private:
/** Logical destructor: dellocates the memory occupied by the \c Tbl
* array \c t .
*/
void del_t() ;
public:
/**
* Sets the logical state to \c ETATNONDEF (undefined).
* Deallocates the memory occupied by the \c Tbl array \c t .
*/
void set_etat_nondef() ;
/**
* Sets the logical state to \c ETATZERO (zero).
* Deallocates the memory occupied by the \c Tbl array \c t .
*/
void set_etat_zero() ;
/**
* Sets the logical state to \c ETATQCQ (ordinary state).
* If the state (member \c etat ) is already \c ETATQCQ , this
* function does nothing. Otherwise, it performs the memory allocation
* for the \c Tbl array \c t .
*/
void set_etat_qcq() ;
/**
* Sets the \c Mtbl to zero in a hard way.
* 1/ Sets the logical state to \c ETATQCQ , i.e. to an ordinary state.
* 2/ Allocates the memory of the \c Tbl array \c t , and fills it
* with zeros. NB: this function must be used for debugging purposes only.
* For other operations, the functions \c set_etat_zero()
* or \c annule(int, int) must be perferred.
*/
void annule_hard() ;
/**
* Sets the \c Mtbl to zero in some domains.
* @param l_min [input] The \c Mtbl will be set (logically) to zero
* in the domains whose indices are in the range
* \c [l_min,l_max] .
* @param l_max [input] see the comments for \c l_min .
*
* Note that \c annule(0,nzone-1) is equivalent to
* \c set_etat_zero() .
*/
void annule(int l_min, int l_max) ;
// Access to individual elements
// -----------------------------
public:
/**
* Read/write of the \c Tbl in a given domain.
* @param l [input] domain index
*/
Tbl& set(int l) {
assert(l < nzone) ;
assert(etat == ETATQCQ) ;
return *(t[l]) ;
};
/**
* Read-only of the \c Tbl in a given domain.
* @param l [input] domain index
*/
const Tbl& operator()(int l) const {
assert(l < nzone) ;
assert(etat == ETATQCQ) ;
return *(t[l]) ;
};
/**
* Read/write of a particular element.
* @param l [input] domain index
* @param k [input] \f$\phi\f$ index
* @param j [input] \f$\theta\f$ index
* @param i [input] \e r (\f$\xi\f$) index
*/
double& set(int l, int k, int j, int i) {
assert(l < nzone) ;
assert(etat == ETATQCQ) ;
return (t[l])->set(k, j, i) ;
};
/**
* Read-only of a particular element.
* @param l [input] domain index
* @param k [input] \f$\phi\f$ index
* @param j [input] \f$\theta\f$ index
* @param i [input] \e r (\f$\xi\f$) index
*/
double operator()(int l, int k, int j, int i) const {
assert(etat != ETATNONDEF) ;
assert(l < nzone) ;
if (etat == ETATZERO) {
double zero = 0. ;
return zero ;
}
else return (*t[l])(k, j, i) ;
};
// Extraction of information
// -------------------------
public:
/// Gives the \c Mg3d on which the \c Mtbl is defined
const Mg3d* get_mg() const { return mg ; };
/// Gives the logical state
int get_etat() const { return etat ; };
/// Gives the number of zones (domains)
int get_nzone() const { return nzone ; } ;
// Outputs
// -------
public:
/// Save in a file
void sauve(FILE *) const ;
/** Prints only the values greater than a given threshold.
* @param ostr [input] Output stream used for the printing
* @param precision [input] Number of printed digits (default: 4)
* @param threshold [input] Value above which an array element is printed
* (default: 1.e-7)
*/
void affiche_seuil(ostream& ostr, int precision = 4,
double threshold = 1.e-7) const ;
/// Display
friend ostream& operator<<(ostream& , const Mtbl & ) ;
// Member arithmetics
// ------------------
public:
/// += Mtbl
void operator+=(const Mtbl & ) ;
/// += double
void operator+=(double ) ;
/// -= Mtbl
void operator-=(const Mtbl & ) ;
/// -= double
void operator-=(double ) ;
/// *= Mtbl
void operator*=(const Mtbl & ) ;
/// *= double
void operator*=(double ) ;
/// /= Mtbl
void operator/=(const Mtbl & ) ;
/// /= double
void operator/=(double ) ;
} ;
ostream& operator<<(ostream& , const Mtbl & ) ;
/**
* \defgroup mtbl_mat Mtbl Mathematics
* \ingroup (spec)
*
* @{
*/
/// + Mtbl
Mtbl operator+(const Mtbl& ) ;
/// \c - Mtbl
Mtbl operator-(const Mtbl& ) ;
/// Mtbl + Mtbl
Mtbl operator+(const Mtbl&, const Mtbl& ) ;
/// Mtbl + double
Mtbl operator+(const Mtbl&, double ) ;
/// double + Mtbl
Mtbl operator+(double , const Mtbl& ) ;
/// Mtbl + int
Mtbl operator+(const Mtbl&, int ) ;
/// int + Mtbl
Mtbl operator+(int, const Mtbl& ) ;
/// Mtbl - Mtbl
Mtbl operator-(const Mtbl&, const Mtbl& ) ;
/// Mtbl - double
Mtbl operator-(const Mtbl&, double ) ;
/// double - Mtbl
Mtbl operator-(double, const Mtbl& ) ;
/// Mtbl - int
Mtbl operator-(const Mtbl&, int ) ;
/// int - Mtbl
Mtbl operator-(int, const Mtbl& ) ;
/// Mtbl * Mtbl
Mtbl operator*(const Mtbl&, const Mtbl& ) ;
/// Mtbl * double
Mtbl operator*(const Mtbl&, double ) ;
/// double * Mtbl
Mtbl operator*(double, const Mtbl& ) ;
/// Mtbl * int
Mtbl operator*(const Mtbl&, int ) ;
/// int * Mtbl
Mtbl operator*(int, const Mtbl& ) ;
/// Mtbl / Mtbl
Mtbl operator/(const Mtbl&, const Mtbl& ) ;
/// Mtbl / double
Mtbl operator/(const Mtbl&, double ) ;
/// double / Mtbl
Mtbl operator/(double, const Mtbl& ) ;
/// Mtbl / int
Mtbl operator/(const Mtbl&, int ) ;
/// int / Mtbl
Mtbl operator/(int, const Mtbl& ) ;
/// Sine
Mtbl sin(const Mtbl& ) ;
/// Cosine
Mtbl cos(const Mtbl& ) ;
/// Tangent
Mtbl tan(const Mtbl& ) ;
/// Arcsine
Mtbl asin(const Mtbl& ) ;
/// Arccosine
Mtbl acos(const Mtbl& ) ;
/// Arctangent
Mtbl atan(const Mtbl& ) ;
/// Exponential
Mtbl exp(const Mtbl& ) ;
/// Heaviside function
Mtbl Heaviside(const Mtbl& ) ;
/// Neperian logarithm
Mtbl log(const Mtbl& ) ;
/// Neperian logarithm
Mtbl log(const Mtbl& ) ;
/// Basis 10 logarithm
Mtbl log10(const Mtbl& ) ;
/// Square root
Mtbl sqrt(const Mtbl& ) ;
/// Cube root
Mtbl racine_cubique (const Mtbl&) ;
/// Power \f${\tt Mtbl}^{\tt int}\f$
Mtbl pow(const Mtbl& , int ) ;
/// Power \f${\tt Mtbl}^{\tt double}\f$
Mtbl pow(const Mtbl& , double ) ;
/// Absolute value
Mtbl abs(const Mtbl& ) ;
/**
* Maximum value of the \c Mtbl elements in all domains.
* @return a double
*/
double totalmax(const Mtbl& ) ;
/**
* Minimum value of the \c Mtbl elements in all domain.
* @return a double
*/
double totalmin(const Mtbl& ) ;
/**
* Maximum values of the \c Mtbl elements in each domain.
* @return 1-D \c Tbl of size the number of domains, the elements of which
* are the set of the maximum values in each domain.
*/
Tbl max(const Mtbl& ) ;
/**
* Minimum values of the \c Mtbl elements in each domain.
* @return 1-D \c Tbl of size the number of domains, the elements of which
* are the set of the minimum values in each domain.
*/
Tbl min(const Mtbl& ) ;
/**
* Sums of the absolute values of all the \c Mtbl elements in each domain.
* @return 1-D \c Tbl of size the number of domains, the elements of which
* are the set of the sums of the absolute values in each domain.
*/
Tbl norme(const Mtbl& ) ;
/**
* Relative difference between two \c Mtbl (norme version).
* @return 1-D \c Tbl of size the number of domains, the elements of which
* are \c norme[a(l)-b(l)]/norme[b(l)] if \c b(l)!=0 and
* \c norme[a(l)-b(l)] if \c b(l)=0 , where \c a(l) and
* \c b(l) denote symbolically the values of \c a and \c b
* in domain no. \c l .
*/
Tbl diffrel(const Mtbl& a, const Mtbl& b) ;
/**
* Relative difference between two \c Mtbl (max version).
* @return 1-D \c Tbl of size the number of domains, the elements of which
* are \c max[abs(a(l)-b(l))]/max[abs(b(l))] if \c b(l)!=0 and
* \c max[abs(a(l)-b(l))] if \c b(l)=0 , where \c a(l) and
* \c b(l) denote symbolically the values of \c a and \c b
* in domain no. \c l .
*/
Tbl diffrelmax(const Mtbl& a, const Mtbl& b) ;
/**@} */
}
#endif
|