| 1 |
/* |
| 2 |
* Method Base_val::name_phi |
| 3 |
* |
| 4 |
* (see file base_val.h for documentation). |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
/* |
| 9 |
* Copyright (c) 2003 Eric Gourgoulhon. |
| 10 |
* |
| 11 |
* This file is part of LORENE. |
| 12 |
* |
| 13 |
* LORENE is free software; you can redistribute it and/or modify |
| 14 |
* it under the terms of the GNU General Public License version 2 |
| 15 |
* as published by the Free Software Foundation. |
| 16 |
* |
| 17 |
* LORENE is distributed in the hope that it will be useful, |
| 18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 |
* GNU General Public License for more details. |
| 21 |
* |
| 22 |
* You should have received a copy of the GNU General Public License |
| 23 |
* along with LORENE; if not, write to the Free Software |
| 24 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 |
* |
| 26 |
*/ |
| 27 |
|
| 28 |
char base_val_name_phi_C[] = "$Header: /cvsroot/Lorene/C++/Source/Base_val/base_val_name_phi.C,v 1.4 2014/10/13 08:52:39 j_novak Exp $" ; |
| 29 |
|
| 30 |
/* |
| 31 |
* $Id: base_val_name_phi.C,v 1.4 2014/10/13 08:52:39 j_novak Exp $ |
| 32 |
* $Log: base_val_name_phi.C,v $ |
| 33 |
* Revision 1.4 2014/10/13 08:52:39 j_novak |
| 34 |
* Lorene classes and functions now belong to the namespace Lorene. |
| 35 |
* |
| 36 |
* Revision 1.3 2014/10/06 15:12:57 j_novak |
| 37 |
* Modified #include directives to use c++ syntax. |
| 38 |
* |
| 39 |
* Revision 1.2 2012/01/17 14:44:27 j_penner |
| 40 |
* Modified phi variables to only use 16 integers in arrays |
| 41 |
* |
| 42 |
* Revision 1.1 2003/10/19 19:49:40 e_gourgoulhon |
| 43 |
* First version |
| 44 |
* |
| 45 |
* |
| 46 |
* |
| 47 |
* $Header: /cvsroot/Lorene/C++/Source/Base_val/base_val_name_phi.C,v 1.4 2014/10/13 08:52:39 j_novak Exp $ |
| 48 |
* |
| 49 |
*/ |
| 50 |
|
| 51 |
// C headers |
| 52 |
#include <cstring> |
| 53 |
#include <cstdlib> |
| 54 |
|
| 55 |
// Lorene headers |
| 56 |
#include "base_val.h" |
| 57 |
|
| 58 |
// Local prototypes |
| 59 |
namespace Lorene { |
| 60 |
void basename_p_unknown(int, char*) ; |
| 61 |
void basename_p_cossin(int, char*) ; |
| 62 |
void basename_p_cossin_p(int, char*) ; |
| 63 |
void basename_p_cossin_i(int, char*) ; |
| 64 |
|
| 65 |
//----------------------------// |
| 66 |
// Base_val method // |
| 67 |
//----------------------------// |
| 68 |
|
| 69 |
void Base_val::name_phi(int l, int k, char* name) const { |
| 70 |
|
| 71 |
// Array of actual base name functions |
| 72 |
static void(*vbasename_p[MAX_BASE_2])(int, char*) ; |
| 73 |
|
| 74 |
static bool first_call = true ; |
| 75 |
|
| 76 |
// Initializations at first call |
| 77 |
// ----------------------------- |
| 78 |
if ( first_call ) { |
| 79 |
|
| 80 |
first_call = false ; |
| 81 |
|
| 82 |
for (int i=0 ; i<MAX_BASE_2 ; i++) { |
| 83 |
vbasename_p[i] = basename_p_unknown ; |
| 84 |
} |
| 85 |
|
| 86 |
vbasename_p[P_COSSIN >> TRA_P] = basename_p_cossin ; |
| 87 |
vbasename_p[P_COSSIN_P >> TRA_P] = basename_p_cossin_p ; |
| 88 |
vbasename_p[P_COSSIN_I >> TRA_P] = basename_p_cossin_i ; |
| 89 |
|
| 90 |
} |
| 91 |
|
| 92 |
// Call to the function adapted to the basis in domain l |
| 93 |
//------------------------------------------------------ |
| 94 |
|
| 95 |
assert( (l>=0) && (l<nzone) ) ; |
| 96 |
|
| 97 |
int base_p = ( b[l] & MSQ_P ) >> TRA_P ; |
| 98 |
|
| 99 |
vbasename_p[base_p](k, name) ; |
| 100 |
|
| 101 |
} |
| 102 |
|
| 103 |
|
| 104 |
//-------------------------------// |
| 105 |
// individual basis functions // |
| 106 |
//-------------------------------// |
| 107 |
|
| 108 |
void basename_p_unknown(int, char*) { |
| 109 |
cout << "Base_val::name_phi : unknwon basis !" << endl ; |
| 110 |
abort() ; |
| 111 |
} |
| 112 |
|
| 113 |
|
| 114 |
void basename_p_cossin(int k, char* name) { |
| 115 |
|
| 116 |
assert( k>=0 ) ; |
| 117 |
|
| 118 |
if (k%2 == 0) { |
| 119 |
strcpy(name, "cos") ; |
| 120 |
} |
| 121 |
else { |
| 122 |
if (k == 1) { |
| 123 |
strcpy(name, "unused") ; |
| 124 |
return ; |
| 125 |
} |
| 126 |
else { |
| 127 |
strcpy(name, "sin") ; |
| 128 |
} |
| 129 |
} |
| 130 |
|
| 131 |
int m = k / 2 ; |
| 132 |
|
| 133 |
char cm[4] ; |
| 134 |
assert( m < 1000) ; |
| 135 |
sprintf(cm, "%d", m) ; |
| 136 |
strcat(name, cm) ; |
| 137 |
strcat(name, "p") ; |
| 138 |
|
| 139 |
} |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
void basename_p_cossin_p(int k, char* name) { |
| 144 |
|
| 145 |
assert( k>=0 ) ; |
| 146 |
|
| 147 |
if (k%2 == 0) { |
| 148 |
strcpy(name, "cos") ; |
| 149 |
} |
| 150 |
else { |
| 151 |
if (k == 1) { |
| 152 |
strcpy(name, "unused") ; |
| 153 |
return ; |
| 154 |
} |
| 155 |
else { |
| 156 |
strcpy(name, "sin") ; |
| 157 |
} |
| 158 |
} |
| 159 |
|
| 160 |
int m = 2 * (k / 2) ; |
| 161 |
|
| 162 |
char cm[4] ; |
| 163 |
assert( m < 1000) ; |
| 164 |
sprintf(cm, "%d", m) ; |
| 165 |
strcat(name, cm) ; |
| 166 |
strcat(name, "p") ; |
| 167 |
|
| 168 |
} |
| 169 |
|
| 170 |
|
| 171 |
void basename_p_cossin_i(int k, char* name) { |
| 172 |
|
| 173 |
assert( k>=0 ) ; |
| 174 |
|
| 175 |
if (k == 0) { |
| 176 |
strcpy(name, "cos1p") ; |
| 177 |
return ; |
| 178 |
} |
| 179 |
|
| 180 |
if (k%2 == 0) { |
| 181 |
strcpy(name, "sin") ; |
| 182 |
} |
| 183 |
else { |
| 184 |
if (k == 1) { |
| 185 |
strcpy(name, "unused") ; |
| 186 |
return ; |
| 187 |
} |
| 188 |
else { |
| 189 |
strcpy(name, "cos") ; |
| 190 |
} |
| 191 |
} |
| 192 |
|
| 193 |
int m = 2 * ((k-1) / 2) + 1 ; |
| 194 |
|
| 195 |
char cm[4] ; |
| 196 |
assert( m < 1000) ; |
| 197 |
sprintf(cm, "%d", m) ; |
| 198 |
strcat(name, cm) ; |
| 199 |
strcat(name, "p") ; |
| 200 |
|
| 201 |
} |
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
} |