/* * Methods of class Tensor_sym * * (see file tensor.h for documentation) * */ /* * Copyright (c) 2004 Eric Gourgoulhon & Jerome Novak * * Copyright (c) 1999-2001 Philippe Grandclement (for preceding class Tenseur) * * 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 tensor_sym_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tensor/tensor_sym.C,v 1.3 2014/10/13 08:53:44 j_novak Exp $" ; /* * $Id: tensor_sym.C,v 1.3 2014/10/13 08:53:44 j_novak Exp $ * $Log: tensor_sym.C,v $ * Revision 1.3 2014/10/13 08:53:44 j_novak * Lorene classes and functions now belong to the namespace Lorene. * * Revision 1.2 2014/10/06 15:13:20 j_novak * Modified #include directives to use c++ syntax. * * Revision 1.1 2004/01/04 20:51:45 e_gourgoulhon * New class to deal with general tensors which are symmetric with * respect to two of their indices. * * * $Header: /cvsroot/Lorene/C++/Source/Tensor/tensor_sym.C,v 1.3 2014/10/13 08:53:44 j_novak Exp $ * */ // Headers C #include #include #include // Headers Lorene #include "tensor.h" #include "utilitaires.h" //--------------// // Constructors // //--------------// // Standard constructor // -------------------- namespace Lorene { Tensor_sym::Tensor_sym(const Map& map, int val, const Itbl& tipe, const Base_vect& triad_i, int index_sym1, int index_sym2) : Tensor(map, val, tipe, 6*int(pow(3.,val-2)), triad_i), id_sym1(index_sym1), id_sym2(index_sym2) { // Des verifs : assert( valence >= 2 ) ; assert( (id_sym1 >=0) && (id_sym1 < valence) ) ; assert( (id_sym2 >=0) && (id_sym2 < valence) ) ; assert( id_sym1 != id_sym2 ) ; // The symmetry indices must be of same type: assert( tipe(id_sym1) == tipe(id_sym2) ) ; // Possible re-ordering of the symmetry indices if (id_sym1 > id_sym2) { int tmp = id_sym1 ; id_sym1 = id_sym2 ; id_sym2 = tmp ; } } // Standard constructor when all the indices are of the same type // -------------------------------------------------------------- Tensor_sym::Tensor_sym(const Map& map, int val, int tipe, const Base_vect& triad_i, int index_sym1, int index_sym2) : Tensor(map, val, tipe, 6*int(pow(3.,val-2)), triad_i), id_sym1(index_sym1), id_sym2(index_sym2) { // Des verifs : assert( valence >= 2 ) ; assert( (id_sym1 >=0) && (id_sym1 < valence) ) ; assert( (id_sym2 >=0) && (id_sym2 < valence) ) ; assert( id_sym1 != id_sym2 ) ; // Possible re-ordering of the symmetry indices if (id_sym1 > id_sym2) { int tmp = id_sym1 ; id_sym1 = id_sym2 ; id_sym2 = tmp ; } } // Constructor for a valence 3 symmetric tensor // -------------------------------------------- Tensor_sym::Tensor_sym(const Map& map, int tipe0, int tipe1, int tipe2, const Base_vect& triad_i, int index_sym1, int index_sym2) : Tensor(map, 3, tipe0, 18, triad_i), id_sym1(index_sym1), id_sym2(index_sym2) { assert( (tipe0==COV) || (tipe0==CON) ) ; assert( (tipe1==COV) || (tipe1==CON) ) ; assert( (tipe2==COV) || (tipe2==CON) ) ; type_indice.set(1) = tipe1 ; type_indice.set(2) = tipe2 ; assert( (id_sym1 >=0) && (id_sym1 < 3) ) ; assert( (id_sym2 >=0) && (id_sym2 < 3) ) ; assert( id_sym1 != id_sym2 ) ; assert( type_indice(id_sym1) == type_indice(id_sym2) ) ; // Possible re-ordering of the symmetry indices if (id_sym1 > id_sym2) { int tmp = id_sym1 ; id_sym1 = id_sym2 ; id_sym2 = tmp ; } } // Copy constructor // ---------------- Tensor_sym::Tensor_sym(const Tensor_sym& source) : Tensor(*source.mp, source.valence, source.type_indice, 6*int(pow(3.,source.valence-2)) , *(source.triad)), id_sym1(source.id_sym1), id_sym2(source.id_sym2) { for (int i=0 ; i=1) && (idx(i)<=3) ) ; } // The two symmetric indices are moved to the end --> new index array idx0 Itbl idx0(valence) ; if (valence > 2) { for (int id=0 ; id=0) && (place2) && (reste<5) ) { idx0.set(valence-2) = 2 ; idx0.set(valence-1) = reste - 1 ; } if (reste == 5) { idx0.set(valence-2) = 3 ; idx0.set(valence-1) = 3 ; } // The output is ready in the case of a valence 2 tensor: if (valence == 2) return idx0 ; for (int id=valence-3 ; id>=0 ; id--) { int ind = div(place, 3).rem ; place = int((place-ind)/3) ; idx0.set(id) = ind + 1 ; } // Reorganization of the index set to put the two symmetric indices at // their correct positions: Itbl idx(valence) ; for (int id=0 ; id