LORENE
tenseur_compare.C
1 /*
2  * File to compare two tensors
3  *
4  */
5 
6 /*
7  * Copyright (c) 2003 Francois Limousin
8  *
9  * This file is part of LORENE.
10  *
11  * LORENE is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License version 2
13  * as published by the Free Software Foundation.
14  *
15  * LORENE is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with LORENE; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  *
24  */
25 
26 char tenseur_compare_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tenseur/tenseur_compare.C,v 1.3 2014/10/13 08:53:42 j_novak Exp $" ;
27 
28 /*
29  * $Id: tenseur_compare.C,v 1.3 2014/10/13 08:53:42 j_novak Exp $
30  * $Log: tenseur_compare.C,v $
31  * Revision 1.3 2014/10/13 08:53:42 j_novak
32  * Lorene classes and functions now belong to the namespace Lorene.
33  *
34  * Revision 1.2 2004/05/27 07:17:19 p_grandclement
35  * Correction of some shadowed variables
36  *
37  * Revision 1.1 2003/06/20 15:01:49 f_limousin
38  * *** empty log message ***
39  *
40  * Revision 1.2 2001/12/11 06:44:41 e_gourgoulhon
41  * template files
42  *
43  *
44  *
45  * $Header: /cvsroot/Lorene/C++/Source/Tenseur/tenseur_compare.C,v 1.3 2014/10/13 08:53:42 j_novak Exp $
46  *
47  */
48 
49 // C headers
50 #include "math.h"
51 
52 // Lorene headers
53 #include "tenseur.h"
54 
55 
56 namespace Lorene {
57 void Tenseur::compare(const Tenseur& tens, const char* name) {
58  assert ( valence == tens.get_valence() ) ;
59 
60  cout << "----------------------------------------------" << endl ;
61  cout << "Comparison of " << name << " : " << endl << endl ;
62 
63  if (valence == 0) {
64  Cmp comp = tens() ;
65  Cmp tmp = (*this)() ;
66  tmp.compare(comp, name) ;
67  }
68 
69  if (valence == 1) {
70  Cmp comp0 = tens(0) ;
71  Cmp comp1 = tens(1) ;
72  Cmp comp2 = tens(2) ;
73 
74  Cmp tmp0 = (*this)(0) ;
75  Cmp tmp1 = (*this)(1) ;
76  Cmp tmp2 = (*this)(2) ;
77 
78  tmp0.compare(comp0, name, 0) ;
79  tmp1.compare(comp1, name, 1) ;
80  tmp2.compare(comp2, name, 2) ;
81  }
82 
83  if (valence == 2) {
84  Cmp comp00 = tens(0,0) ;
85  Cmp comp01 = tens(0,1) ;
86  Cmp comp02 = tens(0,2) ;
87  Cmp comp10 = tens(1,0) ;
88  Cmp comp11 = tens(1,1) ;
89  Cmp comp12 = tens(1,2) ;
90  Cmp comp20 = tens(2,0) ;
91  Cmp comp21 = tens(2,1) ;
92  Cmp comp22 = tens(2,2) ;
93 
94  Cmp tmp00 = (*this)(0,0) ;
95  Cmp tmp01 = (*this)(0,1) ;
96  Cmp tmp02 = (*this)(0,2) ;
97  Cmp tmp10 = (*this)(1,0) ;
98  Cmp tmp11 = (*this)(1,1) ;
99  Cmp tmp12 = (*this)(1,2) ;
100  Cmp tmp20 = (*this)(2,0) ;
101  Cmp tmp21 = (*this)(2,1) ;
102  Cmp tmp22 = (*this)(2,2) ;
103 
104  tmp00.compare(comp00, name, 0, 0) ;
105  tmp01.compare(comp01, name, 0, 1) ;
106  tmp02.compare(comp02, name, 0, 2) ;
107  tmp10.compare(comp10, name, 1, 0) ;
108  tmp11.compare(comp11, name, 1, 1) ;
109  tmp12.compare(comp12, name, 1, 2) ;
110  tmp20.compare(comp20, name, 2, 0) ;
111  tmp21.compare(comp21, name, 2, 1) ;
112  tmp22.compare(comp22, name, 2, 2) ;
113 }
114 
115  if (valence > 2 ) {
116  abort() ;
117  }
118 }
119 
120 void Tenseur::compare(FILE* fich, const char* name_i) {
121 
122  Mg3d mg(fich) ;
123  Map_et mpg(mg, fich) ;
124 
125  Tenseur tens(mpg, mpg.get_bvect_cart(), fich) ;
126 
127  compare(tens, name_i) ;
128 
129 
130 }
131 }
void compare(const Tenseur &tens, const char *name)
Functions to compare the values of tensors.
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
Definition: cmp.h:443
Radial mapping of rather general form.
Definition: map.h:2752
Lorene prototypes.
Definition: app_hor.h:64
int get_valence() const
Returns the valence.
Definition: tenseur.h:707
int valence
Valence.
Definition: tenseur.h:304
Multi-domain grid.
Definition: grilles.h:273
const Base_vect_cart & get_bvect_cart() const
Returns the Cartesian basis associated with the coordinates (x,y,z) of the mapping, i.e.
Definition: map.h:791
Tensor handling *** DEPRECATED : use class Tensor instead ***.
Definition: tenseur.h:298