/* * Methods of class Tenseur_sym * * (see file tenseur.h for documentation) * */ /* * Copyright (c) 1999-2001 Philippe Grandclement * Copyright (c) 2000-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 * */ char tenseur_sym_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tenseur/tenseur_sym.C,v 1.8 2014/10/13 08:53:42 j_novak Exp $" ; /* * $Id: tenseur_sym.C,v 1.8 2014/10/13 08:53:42 j_novak Exp $ * $Log: tenseur_sym.C,v $ * Revision 1.8 2014/10/13 08:53:42 j_novak * Lorene classes and functions now belong to the namespace Lorene. * * Revision 1.7 2014/10/06 15:13:19 j_novak * Modified #include directives to use c++ syntax. * * Revision 1.6 2003/03/03 19:39:58 f_limousin * Modification of an assert to have a check on a triad and not only on a pointer. * * Revision 1.5 2002/10/16 14:37:14 j_novak * Reorganization of #include instructions of standard C++, in order to * use experimental version 3 of gcc. * * Revision 1.4 2002/09/06 14:49:25 j_novak * Added method lie_derive for Tenseur and Tenseur_sym. * Corrected various errors for derive_cov and arithmetic. * * Revision 1.3 2002/08/14 13:46:15 j_novak * Derived quantities of a Tenseur can now depend on several Metrique's * * 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.3 2001/10/10 13:55:23 eric * Modif Joachim: pow(3, *) --> pow(3., *) * * Revision 2.2 2000/02/09 19:33:38 eric * MODIF IMPORTANTE: la triade de decomposition est desormais passee en * argument des constructeurs. * * Revision 2.1 2000/01/11 11:14:41 eric * Gestion de la base vectorielle (triad). * * Revision 2.0 1999/12/02 17:18:37 phil * *** empty log message *** * * * $Header: /cvsroot/Lorene/C++/Source/Tenseur/tenseur_sym.C,v 1.8 2014/10/13 08:53:42 j_novak Exp $ * */ // Headers C #include #include #include // Headers Lorene #include "tenseur.h" #include "metrique.h" //--------------// // Constructors // //--------------// // Standard constructor // -------------------- namespace Lorene { Tenseur_sym::Tenseur_sym(const Map& map, int val, const Itbl& tipe, const Base_vect& triad_i, const Metrique* met, double weight) : Tenseur(map, val, tipe, int(pow(3., val-2)) * 6, triad_i, met, weight) { assert (val >= 2) ; } // Standard constructor when all the indices are of the same type // -------------------------------------------------------------- Tenseur_sym::Tenseur_sym(const Map& map, int val, int tipe, const Base_vect& triad_i, const Metrique* met, double weight) : Tenseur(map, val, tipe, int(pow(3., val-2)) * 6, triad_i, met, weight) { assert (val >= 2) ; } // Copy constructor // ---------------- Tenseur_sym::Tenseur_sym (const Tenseur_sym& source) : Tenseur (*source.mp, source.valence, source.type_indice, int(pow(3., source.valence-2)*6), *(source.triad), source.metric, source.poids) { assert (valence >= 2) ; for (int i=0 ; i= 2) ; for (int i=0 ; i= 2) ; assert (n_comp == int(pow(3., valence-2))*6) ; } //--------------// // Destructor // //--------------// Tenseur_sym::~Tenseur_sym() {} int Tenseur_sym::donne_place (const Itbl& idx) const { assert (idx.get_ndim() == 1) ; assert (idx.get_dim(0) == valence) ; for (int i=0 ; i= 0) && (idx(i) < 3)) ; // Gestion des deux derniers indices : int last = idx(valence-1) ; int lastm1 = idx(valence-2) ; if (last < lastm1) { int auxi = last ; last = lastm1 ; lastm1 = auxi ; } int place_fin ; switch (lastm1) { case 0 : { place_fin = last ; break ; } case 1 : { place_fin = 2+last ; break ; } case 2 : { place_fin = 5 ; break ; } default : { abort() ; } } int res = 0 ; for (int i=0 ; i=0) && (place=0 ; i--) { res.set(i) = div(place, 3).rem ; place = int((place-res(i))/3) ; } if (reste<3) { res.set(valence-2) = 0 ; res.set(valence-1) = reste ; } if ((reste>2) && (reste<5)) { res.set(valence-2) = 1 ; res.set(valence-1) = reste - 2 ; } if (reste == 5) { res.set(valence-2) = 2 ; res.set(valence-1) = 2 ; } return res ; } void Tenseur_sym::operator= (const Tenseur& t) { assert (valence == t.get_valence()) ; triad = t.triad ; poids = t.poids ; metric = t.metric ; for (int i=0 ; i