Debian Codegraph @

C++/Source/Valeur/valeur_scost.C

raw
1 /*
2 * Computation of 1/(cos theta)
3 *
4 * for:
5 * - Valeur
6 * - Mtbl_cf
7 */
8
9 /*
10 * Copyright (c) 1999-2001 Jerome Novak
11 * Copyright (c) 1999-2001 Eric Gourgoulhon
12 *
13 * This file is part of LORENE.
14 *
15 * LORENE is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * LORENE is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with LORENE; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 */
30
31
32 char valeur_scost_C[] = "$Header: /cvsroot/Lorene/C++/Source/Valeur/valeur_scost.C,v 1.5 2014/10/13 08:53:51 j_novak Exp $" ;
33
34 /*
35 * $Id: valeur_scost.C,v 1.5 2014/10/13 08:53:51 j_novak Exp $
36 * $Log: valeur_scost.C,v $
37 * Revision 1.5 2014/10/13 08:53:51 j_novak
38 * Lorene classes and functions now belong to the namespace Lorene.
39 *
40 * Revision 1.4 2014/10/06 15:13:24 j_novak
41 * Modified #include directives to use c++ syntax.
42 *
43 * Revision 1.3 2009/10/10 18:28:11 j_novak
44 * New bases T_COS and T_SIN.
45 *
46 * Revision 1.2 2004/11/23 15:17:19 m_forot
47 * Added the bases for the cases without any equatorial symmetry
48 * (T_COSSIN_C, T_COSSIN_S, T_LEG, R_CHEBPI_P, R_CHEBPI_I).
49 *
50 * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon
51 * LORENE
52 *
53 * Revision 1.5 1999/11/30 12:45:27 eric
54 * Valeur::base est desormais du type Base_val et non plus Base_val*.
55 *
56 * Revision 1.4 1999/11/24 09:34:46 eric
57 * Modif commentaires.
58 *
59 * Revision 1.3 1999/11/23 16:18:13 eric
60 * Reorganisation du calcul dans le cas ETATZERO.
61 *
62 * Revision 1.2 1999/11/19 09:31:31 eric
63 * La valeur de retour est desormais const Valeur &.
64 *
65 * Revision 1.1 1999/11/16 13:37:50 novak
66 * Initial revision
67 *
68 *
69 * $Header: /cvsroot/Lorene/C++/Source/Valeur/valeur_scost.C,v 1.5 2014/10/13 08:53:51 j_novak Exp $
70 *
71 */
72
73 // Headers C
74 #include <cassert>
75
76 // Headers Lorene
77 #include "mtbl_cf.h"
78 #include "valeur.h"
79
80 // Local prototypes
81 namespace Lorene {
82 void _scost_pas_prevu (Tbl*, int&) ;
83 void _scost_t_cos (Tbl*, int&) ;
84 void _scost_t_sin (Tbl*, int&) ;
85 void _scost_t_sin_p (Tbl*, int&) ;
86 void _scost_t_sin_i (Tbl*, int&) ;
87 void _scost_t_cos_i (Tbl*, int&) ;
88 void _scost_t_cos_p (Tbl*, int&) ;
89 void _scost_t_cossin_si (Tbl*, int&) ;
90 void _scost_t_cossin_ci (Tbl*, int&) ;
91 void _scost_t_cossin_cp (Tbl*, int&) ;
92 void _scost_t_cossin_sp (Tbl*, int&) ;
93 void _scost_t_cossin_c (Tbl*, int&) ;
94 void _scost_t_cossin_s (Tbl*, int&) ;
95
96 // Version membre d'un Valeur
97 // --------------------------
98
99 const Valeur& Valeur::scost() const {
100
101 // Protection
102 assert(etat != ETATNONDEF) ;
103
104 // Peut-etre rien a faire ?
105 if (p_scost != 0x0) {
106 return *p_scost ;
107 }
108
109 // ... si, il faut bosser
110
111 p_scost = new Valeur(mg) ;
112
113 if (etat == ETATZERO) {
114 p_scost->set_etat_zero() ;
115 }
116 else {
117 assert(etat == ETATQCQ) ;
118 p_scost->set_etat_cf_qcq() ;
119 Mtbl_cf* cfp = p_scost->c_cf ; // Pointeur sur le Mtbl_cf qui vient d'etre
120 // cree par le set_etat_cf_qcq()
121
122 // Initialisation de *cfp : recopie des coef. de la fonction
123 if (c_cf == 0x0) {
124 coef() ;
125 }
126 *cfp = *c_cf ;
127
128 cfp->scost() ; // calcul
129
130 p_scost->base = cfp->base ; // On remonte la base de sortie au niveau Valeur
131 }
132
133 // Termine
134 return *p_scost ;
135 }
136
137
138
139 // Version membre d'un Mtbl_cf
140 // ---------------------------
141
142 void Mtbl_cf::scost() {
143
144 // Routines de derivation
145 static void (*_scost[MAX_BASE])(Tbl *, int &) ;
146 static int nap = 0 ;
147
148 // Premier appel
149 if (nap==0) {
150 nap = 1 ;
151 for (int i=0 ; i<MAX_BASE ; i++) {
152 _scost[i] = _scost_pas_prevu ;
153 }
154 // Les routines existantes
155 _scost[T_COS >> TRA_T] = _scost_t_cos ;
156 _scost[T_SIN >> TRA_T] = _scost_t_sin ;
157 _scost[T_COS_P >> TRA_T] = _scost_t_cos_p ;
158 _scost[T_COS_I >> TRA_T] = _scost_t_cos_i ;
159 _scost[T_SIN_P >> TRA_T] = _scost_t_sin_p ;
160 _scost[T_SIN_I >> TRA_T] = _scost_t_sin_i ;
161 _scost[T_COSSIN_SI >> TRA_T] = _scost_t_cossin_si ;
162 _scost[T_COSSIN_CI >> TRA_T] = _scost_t_cossin_ci ;
163 _scost[T_COSSIN_CP >> TRA_T] = _scost_t_cossin_cp ;
164 _scost[T_COSSIN_SP >> TRA_T] = _scost_t_cossin_sp ;
165 _scost[T_COSSIN_C >> TRA_T] = _scost_t_cossin_c ;
166 _scost[T_COSSIN_S >> TRA_T] = _scost_t_cossin_s ;
167 }
168
169 // Debut de la routine
170
171 // Protection
172 assert(etat == ETATQCQ) ;
173
174 // Boucle sur les zones
175 int base_t ;
176 for (int l=0 ; l<nzone ; l++) {
177 base_t = (base.b[l] & MSQ_T) >> TRA_T ;
178 assert(t[l] != 0x0) ;
179 _scost[base_t](t[l], base.b[l]) ;
180 }
181 }
182 }