/* * Mathematical functions for class Tbl * */ /* * Copyright (c) 1999-2000 Jean-Alain Marck * Copyright (c) 1999-2001 Eric Gourgoulhon * Copyright (c) 1999-2001 Philippe Grandclement * * 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 tbl_math_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tbl/tbl_math.C,v 1.4 2014/10/13 08:53:41 j_novak Exp $" ; /* * $Id: tbl_math.C,v 1.4 2014/10/13 08:53:41 j_novak Exp $ * $Log: tbl_math.C,v $ * Revision 1.4 2014/10/13 08:53:41 j_novak * Lorene classes and functions now belong to the namespace Lorene. * * Revision 1.3 2014/10/06 15:13:18 j_novak * Modified #include directives to use c++ syntax. * * Revision 1.2 2012/01/17 10:38:48 j_penner * added a Heaviside function * * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon * LORENE * * Revision 2.4 1999/12/02 17:47:48 phil * ajout de racine_cubique * * Revision 2.3 1999/10/29 15:05:32 eric * Ajout de fonctions mathematiques (abs, norme, etc...). * * Revision 2.2 1999/03/01 15:10:19 eric * *** empty log message *** * * Revision 2.1 1999/02/24 15:26:13 hyc * *** empty log message *** * * * $Header: /cvsroot/Lorene/C++/Source/Tbl/tbl_math.C,v 1.4 2014/10/13 08:53:41 j_novak Exp $ * */ // Headers C // --------- #include #include // Headers Lorene // -------------- #include "tbl.h" //-------// // Sinus // //-------// namespace Lorene { Tbl sin(const Tbl& ti) { // Protection assert(ti.get_etat() != ETATNONDEF) ; // Cas ETATZERO if (ti.get_etat() == ETATZERO) { return ti ; } // Cas general assert(ti.get_etat() == ETATQCQ) ; // sinon... Tbl to(ti.dim) ; // Tbl resultat to.set_etat_qcq() ; int taille = ti.get_taille() ; for (int i=0 ; i= 0) to.t[i] = 1 ; else to.t[i] = 0 ; } return to ; } //-------------// // Log naturel // //-------------// Tbl log(const Tbl& ti) { // Protection assert(ti.get_etat() != ETATNONDEF) ; // Cas ETATZERO if (ti.get_etat() == ETATZERO) { cout << "Tbl log: log(ETATZERO) !" << endl ; abort () ; } // Cas general assert(ti.get_etat() == ETATQCQ) ; // sinon... Tbl to(ti.dim) ; // Tbl resultat to.set_etat_qcq() ; int taille = ti.get_taille() ; for (int i=0 ; i 0) { return ti ; } else { cout << "Tbl pow: ETATZERO^n avec n<=0 ! "<< endl ; abort () ; } } // Cas general assert(ti.get_etat() == ETATQCQ) ; // sinon... Tbl to(ti.dim) ; // Tbl resultat to.set_etat_qcq() ; double x = n ; int taille = ti.get_taille() ; for (int i=0 ; i 0) { return ti ; } else { cout << "Tbl pow: ETATZERO^x avec x<=0 !" << endl ; abort () ; } } // Cas general assert(ti.get_etat() == ETATQCQ) ; // sinon... Tbl to(ti.dim) ; // Tbl resultat to.set_etat_qcq() ; int taille = ti.get_taille() ; for (int i=0 ; i resu ) resu = x[i] ; } return resu ; } //-------------------------------// // min // //-------------------------------// double min(const Tbl& ti) { // Protection assert(ti.get_etat() != ETATNONDEF) ; // Cas particulier if (ti.get_etat() == ETATZERO) { return double(0) ; } // Cas general assert(ti.get_etat() == ETATQCQ) ; // sinon.... const double* x = ti.t ; double resu = x[0] ; for (int i=1; i