/* * Copyright (c) 1999-2001 Philippe Grandclement * Copyright (c) 2000-2001 Eric Gourgoulhon * Copyright (c) 2002 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_operateur_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tenseur/tenseur_operateur.C,v 1.10 2014/10/13 08:53:42 j_novak Exp $" ; /* * $Id: tenseur_operateur.C,v 1.10 2014/10/13 08:53:42 j_novak Exp $ * $Log: tenseur_operateur.C,v $ * Revision 1.10 2014/10/13 08:53:42 j_novak * Lorene classes and functions now belong to the namespace Lorene. * * Revision 1.9 2014/10/06 15:13:19 j_novak * Modified #include directives to use c++ syntax. * * Revision 1.8 2004/05/27 07:17:19 p_grandclement * Correction of some shadowed variables * * Revision 1.7 2003/06/20 14:53:38 f_limousin * Add the function contract_desal() * * Revision 1.6 2003/03/03 19:38:41 f_limousin * Suppression of an assert on a metric associated with a tensor. * * 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/10 13:44:17 j_novak * The method "manipule" of one indice has been removed for Tenseur_sym objects * (the result cannot be a Tenseur_sym). * The method "sans_trace" now computes the traceless part of a Tenseur (or * Tenseur_sym) of valence 2. * * Revision 1.3 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.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.11 2001/08/27 10:04:21 eric * Ajout de l'operator% (produit tensoriel avec desaliasing) * * Revision 2.10 2001/05/26 15:43:17 eric * Ajout de la fonction flat_scalar_prod_desal (desaliasage) * * Revision 2.9 2000/10/06 15:08:40 eric * Traitement des cas ETATZERO dans contract et flat_scal_prod * * Revision 2.8 2000/09/13 09:43:29 eric * Modif skxk : appel des nouvelles fonctions Valeur::mult_cp() et * Valeur::mult_sp() pour la multiplication par cos(phi) et sin(phi). * * Revision 2.7 2000/02/09 19:32:11 eric * MODIF IMPORTANTE: la triade de decomposition est desormais passee en * argument des constructeurs. * * Revision 2.6 2000/02/01 14:14:25 eric * Ajout de la fonction amie flat_scalar_prod. * * Revision 2.5 2000/01/21 12:59:18 phil * ajout de skxk * * Revision 2.4 2000/01/14 09:29:43 eric * *** empty log message *** * * Revision 2.3 2000/01/13 17:22:37 phil * la fonction contraction de deux tenseurs ne passe plus par produit tensoriel * * Revision 2.2 2000/01/11 11:14:29 eric * Changement de nom pour la base vectorielle : base --> triad * * Revision 2.1 2000/01/10 17:25:15 eric * Gestion des bases vectorielles (triades de decomposition). * * Revision 2.0 1999/12/02 17:19:06 phil * *** empty log message *** * * * $Header: /cvsroot/Lorene/C++/Source/Tenseur/tenseur_operateur.C,v 1.10 2014/10/13 08:53:42 j_novak Exp $ * */ // Headers C #include #include #include // Headers Lorene #include "tenseur.h" #include "metrique.h" namespace Lorene { Tenseur operator*(const Tenseur& t1, const Tenseur& t2) { assert ((t1.etat != ETATNONDEF) && (t2.etat != ETATNONDEF)) ; assert (t1.mp == t2.mp) ; int val_res = t1.valence + t2.valence ; double poids_res = t1.poids + t2.poids ; poids_res = (fabs(poids_res) < 1.e-10 ? 0. : poids_res) ; const Metrique* met_res = 0x0 ; if (poids_res != 0.) { // assert((t1.metric != 0x0) || (t2.metric != 0x0)) ; if (t1.metric != 0x0) met_res = t1.metric ; else met_res = t2.metric ; } // cas scalaire : if (val_res == 0) { Tenseur scal(*t1.mp, met_res, poids_res) ; // cas ou un des deux est nul : if ((t1.etat == ETATZERO) || (t2.etat == ETATZERO)) scal.set_etat_zero() ; else { scal.set_etat_qcq() ; scal.set() = t1() * t2() ; } return scal ; } else { Itbl tipe (val_res) ; tipe.set_etat_qcq() ; for (int i=0 ; i= 0) && (ind_1 < source.valence)) ; assert ((ind_2 >= 0) && (ind_2 < source.valence)) ; assert (source.type_indice(ind_1) != source.type_indice(ind_2)) ; // On veut ind_1 < ind_2 : if (ind_1 > ind_2) { int auxi = ind_2 ; ind_2 = ind_1 ; ind_1 = auxi ; } // On construit le resultat : int val_res = source.valence - 2 ; Itbl tipe (val_res) ; tipe.set_etat_qcq() ; for (int i=0 ; i=0) && (ind1=0) && (ind2=0) && (ind1=0) && (ind2=0) && (place < valen)) ; Itbl tipe (valen) ; tipe.set_etat_qcq() ; tipe.set(0) = -t1.type_indice(place) ; for (int i=1 ; i 0) ; assert (source.etat != ETATNONDEF) ; assert (*source.triad == source.mp->get_bvect_cart()) ; // Le resultat : int val_res = source.valence-1 ; Itbl tipe (val_res) ; tipe.set_etat_qcq() ; for (int i=0 ; i(source.get_mp()) != 0x0) ; resu.va = (resu.va).mult_st() ; // Multipl. by sin(theta) resu.va = (resu.va).mult_cp() ; // Multipl. by cos(phi) // y S_y // ----- indices_so.set(val_res) = 1 ; Cmp auxiliaire (source(indices_so)) ; auxiliaire.mult_r() ; // Multipl. by r auxiliaire.va = (auxiliaire.va).mult_st() ; // Multipl. by sin(theta) auxiliaire.va = (auxiliaire.va).mult_sp() ; // Multipl. by sin(phi) resu = resu + auxiliaire ; // z S_z // ----- indices_so.set(val_res) = 2 ; auxiliaire = source(indices_so) ; auxiliaire.mult_r() ; // Multipl. by r auxiliaire.va = (auxiliaire.va).mult_ct() ; // Multipl. by cos(theta) resu = resu + auxiliaire ; res.set(indices_res) = resu ; // The End // ------- } } return res ; } Tenseur flat_scalar_prod(const Tenseur& t1, const Tenseur& t2) { assert ((t1.etat != ETATNONDEF) && (t2.etat != ETATNONDEF)) ; // Verifs : assert (t1.mp == t2.mp) ; // Contraction possible ? if ( (t1.valence != 0) && (t2.valence != 0) ) { assert ( *(t1.get_triad()) == *(t2.get_triad()) ) ; } int val_res = t1.valence + t2.valence - 2; double poids_res = t1.poids + t2.poids ; poids_res = (fabs(poids_res) < 1.e-10 ? 0. : poids_res) ; const Metrique* met_res = 0x0 ; if (poids_res != 0.) { assert((t1.metric != 0x0) || (t2.metric != 0x0)) ; if (t1.metric != 0x0) met_res = t1.metric ; else met_res = t2.metric ; } Itbl tipe(val_res) ; tipe.set_etat_qcq() ; for (int i=0 ; iidentify() == x.get_triad()->identify()) ; for (int i=0 ; i