tenseur_math.C
/*
* Mathematical functions for the Tenseur class.
*
* These functions are not member functions of the Tenseur class.
*
* (see file tenseur.h for documentation).
*
*/
/*
* Copyright (c) 2000-2001 Eric Gourgoulhon
* Copyright (c) 2001 Jerome Novak
*
* 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
*
*/
char tenseur_math_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tenseur/tenseur_math.C,v 1.4 2014/10/13 08:53:42 j_novak Exp $" ;
/*
* $Id: tenseur_math.C,v 1.4 2014/10/13 08:53:42 j_novak Exp $
* $Log: tenseur_math.C,v $
* Revision 1.4 2014/10/13 08:53:42 j_novak
* Lorene classes and functions now belong to the namespace Lorene.
*
* Revision 1.3 2002/08/08 15:10:45 j_novak
* The flag "plat" has been added to the class Metrique to show flat metrics.
*
* Revision 1.2 2002/08/07 16:14:11 j_novak
* class Tenseur can now also handle tensor densities, this should be transparent to older codes
*
* Revision 1.1.1.1 2001/11/20 15:19:30 e_gourgoulhon
* LORENE
*
* Revision 2.1 2001/06/18 13:56:25 novak
* Ajout de la fonction abs() pour les scalaires
*
* Revision 2.0 2000/02/08 19:06:32 eric
* *** empty log message ***
*
*
* $Header: /cvsroot/Lorene/C++/Source/Tenseur/tenseur_math.C,v 1.4 2014/10/13 08:53:42 j_novak Exp $
*
*/
// Headers Lorene
#include "tenseur.h"
//--------------//
// Exponential //
//--------------//
namespace Lorene {
Tenseur exp (const Tenseur& t) {
assert (t.get_etat() != ETATNONDEF) ;
assert (t.get_valence() == 0) ; // Scalaire uniquement ...
Tenseur res( *(t.get_mp()) ) ;
res.set_etat_qcq() ;
if (t.get_etat() == ETATZERO)
res.set() = 1 ;
else
res.set() = exp( t() ) ;
return res ;
}
//---------------------//
// Neperian logarithm //
//---------------------//
Tenseur log (const Tenseur& t) {
assert (t.get_etat() != ETATNONDEF) ;
assert (t.get_valence() == 0) ; // Scalaire uniquement ...
Tenseur res( *(t.get_mp()) ) ;
res.set_etat_qcq() ;
res.set() = log(t()) ;
return res ;
}
//-------------//
// Square root //
//-------------//
Tenseur sqrt(const Tenseur& t) {
assert (t.get_etat() != ETATNONDEF) ;
assert (t.get_valence() == 0) ; // Scalaire uniquement ...
Tenseur res( *(t.get_mp()), t.get_metric(), 0.5*t.get_poids() ) ;
res.set_etat_qcq() ;
res.set() = sqrt(t()) ;
return res ;
}
//----------------//
// Absolute value //
//----------------//
Tenseur abs(const Tenseur& t) {
assert (t.get_etat() != ETATNONDEF) ;
assert (t.get_valence() == 0) ; // Scalaire uniquement ...
Tenseur res( *(t.get_mp()), t.get_metric(), t.get_poids() ) ;
res.set_etat_qcq() ;
res.set() = abs(t()) ;
return res ;
}
//--------------//
// Power^double //
//--------------//
Tenseur pow (const Tenseur& t, double a) {
assert (t.get_etat() != ETATNONDEF) ;
assert (t.get_valence() == 0) ; // Scalaire uniquement ...
Tenseur res( *(t.get_mp()), t.get_metric(), a*t.get_poids() ) ;
res.set_etat_qcq() ;
if (t.get_etat() == ETATZERO)
if (a > double(0)) {
res.set_etat_zero() ;
res.set_std_base() ;
return res ;
}
else {
cout << "pow(Tenseur, double) : ETATZERO^x with x <= 0 !" << endl ;
abort() ;
}
else {
assert(t.get_etat() == ETATQCQ) ;
res.set() = pow( t(), a ) ;
}
res.set_std_base() ;
return res ;
}
//--------------//
// Power^int //
//--------------//
Tenseur pow (const Tenseur& t, int n) {
assert (t.get_etat() != ETATNONDEF) ;
assert (t.get_valence() == 0) ; // Scalaire uniquement ...
Tenseur res( *(t.get_mp()), t.get_metric(), n*t.get_poids() ) ;
res.set_etat_qcq() ;
if (t.get_etat() == ETATZERO)
if (n > double(0)) {
res.set_etat_zero() ;
return res ;
}
else {
cout << "pow(Tenseur, int) : ETATZERO^n with n <= 0 !" << endl ;
abort() ;
}
else {
assert(t.get_etat() == ETATQCQ) ;
res.set() = pow( t(), n ) ;
}
return res ;
}
}
Lorene::Tenseur
Tensor handling *** DEPRECATED : use class Tensor instead ***.
Definition tenseur.h:301
Lorene::Tenseur::set
Cmp & set()
Read/write for a scalar (see also operator=(const Cmp&) ).
Definition tenseur.C:824
Lorene::Tenseur::set_etat_qcq
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition tenseur.C:636
Lorene::Tenseur::get_mp
const Map * get_mp() const
Returns pointer on the mapping.
Definition tenseur.h:699
Lorene::Tenseur::get_poids
double get_poids() const
Returns the weight.
Definition tenseur.h:738
Lorene::Tenseur::set_std_base
void set_std_base()
Set the standard spectal basis of decomposition for each component.
Definition tenseur.C:1170
Lorene::Tenseur::set_etat_zero
void set_etat_zero()
Sets the logical state to ETATZERO (zero state).
Definition tenseur.C:645
Lorene::Tenseur::get_valence
int get_valence() const
Returns the valence.
Definition tenseur.h:710
Lorene::Tenseur::get_metric
const Metrique * get_metric() const
Returns a pointer on the metric defining the conformal factor for tensor densities.
Definition tenseur.h:745
Lorene::Tenseur::get_etat
int get_etat() const
Returns the logical state.
Definition tenseur.h:707
Lorene::sqrt
Cmp sqrt(const Cmp &)
Square root.
Definition cmp_math.C:220
Lorene::exp
Cmp exp(const Cmp &)
Exponential.
Definition cmp_math.C:270
Lorene::pow
Cmp pow(const Cmp &, int)
Power .
Definition cmp_math.C:348
Lorene::abs
Cmp abs(const Cmp &)
Absolute value.
Definition cmp_math.C:410
Lorene::log
Cmp log(const Cmp &)
Neperian logarithm.
Definition cmp_math.C:296
Lorene
Lorene prototypes.
Definition app_hor.h:64