| 1 |
/* |
| 2 |
* Methods of class Param |
| 3 |
* |
| 4 |
* (see file param.h for documentation) |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
/* |
| 9 |
* Copyright (c) 1999-2005 Eric Gourgoulhon |
| 10 |
* Copyright (c) 2000-2003 Jerome Novak |
| 11 |
* |
| 12 |
* This file is part of LORENE. |
| 13 |
* |
| 14 |
* LORENE is free software; you can redistribute it and/or modify |
| 15 |
* it under the terms of the GNU General Public License as published by |
| 16 |
* the Free Software Foundation; either version 2 of the License, or |
| 17 |
* (at your option) any later version. |
| 18 |
* |
| 19 |
* LORENE is distributed in the hope that it will be useful, |
| 20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 |
* GNU General Public License for more details. |
| 23 |
* |
| 24 |
* You should have received a copy of the GNU General Public License |
| 25 |
* along with LORENE; if not, write to the Free Software |
| 26 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 27 |
* |
| 28 |
*/ |
| 29 |
|
| 30 |
|
| 31 |
char param_C[] = "$Header: /cvsroot/Lorene/C++/Source/Param/param.C,v 1.9 2014/10/13 08:53:37 j_novak Exp $" ; |
| 32 |
|
| 33 |
/* |
| 34 |
* $Id: param.C,v 1.9 2014/10/13 08:53:37 j_novak Exp $ |
| 35 |
* $Log: param.C,v $ |
| 36 |
* Revision 1.9 2014/10/13 08:53:37 j_novak |
| 37 |
* Lorene classes and functions now belong to the namespace Lorene. |
| 38 |
* |
| 39 |
* Revision 1.8 2014/10/06 15:13:16 j_novak |
| 40 |
* Modified #include directives to use c++ syntax. |
| 41 |
* |
| 42 |
* Revision 1.7 2006/06/15 08:15:39 j_novak |
| 43 |
* Removed members linked to Qtenseur objects. |
| 44 |
* Added members for Matrice objects. |
| 45 |
* |
| 46 |
* Revision 1.6 2005/08/13 16:11:44 m_saijo |
| 47 |
* Added storage of a Star |
| 48 |
* |
| 49 |
* Revision 1.5 2005/03/24 21:56:31 e_gourgoulhon |
| 50 |
* Added storage of a Scalar. |
| 51 |
* |
| 52 |
* Revision 1.4 2003/09/25 12:08:03 j_novak |
| 53 |
* Tensors can be stored in Param objects |
| 54 |
* |
| 55 |
* Revision 1.3 2002/10/16 14:37:12 j_novak |
| 56 |
* Reorganization of #include instructions of standard C++, in order to |
| 57 |
* use experimental version 3 of gcc. |
| 58 |
* |
| 59 |
* Revision 1.2 2002/09/19 09:52:42 j_novak |
| 60 |
* Added objects Qtenseur and Qmetrique for 4D tensor and metric handling. |
| 61 |
* |
| 62 |
* Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon |
| 63 |
* LORENE |
| 64 |
* |
| 65 |
* Revision 1.8 2001/10/11 07:44:27 eric |
| 66 |
* Ajout du stokage des Etoile's |
| 67 |
* |
| 68 |
* Revision 1.7 2000/10/24 14:55:20 novak |
| 69 |
* Added the function clean_all() |
| 70 |
* |
| 71 |
* Revision 1.6 2000/05/25 12:40:47 eric |
| 72 |
* MODIFICATION MAJEURE: pour les int et les double, ce sont desormais les |
| 73 |
* dresses qui sont stokees, et non plus les nombres eux-memes |
| 74 |
* (le traitement des int et des double est donc desormais completement |
| 75 |
* aligne sur celui des Tbl, Cmp, etc...) |
| 76 |
* |
| 77 |
* Revision 1.5 1999/12/29 13:10:54 eric |
| 78 |
* Ajout du stokage des Mtbl_cf. |
| 79 |
* |
| 80 |
* Revision 1.4 1999/12/27 12:17:02 eric |
| 81 |
* Ajout du stokage des mappings (class Map). |
| 82 |
* |
| 83 |
* Revision 1.3 1999/12/16 10:28:25 eric |
| 84 |
* Ajout des membres modifiables. |
| 85 |
* Par defaut, les objets listes sont const. |
| 86 |
* |
| 87 |
* Revision 1.2 1999/12/15 16:23:22 eric |
| 88 |
* Changement de l'ordre des arguments dans add_* |
| 89 |
* Argument par defaut: position = 0 |
| 90 |
* Ajout du stokage des int et des double. |
| 91 |
* |
| 92 |
* Revision 1.1 1999/12/13 14:36:00 eric |
| 93 |
* Initial revision |
| 94 |
* |
| 95 |
* |
| 96 |
* $Header: /cvsroot/Lorene/C++/Source/Param/param.C,v 1.9 2014/10/13 08:53:37 j_novak Exp $ |
| 97 |
* |
| 98 |
*/ |
| 99 |
|
| 100 |
// Headers C |
| 101 |
#include <cstdlib> |
| 102 |
#include <cassert> |
| 103 |
|
| 104 |
// Headers Lorene |
| 105 |
#include "param.h" |
| 106 |
#include "tenseur.h" |
| 107 |
#include "tensor.h" |
| 108 |
#include "matrice.h" |
| 109 |
|
| 110 |
//------------------------// |
| 111 |
// Constructor // |
| 112 |
//------------------------// |
| 113 |
|
| 114 |
namespace Lorene { |
| 115 |
Param::Param() : n_int(0), |
| 116 |
n_int_mod(0), |
| 117 |
n_double(0), |
| 118 |
n_double_mod(0), |
| 119 |
n_tbl(0), |
| 120 |
n_tbl_mod(0), |
| 121 |
n_itbl(0), |
| 122 |
n_itbl_mod(0), |
| 123 |
n_matrice(0), |
| 124 |
n_matrice_mod(0), |
| 125 |
n_cmp(0), |
| 126 |
n_cmp_mod(0), |
| 127 |
n_tenseur(0), |
| 128 |
n_tenseur_mod(0), |
| 129 |
n_map(0), |
| 130 |
n_mtbl_cf(0), |
| 131 |
n_scalar(0), |
| 132 |
n_scalar_mod(0), |
| 133 |
n_tensor(0), |
| 134 |
n_tensor_mod(0), |
| 135 |
n_etoile(0), |
| 136 |
n_star(0) |
| 137 |
{} |
| 138 |
|
| 139 |
|
| 140 |
//----------------------// |
| 141 |
// Destructor // |
| 142 |
//----------------------// |
| 143 |
|
| 144 |
Param::~Param(){ |
| 145 |
|
| 146 |
if (n_int > 0) delete [] p_int ; |
| 147 |
if (n_int_mod > 0) delete [] p_int_mod ; |
| 148 |
if (n_double > 0) delete [] p_double ; |
| 149 |
if (n_double_mod > 0) delete [] p_double_mod ; |
| 150 |
if (n_tbl > 0) delete [] p_tbl ; |
| 151 |
if (n_tbl_mod > 0) delete [] p_tbl_mod ; |
| 152 |
if (n_itbl > 0) delete [] p_itbl ; |
| 153 |
if (n_itbl_mod > 0) delete [] p_itbl_mod ; |
| 154 |
if (n_matrice > 0) delete [] p_matrice ; |
| 155 |
if (n_matrice_mod > 0) delete [] p_matrice_mod ; |
| 156 |
if (n_cmp > 0) delete [] p_cmp ; |
| 157 |
if (n_cmp_mod > 0) delete [] p_cmp_mod ; |
| 158 |
if (n_tenseur > 0) delete [] p_tenseur ; |
| 159 |
if (n_tenseur_mod > 0) delete [] p_tenseur_mod ; |
| 160 |
if (n_map > 0) delete [] p_map ; |
| 161 |
if (n_mtbl_cf > 0) delete [] p_mtbl_cf ; |
| 162 |
if (n_scalar > 0) delete [] p_scalar ; |
| 163 |
if (n_scalar_mod > 0) delete [] p_scalar_mod ; |
| 164 |
if (n_tensor > 0) delete [] p_tensor ; |
| 165 |
if (n_tensor_mod > 0) delete [] p_tensor_mod ; |
| 166 |
if (n_etoile > 0) delete [] p_etoile ; |
| 167 |
if (n_star > 0) delete [] p_star ; |
| 168 |
} |
| 169 |
|
| 170 |
//------------------------------------// |
| 171 |
// cleaning the memory // |
| 172 |
//------------------------------------// |
| 173 |
|
| 174 |
void Param::clean_all() { |
| 175 |
|
| 176 |
for (int i=0; i<n_int_mod; i++) |
| 177 |
if (p_int_mod[i] != 0x0) { |
| 178 |
delete p_int_mod[i] ; |
| 179 |
p_int_mod[i] = 0x0 ; |
| 180 |
} |
| 181 |
|
| 182 |
for (int i=0; i<n_double_mod; i++) |
| 183 |
if (p_double_mod[i] != 0x0) { |
| 184 |
delete p_double_mod[i] ; |
| 185 |
p_double_mod[i] = 0x0 ; |
| 186 |
} |
| 187 |
|
| 188 |
for (int i=0; i<n_tbl_mod; i++) |
| 189 |
if (p_tbl_mod[i] != 0x0) { |
| 190 |
delete p_tbl_mod[i] ; |
| 191 |
p_tbl_mod[i] = 0x0 ; |
| 192 |
} |
| 193 |
|
| 194 |
for (int i=0; i<n_itbl_mod; i++) |
| 195 |
if (p_itbl_mod[i] != 0x0) { |
| 196 |
delete p_itbl_mod[i] ; |
| 197 |
p_itbl_mod[i] = 0x0 ; |
| 198 |
} |
| 199 |
|
| 200 |
for (int i=0; i<n_matrice_mod; i++) |
| 201 |
if (p_matrice_mod[i] != 0x0) { |
| 202 |
delete p_matrice_mod[i] ; |
| 203 |
p_matrice_mod[i] = 0x0 ; |
| 204 |
} |
| 205 |
|
| 206 |
for (int i=0; i<n_cmp_mod; i++) |
| 207 |
if (p_cmp_mod[i] != 0x0) { |
| 208 |
delete p_cmp_mod[i] ; |
| 209 |
p_cmp_mod[i] = 0x0 ; |
| 210 |
} |
| 211 |
|
| 212 |
for (int i=0; i<n_tenseur_mod; i++) |
| 213 |
if (p_tenseur_mod[i] != 0x0) { |
| 214 |
delete p_tenseur_mod[i] ; |
| 215 |
p_tenseur_mod[i] = 0x0 ; |
| 216 |
} |
| 217 |
|
| 218 |
for (int i=0; i<n_scalar_mod; i++) |
| 219 |
if (p_scalar_mod[i] != 0x0) { |
| 220 |
delete p_scalar_mod[i] ; |
| 221 |
p_scalar_mod[i] = 0x0 ; |
| 222 |
} |
| 223 |
|
| 224 |
for (int i=0; i<n_tensor_mod; i++) |
| 225 |
if (p_tensor_mod[i] != 0x0) { |
| 226 |
delete p_tensor_mod[i] ; |
| 227 |
p_tensor_mod[i] = 0x0 ; |
| 228 |
} |
| 229 |
} |
| 230 |
|
| 231 |
|
| 232 |
//------------------------------------// |
| 233 |
// int storage // |
| 234 |
//------------------------------------// |
| 235 |
|
| 236 |
// Total number of stored int |
| 237 |
// -------------------------- |
| 238 |
|
| 239 |
int Param::get_n_int() const { |
| 240 |
return n_int ; |
| 241 |
} |
| 242 |
|
| 243 |
// Addition |
| 244 |
// -------- |
| 245 |
|
| 246 |
void Param::add_int(const int& ti, int index){ |
| 247 |
|
| 248 |
if (index >= n_int) { // p_int must be rescaled |
| 249 |
|
| 250 |
int n_int_nouveau = index + 1 ; |
| 251 |
const int** p_int_nouveau = new const int*[n_int_nouveau] ; |
| 252 |
|
| 253 |
|
| 254 |
// Copy of the previous addresses |
| 255 |
for (int i=0; i<n_int; i++) { |
| 256 |
p_int_nouveau[i] = p_int[i] ; |
| 257 |
} |
| 258 |
|
| 259 |
|
| 260 |
// The intermediate addresses are set to 0x0 |
| 261 |
for (int i=n_int; i<index; i++) { |
| 262 |
p_int_nouveau[i] = 0x0 ; |
| 263 |
} |
| 264 |
|
| 265 |
// The new address |
| 266 |
p_int_nouveau[index] = &ti ; |
| 267 |
|
| 268 |
// Update |
| 269 |
if (n_int > 0) delete [] p_int ; |
| 270 |
p_int = p_int_nouveau ; |
| 271 |
n_int = n_int_nouveau ; |
| 272 |
|
| 273 |
} |
| 274 |
else { |
| 275 |
|
| 276 |
if (p_int[index] != 0x0) { |
| 277 |
cout << "Param::add_int : the position " << index |
| 278 |
<< " is already occupied !" << endl ; |
| 279 |
abort() ; |
| 280 |
} |
| 281 |
else{ |
| 282 |
p_int[index] = &ti ; |
| 283 |
} |
| 284 |
|
| 285 |
} |
| 286 |
|
| 287 |
} |
| 288 |
|
| 289 |
// Extraction |
| 290 |
// ---------- |
| 291 |
|
| 292 |
const int& Param::get_int(int index) const { |
| 293 |
|
| 294 |
assert(index >= 0) ; |
| 295 |
assert(index < n_int) ; |
| 296 |
|
| 297 |
return *(p_int[index]) ; |
| 298 |
|
| 299 |
} |
| 300 |
|
| 301 |
//------------------------------------// |
| 302 |
// double storage // |
| 303 |
//------------------------------------// |
| 304 |
|
| 305 |
// Total number of stored doubles |
| 306 |
// ------------------------------ |
| 307 |
|
| 308 |
int Param::get_n_double() const { |
| 309 |
return n_double ; |
| 310 |
} |
| 311 |
|
| 312 |
// Addition |
| 313 |
// -------- |
| 314 |
|
| 315 |
void Param::add_double(const double& ti, int index){ |
| 316 |
|
| 317 |
if (index >= n_double) { // p_double must be rescaled |
| 318 |
|
| 319 |
int n_double_nouveau = index + 1 ; |
| 320 |
const double** p_double_nouveau = |
| 321 |
new const double*[n_double_nouveau] ; |
| 322 |
|
| 323 |
|
| 324 |
// Copy of the previous addresses |
| 325 |
for (int i=0; i<n_double; i++) { |
| 326 |
p_double_nouveau[i] = p_double[i] ; |
| 327 |
} |
| 328 |
|
| 329 |
// The intermediate addresses are set to 0x0 |
| 330 |
for (int i=n_double; i<index; i++) { |
| 331 |
p_double_nouveau[i] = 0x0 ; |
| 332 |
} |
| 333 |
|
| 334 |
// The new address |
| 335 |
p_double_nouveau[index] = &ti ; |
| 336 |
|
| 337 |
// Update |
| 338 |
if (n_double > 0) delete [] p_double ; |
| 339 |
p_double = p_double_nouveau ; |
| 340 |
n_double = n_double_nouveau ; |
| 341 |
|
| 342 |
} |
| 343 |
else { |
| 344 |
|
| 345 |
if (p_double[index] != 0x0) { |
| 346 |
cout << "Param::add_double : the position " << index |
| 347 |
<< " is already occupied !" << endl ; |
| 348 |
abort() ; |
| 349 |
} |
| 350 |
else{ |
| 351 |
p_double[index] = &ti ; |
| 352 |
} |
| 353 |
|
| 354 |
} |
| 355 |
|
| 356 |
} |
| 357 |
|
| 358 |
// Extraction |
| 359 |
// ---------- |
| 360 |
|
| 361 |
const double& Param::get_double(int index) const { |
| 362 |
|
| 363 |
assert(index >= 0) ; |
| 364 |
assert(index < n_double) ; |
| 365 |
|
| 366 |
return *(p_double[index]) ; |
| 367 |
|
| 368 |
} |
| 369 |
|
| 370 |
|
| 371 |
//------------------------------------// |
| 372 |
// Modifiable int storage // |
| 373 |
//------------------------------------// |
| 374 |
|
| 375 |
// Total number of stored addresses |
| 376 |
// -------------------------------- |
| 377 |
|
| 378 |
int Param::get_n_int_mod() const { |
| 379 |
return n_int_mod ; |
| 380 |
} |
| 381 |
|
| 382 |
// Addition |
| 383 |
// -------- |
| 384 |
|
| 385 |
void Param::add_int_mod(int& ti, int index){ |
| 386 |
|
| 387 |
if (index >= n_int_mod) { // p_int_mod must be rescaled |
| 388 |
|
| 389 |
int n_int_nouveau = index + 1 ; |
| 390 |
int** p_int_nouveau = new int*[n_int_nouveau] ; |
| 391 |
|
| 392 |
|
| 393 |
// Copy of the previous addresses |
| 394 |
for (int i=0; i<n_int_mod; i++) { |
| 395 |
p_int_nouveau[i] = p_int_mod[i] ; |
| 396 |
} |
| 397 |
|
| 398 |
// The intermediate addresses are set to 0x0 |
| 399 |
for (int i=n_int_mod; i<index; i++) { |
| 400 |
p_int_nouveau[i] = 0x0 ; |
| 401 |
} |
| 402 |
|
| 403 |
// The new address |
| 404 |
p_int_nouveau[index] = &ti ; |
| 405 |
|
| 406 |
// Update |
| 407 |
if (n_int_mod > 0) delete [] p_int_mod ; |
| 408 |
p_int_mod = p_int_nouveau ; |
| 409 |
n_int_mod = n_int_nouveau ; |
| 410 |
|
| 411 |
} |
| 412 |
else { |
| 413 |
|
| 414 |
if (p_int_mod[index] != 0x0) { |
| 415 |
cout << "Param::add_int_mod : the position " << index |
| 416 |
<< " is already occupied !" << endl ; |
| 417 |
abort() ; |
| 418 |
} |
| 419 |
else{ |
| 420 |
p_int_mod[index] = &ti ; |
| 421 |
} |
| 422 |
|
| 423 |
} |
| 424 |
|
| 425 |
} |
| 426 |
|
| 427 |
// Extraction |
| 428 |
// ---------- |
| 429 |
|
| 430 |
int& Param::get_int_mod(int index) const { |
| 431 |
|
| 432 |
assert(index >= 0) ; |
| 433 |
assert(index < n_int_mod) ; |
| 434 |
|
| 435 |
return *(p_int_mod[index]) ; |
| 436 |
|
| 437 |
} |
| 438 |
|
| 439 |
//------------------------------------// |
| 440 |
// Modifiable double storage // |
| 441 |
//------------------------------------// |
| 442 |
|
| 443 |
// Total number of stored addresses |
| 444 |
// -------------------------------- |
| 445 |
|
| 446 |
int Param::get_n_double_mod() const { |
| 447 |
return n_double_mod ; |
| 448 |
} |
| 449 |
|
| 450 |
// Addition |
| 451 |
// -------- |
| 452 |
|
| 453 |
void Param::add_double_mod(double& ti, int index){ |
| 454 |
|
| 455 |
if (index >= n_double_mod) { // p_double_mod must be rescaled |
| 456 |
|
| 457 |
int n_double_nouveau = index + 1 ; |
| 458 |
double** p_double_nouveau = new double*[n_double_nouveau] ; |
| 459 |
|
| 460 |
|
| 461 |
// Copy of the previous addresses |
| 462 |
for (int i=0; i<n_double_mod; i++) { |
| 463 |
p_double_nouveau[i] = p_double_mod[i] ; |
| 464 |
} |
| 465 |
|
| 466 |
// The intermediate addresses are set to 0x0 |
| 467 |
for (int i=n_double_mod; i<index; i++) { |
| 468 |
p_double_nouveau[i] = 0x0 ; |
| 469 |
} |
| 470 |
|
| 471 |
// The new address |
| 472 |
p_double_nouveau[index] = &ti ; |
| 473 |
|
| 474 |
// Update |
| 475 |
if (n_double_mod > 0) delete [] p_double_mod ; |
| 476 |
p_double_mod = p_double_nouveau ; |
| 477 |
n_double_mod = n_double_nouveau ; |
| 478 |
|
| 479 |
} |
| 480 |
else { |
| 481 |
|
| 482 |
if (p_double_mod[index] != 0x0) { |
| 483 |
cout << "Param::add_double_mod : the position " << index |
| 484 |
<< " is already occupied !" << endl ; |
| 485 |
abort() ; |
| 486 |
} |
| 487 |
else{ |
| 488 |
p_double_mod[index] = &ti ; |
| 489 |
} |
| 490 |
|
| 491 |
} |
| 492 |
|
| 493 |
} |
| 494 |
|
| 495 |
// Extraction |
| 496 |
// ---------- |
| 497 |
|
| 498 |
double& Param::get_double_mod(int index) const { |
| 499 |
|
| 500 |
assert(index >= 0) ; |
| 501 |
assert(index < n_double_mod) ; |
| 502 |
|
| 503 |
return *(p_double_mod[index]) ; |
| 504 |
|
| 505 |
} |
| 506 |
|
| 507 |
|
| 508 |
//------------------------------------// |
| 509 |
// Tbl storage // |
| 510 |
//------------------------------------// |
| 511 |
|
| 512 |
// Total number of stored addresses |
| 513 |
// -------------------------------- |
| 514 |
|
| 515 |
int Param::get_n_tbl() const { |
| 516 |
return n_tbl ; |
| 517 |
} |
| 518 |
|
| 519 |
// Addition |
| 520 |
// -------- |
| 521 |
|
| 522 |
void Param::add_tbl(const Tbl& ti, int index){ |
| 523 |
|
| 524 |
if (index >= n_tbl) { // p_tbl must be rescaled |
| 525 |
|
| 526 |
int n_tbl_nouveau = index + 1 ; |
| 527 |
const Tbl** p_tbl_nouveau = new const Tbl*[n_tbl_nouveau] ; |
| 528 |
|
| 529 |
|
| 530 |
// Copy of the previous addresses |
| 531 |
for (int i=0; i<n_tbl; i++) { |
| 532 |
p_tbl_nouveau[i] = p_tbl[i] ; |
| 533 |
} |
| 534 |
|
| 535 |
// The intermediate addresses are set to 0x0 |
| 536 |
for (int i=n_tbl; i<index; i++) { |
| 537 |
p_tbl_nouveau[i] = 0x0 ; |
| 538 |
} |
| 539 |
|
| 540 |
// The new address |
| 541 |
p_tbl_nouveau[index] = &ti ; |
| 542 |
|
| 543 |
// Update |
| 544 |
if (n_tbl > 0) delete [] p_tbl ; |
| 545 |
p_tbl = p_tbl_nouveau ; |
| 546 |
n_tbl = n_tbl_nouveau ; |
| 547 |
|
| 548 |
} |
| 549 |
else { |
| 550 |
|
| 551 |
if (p_tbl[index] != 0x0) { |
| 552 |
cout << "Param::add_tbl : the position " << index |
| 553 |
<< " is already occupied !" << endl ; |
| 554 |
abort() ; |
| 555 |
} |
| 556 |
else{ |
| 557 |
p_tbl[index] = &ti ; |
| 558 |
} |
| 559 |
|
| 560 |
} |
| 561 |
|
| 562 |
} |
| 563 |
|
| 564 |
// Extraction |
| 565 |
// ---------- |
| 566 |
|
| 567 |
const Tbl& Param::get_tbl(int index) const { |
| 568 |
|
| 569 |
assert(index >= 0) ; |
| 570 |
assert(index < n_tbl) ; |
| 571 |
|
| 572 |
return *(p_tbl[index]) ; |
| 573 |
|
| 574 |
} |
| 575 |
|
| 576 |
|
| 577 |
//------------------------------------// |
| 578 |
// Modifiable Tbl storage // |
| 579 |
//------------------------------------// |
| 580 |
|
| 581 |
// Total number of stored addresses |
| 582 |
// -------------------------------- |
| 583 |
|
| 584 |
int Param::get_n_tbl_mod() const { |
| 585 |
return n_tbl_mod ; |
| 586 |
} |
| 587 |
|
| 588 |
// Addition |
| 589 |
// -------- |
| 590 |
|
| 591 |
void Param::add_tbl_mod(Tbl& ti, int index){ |
| 592 |
|
| 593 |
if (index >= n_tbl_mod) { // p_tbl_mod must be rescaled |
| 594 |
|
| 595 |
int n_tbl_nouveau = index + 1 ; |
| 596 |
Tbl** p_tbl_nouveau = new Tbl*[n_tbl_nouveau] ; |
| 597 |
|
| 598 |
|
| 599 |
// Copy of the previous addresses |
| 600 |
for (int i=0; i<n_tbl_mod; i++) { |
| 601 |
p_tbl_nouveau[i] = p_tbl_mod[i] ; |
| 602 |
} |
| 603 |
|
| 604 |
// The intermediate addresses are set to 0x0 |
| 605 |
for (int i=n_tbl_mod; i<index; i++) { |
| 606 |
p_tbl_nouveau[i] = 0x0 ; |
| 607 |
} |
| 608 |
|
| 609 |
// The new address |
| 610 |
p_tbl_nouveau[index] = &ti ; |
| 611 |
|
| 612 |
// Update |
| 613 |
if (n_tbl_mod > 0) delete [] p_tbl_mod ; |
| 614 |
p_tbl_mod = p_tbl_nouveau ; |
| 615 |
n_tbl_mod = n_tbl_nouveau ; |
| 616 |
|
| 617 |
} |
| 618 |
else { |
| 619 |
|
| 620 |
if (p_tbl_mod[index] != 0x0) { |
| 621 |
cout << "Param::add_tbl_mod : the position " << index |
| 622 |
<< " is already occupied !" << endl ; |
| 623 |
abort() ; |
| 624 |
} |
| 625 |
else{ |
| 626 |
p_tbl_mod[index] = &ti ; |
| 627 |
} |
| 628 |
|
| 629 |
} |
| 630 |
|
| 631 |
} |
| 632 |
|
| 633 |
// Extraction |
| 634 |
// ---------- |
| 635 |
|
| 636 |
Tbl& Param::get_tbl_mod(int index) const { |
| 637 |
|
| 638 |
assert(index >= 0) ; |
| 639 |
assert(index < n_tbl_mod) ; |
| 640 |
|
| 641 |
return *(p_tbl_mod[index]) ; |
| 642 |
|
| 643 |
} |
| 644 |
|
| 645 |
|
| 646 |
//------------------------------------// |
| 647 |
// Itbl storage // |
| 648 |
//------------------------------------// |
| 649 |
|
| 650 |
// Total number of stored addresses |
| 651 |
// -------------------------------- |
| 652 |
|
| 653 |
int Param::get_n_itbl() const { |
| 654 |
return n_itbl ; |
| 655 |
} |
| 656 |
|
| 657 |
// Addition |
| 658 |
// -------- |
| 659 |
|
| 660 |
void Param::add_itbl(const Itbl& ti, int index){ |
| 661 |
|
| 662 |
if (index >= n_itbl) { // p_itbl must be rescaled |
| 663 |
|
| 664 |
int n_itbl_nouveau = index + 1 ; |
| 665 |
const Itbl** p_itbl_nouveau = new const Itbl*[n_itbl_nouveau] ; |
| 666 |
|
| 667 |
|
| 668 |
// Copy of the previous addresses |
| 669 |
for (int i=0; i<n_itbl; i++) { |
| 670 |
p_itbl_nouveau[i] = p_itbl[i] ; |
| 671 |
} |
| 672 |
|
| 673 |
// The intermediate addresses are set to 0x0 |
| 674 |
for (int i=n_itbl; i<index; i++) { |
| 675 |
p_itbl_nouveau[i] = 0x0 ; |
| 676 |
} |
| 677 |
|
| 678 |
// The new address |
| 679 |
p_itbl_nouveau[index] = &ti ; |
| 680 |
|
| 681 |
// Update |
| 682 |
if (n_itbl > 0) delete [] p_itbl ; |
| 683 |
p_itbl = p_itbl_nouveau ; |
| 684 |
n_itbl = n_itbl_nouveau ; |
| 685 |
|
| 686 |
} |
| 687 |
else { |
| 688 |
|
| 689 |
if (p_itbl[index] != 0x0) { |
| 690 |
cout << "Param::add_itbl : the position " << index |
| 691 |
<< " is already occupied !" << endl ; |
| 692 |
abort() ; |
| 693 |
} |
| 694 |
else{ |
| 695 |
p_itbl[index] = &ti ; |
| 696 |
} |
| 697 |
|
| 698 |
} |
| 699 |
|
| 700 |
} |
| 701 |
|
| 702 |
// Extraction |
| 703 |
// ---------- |
| 704 |
|
| 705 |
const Itbl& Param::get_itbl(int index) const { |
| 706 |
|
| 707 |
assert(index >= 0) ; |
| 708 |
assert(index < n_itbl) ; |
| 709 |
|
| 710 |
return *(p_itbl[index]) ; |
| 711 |
|
| 712 |
} |
| 713 |
|
| 714 |
|
| 715 |
//------------------------------------// |
| 716 |
// Modifiable Itbl storage // |
| 717 |
//------------------------------------// |
| 718 |
|
| 719 |
// Total number of stored addresses |
| 720 |
// -------------------------------- |
| 721 |
|
| 722 |
int Param::get_n_itbl_mod() const { |
| 723 |
return n_itbl_mod ; |
| 724 |
} |
| 725 |
|
| 726 |
// Addition |
| 727 |
// -------- |
| 728 |
|
| 729 |
void Param::add_itbl_mod(Itbl& ti, int index){ |
| 730 |
|
| 731 |
if (index >= n_itbl_mod) { // p_itbl_mod must be rescaled |
| 732 |
|
| 733 |
int n_itbl_nouveau = index + 1 ; |
| 734 |
Itbl** p_itbl_nouveau = new Itbl*[n_itbl_nouveau] ; |
| 735 |
|
| 736 |
|
| 737 |
// Copy of the previous addresses |
| 738 |
for (int i=0; i<n_itbl_mod; i++) { |
| 739 |
p_itbl_nouveau[i] = p_itbl_mod[i] ; |
| 740 |
} |
| 741 |
|
| 742 |
// The intermediate addresses are set to 0x0 |
| 743 |
for (int i=n_itbl_mod; i<index; i++) { |
| 744 |
p_itbl_nouveau[i] = 0x0 ; |
| 745 |
} |
| 746 |
|
| 747 |
// The new address |
| 748 |
p_itbl_nouveau[index] = &ti ; |
| 749 |
|
| 750 |
// Update |
| 751 |
if (n_itbl_mod > 0) delete [] p_itbl_mod ; |
| 752 |
p_itbl_mod = p_itbl_nouveau ; |
| 753 |
n_itbl_mod = n_itbl_nouveau ; |
| 754 |
|
| 755 |
} |
| 756 |
else { |
| 757 |
|
| 758 |
if (p_itbl_mod[index] != 0x0) { |
| 759 |
cout << "Param::add_itbl_mod : the position " << index |
| 760 |
<< " is already occupied !" << endl ; |
| 761 |
abort() ; |
| 762 |
} |
| 763 |
else{ |
| 764 |
p_itbl_mod[index] = &ti ; |
| 765 |
} |
| 766 |
|
| 767 |
} |
| 768 |
|
| 769 |
} |
| 770 |
|
| 771 |
// Extraction |
| 772 |
// ---------- |
| 773 |
|
| 774 |
Itbl& Param::get_itbl_mod(int index) const { |
| 775 |
|
| 776 |
assert(index >= 0) ; |
| 777 |
assert(index < n_itbl_mod) ; |
| 778 |
|
| 779 |
return *(p_itbl_mod[index]) ; |
| 780 |
|
| 781 |
} |
| 782 |
|
| 783 |
//------------------------------------// |
| 784 |
// Matrice storage // |
| 785 |
//------------------------------------// |
| 786 |
|
| 787 |
// Total number of stored addresses |
| 788 |
// -------------------------------- |
| 789 |
|
| 790 |
int Param::get_n_matrice() const { |
| 791 |
return n_matrice ; |
| 792 |
} |
| 793 |
|
| 794 |
// Addition |
| 795 |
// -------- |
| 796 |
|
| 797 |
void Param::add_matrice(const Matrice& ti, int index){ |
| 798 |
|
| 799 |
if (index >= n_matrice) { // p_matrice must be rescaled |
| 800 |
|
| 801 |
int n_matrice_nouveau = index + 1 ; |
| 802 |
const Matrice** p_matrice_nouveau = new const Matrice*[n_matrice_nouveau] ; |
| 803 |
|
| 804 |
|
| 805 |
// Copy of the previous addresses |
| 806 |
for (int i=0; i<n_matrice; i++) { |
| 807 |
p_matrice_nouveau[i] = p_matrice[i] ; |
| 808 |
} |
| 809 |
|
| 810 |
// The intermediate addresses are set to 0x0 |
| 811 |
for (int i=n_matrice; i<index; i++) { |
| 812 |
p_matrice_nouveau[i] = 0x0 ; |
| 813 |
} |
| 814 |
|
| 815 |
// The new address |
| 816 |
p_matrice_nouveau[index] = &ti ; |
| 817 |
|
| 818 |
// Update |
| 819 |
if (n_matrice > 0) delete [] p_matrice ; |
| 820 |
p_matrice = p_matrice_nouveau ; |
| 821 |
n_matrice = n_matrice_nouveau ; |
| 822 |
|
| 823 |
} |
| 824 |
else { |
| 825 |
|
| 826 |
if (p_matrice[index] != 0x0) { |
| 827 |
cout << "Param::add_matrice : the position " << index |
| 828 |
<< " is already occupied !" << endl ; |
| 829 |
abort() ; |
| 830 |
} |
| 831 |
else{ |
| 832 |
p_matrice[index] = &ti ; |
| 833 |
} |
| 834 |
|
| 835 |
} |
| 836 |
|
| 837 |
} |
| 838 |
|
| 839 |
// Extraction |
| 840 |
// ---------- |
| 841 |
|
| 842 |
const Matrice& Param::get_matrice(int index) const { |
| 843 |
|
| 844 |
assert(index >= 0) ; |
| 845 |
assert(index < n_matrice) ; |
| 846 |
|
| 847 |
return *(p_matrice[index]) ; |
| 848 |
|
| 849 |
} |
| 850 |
|
| 851 |
|
| 852 |
//------------------------------------// |
| 853 |
// Modifiable Matrice storage // |
| 854 |
//------------------------------------// |
| 855 |
|
| 856 |
// Total number of stored addresses |
| 857 |
// -------------------------------- |
| 858 |
|
| 859 |
int Param::get_n_matrice_mod() const { |
| 860 |
return n_matrice_mod ; |
| 861 |
} |
| 862 |
|
| 863 |
// Addition |
| 864 |
// -------- |
| 865 |
|
| 866 |
void Param::add_matrice_mod(Matrice& ti, int index){ |
| 867 |
|
| 868 |
if (index >= n_matrice_mod) { // p_matrice_mod must be rescaled |
| 869 |
|
| 870 |
int n_matrice_nouveau = index + 1 ; |
| 871 |
Matrice** p_matrice_nouveau = new Matrice*[n_matrice_nouveau] ; |
| 872 |
|
| 873 |
|
| 874 |
// Copy of the previous addresses |
| 875 |
for (int i=0; i<n_matrice_mod; i++) { |
| 876 |
p_matrice_nouveau[i] = p_matrice_mod[i] ; |
| 877 |
} |
| 878 |
|
| 879 |
// The intermediate addresses are set to 0x0 |
| 880 |
for (int i=n_matrice_mod; i<index; i++) { |
| 881 |
p_matrice_nouveau[i] = 0x0 ; |
| 882 |
} |
| 883 |
|
| 884 |
// The new address |
| 885 |
p_matrice_nouveau[index] = &ti ; |
| 886 |
|
| 887 |
// Update |
| 888 |
if (n_matrice_mod > 0) delete [] p_matrice_mod ; |
| 889 |
p_matrice_mod = p_matrice_nouveau ; |
| 890 |
n_matrice_mod = n_matrice_nouveau ; |
| 891 |
|
| 892 |
} |
| 893 |
else { |
| 894 |
|
| 895 |
if (p_matrice_mod[index] != 0x0) { |
| 896 |
cout << "Param::add_matrice_mod : the position " << index |
| 897 |
<< " is already occupied !" << endl ; |
| 898 |
abort() ; |
| 899 |
} |
| 900 |
else{ |
| 901 |
p_matrice_mod[index] = &ti ; |
| 902 |
} |
| 903 |
|
| 904 |
} |
| 905 |
|
| 906 |
} |
| 907 |
|
| 908 |
// Extraction |
| 909 |
// ---------- |
| 910 |
|
| 911 |
Matrice& Param::get_matrice_mod(int index) const { |
| 912 |
|
| 913 |
assert(index >= 0) ; |
| 914 |
assert(index < n_matrice_mod) ; |
| 915 |
|
| 916 |
return *(p_matrice_mod[index]) ; |
| 917 |
|
| 918 |
} |
| 919 |
|
| 920 |
|
| 921 |
//------------------------------------// |
| 922 |
// Cmp storage // |
| 923 |
//------------------------------------// |
| 924 |
|
| 925 |
// Total number of stored addresses |
| 926 |
// -------------------------------- |
| 927 |
|
| 928 |
int Param::get_n_cmp() const { |
| 929 |
return n_cmp ; |
| 930 |
} |
| 931 |
|
| 932 |
// Addition |
| 933 |
// -------- |
| 934 |
|
| 935 |
void Param::add_cmp(const Cmp& ti, int index){ |
| 936 |
|
| 937 |
if (index >= n_cmp) { // p_cmp must be rescaled |
| 938 |
|
| 939 |
int n_cmp_nouveau = index + 1 ; |
| 940 |
const Cmp** p_cmp_nouveau = new const Cmp*[n_cmp_nouveau] ; |
| 941 |
|
| 942 |
|
| 943 |
// Copy of the previous addresses |
| 944 |
for (int i=0; i<n_cmp; i++) { |
| 945 |
p_cmp_nouveau[i] = p_cmp[i] ; |
| 946 |
} |
| 947 |
|
| 948 |
// The intermediate addresses are set to 0x0 |
| 949 |
for (int i=n_cmp; i<index; i++) { |
| 950 |
p_cmp_nouveau[i] = 0x0 ; |
| 951 |
} |
| 952 |
|
| 953 |
// The new address |
| 954 |
p_cmp_nouveau[index] = &ti ; |
| 955 |
|
| 956 |
// Update |
| 957 |
if (n_cmp > 0) delete [] p_cmp ; |
| 958 |
p_cmp = p_cmp_nouveau ; |
| 959 |
n_cmp = n_cmp_nouveau ; |
| 960 |
|
| 961 |
} |
| 962 |
else { |
| 963 |
|
| 964 |
if (p_cmp[index] != 0x0) { |
| 965 |
cout << "Param::add_cmp : the position " << index |
| 966 |
<< " is already occupied !" << endl ; |
| 967 |
abort() ; |
| 968 |
} |
| 969 |
else{ |
| 970 |
p_cmp[index] = &ti ; |
| 971 |
} |
| 972 |
|
| 973 |
} |
| 974 |
|
| 975 |
} |
| 976 |
|
| 977 |
// Extraction |
| 978 |
// ---------- |
| 979 |
|
| 980 |
const Cmp& Param::get_cmp(int index) const { |
| 981 |
|
| 982 |
assert(index >= 0) ; |
| 983 |
assert(index < n_cmp) ; |
| 984 |
|
| 985 |
return *(p_cmp[index]) ; |
| 986 |
|
| 987 |
} |
| 988 |
|
| 989 |
|
| 990 |
//------------------------------------// |
| 991 |
// Modifiable Cmp storage // |
| 992 |
//------------------------------------// |
| 993 |
|
| 994 |
// Total number of stored addresses |
| 995 |
// -------------------------------- |
| 996 |
|
| 997 |
int Param::get_n_cmp_mod() const { |
| 998 |
return n_cmp_mod ; |
| 999 |
} |
| 1000 |
|
| 1001 |
// Addition |
| 1002 |
// -------- |
| 1003 |
|
| 1004 |
void Param::add_cmp_mod(Cmp& ti, int index){ |
| 1005 |
|
| 1006 |
if (index >= n_cmp_mod) { // p_cmp_mod must be rescaled |
| 1007 |
|
| 1008 |
int n_cmp_nouveau = index + 1 ; |
| 1009 |
Cmp** p_cmp_nouveau = new Cmp*[n_cmp_nouveau] ; |
| 1010 |
|
| 1011 |
|
| 1012 |
// Copy of the previous addresses |
| 1013 |
for (int i=0; i<n_cmp_mod; i++) { |
| 1014 |
p_cmp_nouveau[i] = p_cmp_mod[i] ; |
| 1015 |
} |
| 1016 |
|
| 1017 |
// The intermediate addresses are set to 0x0 |
| 1018 |
for (int i=n_cmp_mod; i<index; i++) { |
| 1019 |
p_cmp_nouveau[i] = 0x0 ; |
| 1020 |
} |
| 1021 |
|
| 1022 |
// The new address |
| 1023 |
p_cmp_nouveau[index] = &ti ; |
| 1024 |
|
| 1025 |
// Update |
| 1026 |
if (n_cmp_mod > 0) delete [] p_cmp_mod ; |
| 1027 |
p_cmp_mod = p_cmp_nouveau ; |
| 1028 |
n_cmp_mod = n_cmp_nouveau ; |
| 1029 |
|
| 1030 |
} |
| 1031 |
else { |
| 1032 |
|
| 1033 |
if (p_cmp_mod[index] != 0x0) { |
| 1034 |
cout << "Param::add_cmp_mod : the position " << index |
| 1035 |
<< " is already occupied !" << endl ; |
| 1036 |
abort() ; |
| 1037 |
} |
| 1038 |
else{ |
| 1039 |
p_cmp_mod[index] = &ti ; |
| 1040 |
} |
| 1041 |
|
| 1042 |
} |
| 1043 |
|
| 1044 |
} |
| 1045 |
|
| 1046 |
// Extraction |
| 1047 |
// ---------- |
| 1048 |
|
| 1049 |
Cmp& Param::get_cmp_mod(int index) const { |
| 1050 |
|
| 1051 |
assert(index >= 0) ; |
| 1052 |
assert(index < n_cmp_mod) ; |
| 1053 |
|
| 1054 |
return *(p_cmp_mod[index]) ; |
| 1055 |
|
| 1056 |
} |
| 1057 |
|
| 1058 |
|
| 1059 |
//------------------------------------// |
| 1060 |
// Tenseur storage // |
| 1061 |
//------------------------------------// |
| 1062 |
|
| 1063 |
// Total number of stored addresses |
| 1064 |
// -------------------------------- |
| 1065 |
|
| 1066 |
int Param::get_n_tenseur() const { |
| 1067 |
return n_tenseur ; |
| 1068 |
} |
| 1069 |
|
| 1070 |
// Addition |
| 1071 |
// -------- |
| 1072 |
|
| 1073 |
void Param::add_tenseur(const Tenseur& ti, int index){ |
| 1074 |
|
| 1075 |
if (index >= n_tenseur) { // p_tenseur must be rescaled |
| 1076 |
|
| 1077 |
int n_tenseur_nouveau = index + 1 ; |
| 1078 |
const Tenseur** p_tenseur_nouveau = new const Tenseur*[n_tenseur_nouveau] ; |
| 1079 |
|
| 1080 |
|
| 1081 |
// Copy of the previous addresses |
| 1082 |
for (int i=0; i<n_tenseur; i++) { |
| 1083 |
p_tenseur_nouveau[i] = p_tenseur[i] ; |
| 1084 |
} |
| 1085 |
|
| 1086 |
// The intermediate addresses are set to 0x0 |
| 1087 |
for (int i=n_tenseur; i<index; i++) { |
| 1088 |
p_tenseur_nouveau[i] = 0x0 ; |
| 1089 |
} |
| 1090 |
|
| 1091 |
// The new address |
| 1092 |
p_tenseur_nouveau[index] = &ti ; |
| 1093 |
|
| 1094 |
// Update |
| 1095 |
if (n_tenseur > 0) delete [] p_tenseur ; |
| 1096 |
p_tenseur = p_tenseur_nouveau ; |
| 1097 |
n_tenseur = n_tenseur_nouveau ; |
| 1098 |
|
| 1099 |
} |
| 1100 |
else { |
| 1101 |
|
| 1102 |
if (p_tenseur[index] != 0x0) { |
| 1103 |
cout << "Param::add_tenseur : the position " << index |
| 1104 |
<< " is already occupied !" << endl ; |
| 1105 |
abort() ; |
| 1106 |
} |
| 1107 |
else{ |
| 1108 |
p_tenseur[index] = &ti ; |
| 1109 |
} |
| 1110 |
|
| 1111 |
} |
| 1112 |
|
| 1113 |
} |
| 1114 |
|
| 1115 |
// Extraction |
| 1116 |
// ---------- |
| 1117 |
|
| 1118 |
const Tenseur& Param::get_tenseur(int index) const { |
| 1119 |
|
| 1120 |
assert(index >= 0) ; |
| 1121 |
assert(index < n_tenseur) ; |
| 1122 |
|
| 1123 |
return *(p_tenseur[index]) ; |
| 1124 |
|
| 1125 |
} |
| 1126 |
|
| 1127 |
|
| 1128 |
//------------------------------------// |
| 1129 |
// Modifiable Tenseur storage // |
| 1130 |
//------------------------------------// |
| 1131 |
|
| 1132 |
// Total number of stored addresses |
| 1133 |
// -------------------------------- |
| 1134 |
|
| 1135 |
int Param::get_n_tenseur_mod() const { |
| 1136 |
return n_tenseur_mod ; |
| 1137 |
} |
| 1138 |
|
| 1139 |
// Addition |
| 1140 |
// -------- |
| 1141 |
|
| 1142 |
void Param::add_tenseur_mod(Tenseur& ti, int index){ |
| 1143 |
|
| 1144 |
if (index >= n_tenseur_mod) { // p_tenseur_mod must be rescaled |
| 1145 |
|
| 1146 |
int n_tenseur_nouveau = index + 1 ; |
| 1147 |
Tenseur** p_tenseur_nouveau = new Tenseur*[n_tenseur_nouveau] ; |
| 1148 |
|
| 1149 |
|
| 1150 |
// Copy of the previous addresses |
| 1151 |
for (int i=0; i<n_tenseur_mod; i++) { |
| 1152 |
p_tenseur_nouveau[i] = p_tenseur_mod[i] ; |
| 1153 |
} |
| 1154 |
|
| 1155 |
// The intermediate addresses are set to 0x0 |
| 1156 |
for (int i=n_tenseur_mod; i<index; i++) { |
| 1157 |
p_tenseur_nouveau[i] = 0x0 ; |
| 1158 |
} |
| 1159 |
|
| 1160 |
// The new address |
| 1161 |
p_tenseur_nouveau[index] = &ti ; |
| 1162 |
|
| 1163 |
// Update |
| 1164 |
if (n_tenseur_mod > 0) delete [] p_tenseur_mod ; |
| 1165 |
p_tenseur_mod = p_tenseur_nouveau ; |
| 1166 |
n_tenseur_mod = n_tenseur_nouveau ; |
| 1167 |
|
| 1168 |
} |
| 1169 |
else { |
| 1170 |
|
| 1171 |
if (p_tenseur_mod[index] != 0x0) { |
| 1172 |
cout << "Param::add_tenseur_mod : the position " << index |
| 1173 |
<< " is already occupied !" << endl ; |
| 1174 |
abort() ; |
| 1175 |
} |
| 1176 |
else{ |
| 1177 |
p_tenseur_mod[index] = &ti ; |
| 1178 |
} |
| 1179 |
|
| 1180 |
} |
| 1181 |
|
| 1182 |
} |
| 1183 |
|
| 1184 |
// Extraction |
| 1185 |
// ---------- |
| 1186 |
|
| 1187 |
Tenseur& Param::get_tenseur_mod(int index) const { |
| 1188 |
|
| 1189 |
assert(index >= 0) ; |
| 1190 |
assert(index < n_tenseur_mod) ; |
| 1191 |
|
| 1192 |
return *(p_tenseur_mod[index]) ; |
| 1193 |
|
| 1194 |
} |
| 1195 |
|
| 1196 |
|
| 1197 |
//------------------------------------// |
| 1198 |
// Map storage // |
| 1199 |
//------------------------------------// |
| 1200 |
|
| 1201 |
// Total number of stored addresses |
| 1202 |
// -------------------------------- |
| 1203 |
|
| 1204 |
int Param::get_n_map() const { |
| 1205 |
return n_map ; |
| 1206 |
} |
| 1207 |
|
| 1208 |
// Addition |
| 1209 |
// -------- |
| 1210 |
|
| 1211 |
void Param::add_map(const Map& mi, int index){ |
| 1212 |
|
| 1213 |
if (index >= n_map) { // p_map must be rescaled |
| 1214 |
|
| 1215 |
int n_map_nouveau = index + 1 ; |
| 1216 |
const Map** p_map_nouveau = new const Map*[n_map_nouveau] ; |
| 1217 |
|
| 1218 |
|
| 1219 |
// Copy of the previous addresses |
| 1220 |
for (int i=0; i<n_map; i++) { |
| 1221 |
p_map_nouveau[i] = p_map[i] ; |
| 1222 |
} |
| 1223 |
|
| 1224 |
// The intermediate addresses are set to 0x0 |
| 1225 |
for (int i=n_map; i<index; i++) { |
| 1226 |
p_map_nouveau[i] = 0x0 ; |
| 1227 |
} |
| 1228 |
|
| 1229 |
// The new address |
| 1230 |
p_map_nouveau[index] = &mi ; |
| 1231 |
|
| 1232 |
// Update |
| 1233 |
if (n_map > 0) delete [] p_map ; |
| 1234 |
p_map = p_map_nouveau ; |
| 1235 |
n_map = n_map_nouveau ; |
| 1236 |
|
| 1237 |
} |
| 1238 |
else { |
| 1239 |
|
| 1240 |
if (p_map[index] != 0x0) { |
| 1241 |
cout << "Param::add_map : the position " << index |
| 1242 |
<< " is already occupied !" << endl ; |
| 1243 |
abort() ; |
| 1244 |
} |
| 1245 |
else{ |
| 1246 |
p_map[index] = &mi ; |
| 1247 |
} |
| 1248 |
|
| 1249 |
} |
| 1250 |
|
| 1251 |
} |
| 1252 |
|
| 1253 |
// Extraction |
| 1254 |
// ---------- |
| 1255 |
|
| 1256 |
const Map& Param::get_map(int index) const { |
| 1257 |
|
| 1258 |
assert(index >= 0) ; |
| 1259 |
assert(index < n_map) ; |
| 1260 |
|
| 1261 |
return *(p_map[index]) ; |
| 1262 |
|
| 1263 |
} |
| 1264 |
|
| 1265 |
//------------------------------------// |
| 1266 |
// Mtbl_cf storage // |
| 1267 |
//------------------------------------// |
| 1268 |
|
| 1269 |
// Total number of stored addresses |
| 1270 |
// -------------------------------- |
| 1271 |
|
| 1272 |
int Param::get_n_mtbl_cf() const { |
| 1273 |
return n_mtbl_cf ; |
| 1274 |
} |
| 1275 |
|
| 1276 |
// Addition |
| 1277 |
// -------- |
| 1278 |
|
| 1279 |
void Param::add_mtbl_cf(const Mtbl_cf& mi, int index){ |
| 1280 |
|
| 1281 |
if (index >= n_mtbl_cf) { // p_mtbl_cf must be rescaled |
| 1282 |
|
| 1283 |
int n_mtbl_cf_nouveau = index + 1 ; |
| 1284 |
const Mtbl_cf** p_mtbl_cf_nouveau = |
| 1285 |
new const Mtbl_cf*[n_mtbl_cf_nouveau] ; |
| 1286 |
|
| 1287 |
|
| 1288 |
// Copy of the previous addresses |
| 1289 |
for (int i=0; i<n_mtbl_cf; i++) { |
| 1290 |
p_mtbl_cf_nouveau[i] = p_mtbl_cf[i] ; |
| 1291 |
} |
| 1292 |
|
| 1293 |
// The intermediate addresses are set to 0x0 |
| 1294 |
for (int i=n_mtbl_cf; i<index; i++) { |
| 1295 |
p_mtbl_cf_nouveau[i] = 0x0 ; |
| 1296 |
} |
| 1297 |
|
| 1298 |
// The new address |
| 1299 |
p_mtbl_cf_nouveau[index] = &mi ; |
| 1300 |
|
| 1301 |
// Update |
| 1302 |
if (n_mtbl_cf > 0) delete [] p_mtbl_cf ; |
| 1303 |
p_mtbl_cf = p_mtbl_cf_nouveau ; |
| 1304 |
n_mtbl_cf = n_mtbl_cf_nouveau ; |
| 1305 |
|
| 1306 |
} |
| 1307 |
else { |
| 1308 |
|
| 1309 |
if (p_mtbl_cf[index] != 0x0) { |
| 1310 |
cout << "Param::add_mtbl_cf : the position " << index |
| 1311 |
<< " is already occupied !" << endl ; |
| 1312 |
abort() ; |
| 1313 |
} |
| 1314 |
else{ |
| 1315 |
p_mtbl_cf[index] = &mi ; |
| 1316 |
} |
| 1317 |
|
| 1318 |
} |
| 1319 |
|
| 1320 |
} |
| 1321 |
|
| 1322 |
// Extraction |
| 1323 |
// ---------- |
| 1324 |
|
| 1325 |
const Mtbl_cf& Param::get_mtbl_cf(int index) const { |
| 1326 |
|
| 1327 |
assert(index >= 0) ; |
| 1328 |
assert(index < n_mtbl_cf) ; |
| 1329 |
|
| 1330 |
return *(p_mtbl_cf[index]) ; |
| 1331 |
|
| 1332 |
} |
| 1333 |
|
| 1334 |
//------------------------------------// |
| 1335 |
// Scalar storage // |
| 1336 |
//------------------------------------// |
| 1337 |
|
| 1338 |
// Total number of stored addresses |
| 1339 |
// -------------------------------- |
| 1340 |
|
| 1341 |
int Param::get_n_scalar() const { |
| 1342 |
return n_scalar ; |
| 1343 |
} |
| 1344 |
|
| 1345 |
// Addition |
| 1346 |
// -------- |
| 1347 |
|
| 1348 |
void Param::add_scalar(const Scalar& ti, int index){ |
| 1349 |
|
| 1350 |
if (index >= n_scalar) { // p_scalar must be rescaled |
| 1351 |
|
| 1352 |
int n_scalar_nouveau = index + 1 ; |
| 1353 |
const Scalar** p_scalar_nouveau = new const Scalar*[n_scalar_nouveau] ; |
| 1354 |
|
| 1355 |
|
| 1356 |
// Copy of the previous addresses |
| 1357 |
for (int i=0; i<n_scalar; i++) { |
| 1358 |
p_scalar_nouveau[i] = p_scalar[i] ; |
| 1359 |
} |
| 1360 |
|
| 1361 |
// The intermediate addresses are set to 0x0 |
| 1362 |
for (int i=n_scalar; i<index; i++) { |
| 1363 |
p_scalar_nouveau[i] = 0x0 ; |
| 1364 |
} |
| 1365 |
|
| 1366 |
// The new address |
| 1367 |
p_scalar_nouveau[index] = &ti ; |
| 1368 |
|
| 1369 |
// Update |
| 1370 |
if (n_scalar > 0) delete [] p_scalar ; |
| 1371 |
p_scalar = p_scalar_nouveau ; |
| 1372 |
n_scalar = n_scalar_nouveau ; |
| 1373 |
|
| 1374 |
} |
| 1375 |
else { |
| 1376 |
|
| 1377 |
if (p_scalar[index] != 0x0) { |
| 1378 |
cout << "Param::add_scalar : the position " << index |
| 1379 |
<< " is already occupied !" << endl ; |
| 1380 |
abort() ; |
| 1381 |
} |
| 1382 |
else{ |
| 1383 |
p_scalar[index] = &ti ; |
| 1384 |
} |
| 1385 |
|
| 1386 |
} |
| 1387 |
|
| 1388 |
} |
| 1389 |
|
| 1390 |
// Extraction |
| 1391 |
// ---------- |
| 1392 |
|
| 1393 |
const Scalar& Param::get_scalar(int index) const { |
| 1394 |
|
| 1395 |
assert(index >= 0) ; |
| 1396 |
assert(index < n_scalar) ; |
| 1397 |
|
| 1398 |
return *(p_scalar[index]) ; |
| 1399 |
|
| 1400 |
} |
| 1401 |
|
| 1402 |
|
| 1403 |
//------------------------------------// |
| 1404 |
// Modifiable Scalar storage // |
| 1405 |
//------------------------------------// |
| 1406 |
|
| 1407 |
// Total number of stored addresses |
| 1408 |
// -------------------------------- |
| 1409 |
|
| 1410 |
int Param::get_n_scalar_mod() const { |
| 1411 |
return n_scalar_mod ; |
| 1412 |
} |
| 1413 |
|
| 1414 |
// Addition |
| 1415 |
// -------- |
| 1416 |
|
| 1417 |
void Param::add_scalar_mod(Scalar& ti, int index){ |
| 1418 |
|
| 1419 |
if (index >= n_scalar_mod) { // p_scalar_mod must be rescaled |
| 1420 |
|
| 1421 |
int n_scalar_nouveau = index + 1 ; |
| 1422 |
Scalar** p_scalar_nouveau = new Scalar*[n_scalar_nouveau] ; |
| 1423 |
|
| 1424 |
|
| 1425 |
// Copy of the previous addresses |
| 1426 |
for (int i=0; i<n_scalar_mod; i++) { |
| 1427 |
p_scalar_nouveau[i] = p_scalar_mod[i] ; |
| 1428 |
} |
| 1429 |
|
| 1430 |
// The intermediate addresses are set to 0x0 |
| 1431 |
for (int i=n_scalar_mod; i<index; i++) { |
| 1432 |
p_scalar_nouveau[i] = 0x0 ; |
| 1433 |
} |
| 1434 |
|
| 1435 |
// The new address |
| 1436 |
p_scalar_nouveau[index] = &ti ; |
| 1437 |
|
| 1438 |
// Update |
| 1439 |
if (n_scalar_mod > 0) delete [] p_scalar_mod ; |
| 1440 |
p_scalar_mod = p_scalar_nouveau ; |
| 1441 |
n_scalar_mod = n_scalar_nouveau ; |
| 1442 |
|
| 1443 |
} |
| 1444 |
else { |
| 1445 |
|
| 1446 |
if (p_scalar_mod[index] != 0x0) { |
| 1447 |
cout << "Param::add_scalar_mod : the position " << index |
| 1448 |
<< " is already occupied !" << endl ; |
| 1449 |
abort() ; |
| 1450 |
} |
| 1451 |
else{ |
| 1452 |
p_scalar_mod[index] = &ti ; |
| 1453 |
} |
| 1454 |
|
| 1455 |
} |
| 1456 |
|
| 1457 |
} |
| 1458 |
|
| 1459 |
// Extraction |
| 1460 |
// ---------- |
| 1461 |
|
| 1462 |
Scalar& Param::get_scalar_mod(int index) const { |
| 1463 |
|
| 1464 |
assert(index >= 0) ; |
| 1465 |
assert(index < n_scalar_mod) ; |
| 1466 |
|
| 1467 |
return *(p_scalar_mod[index]) ; |
| 1468 |
|
| 1469 |
} |
| 1470 |
|
| 1471 |
|
| 1472 |
//------------------------------------// |
| 1473 |
// Tensor storage // |
| 1474 |
//------------------------------------// |
| 1475 |
|
| 1476 |
// Total number of stored addresses |
| 1477 |
// -------------------------------- |
| 1478 |
|
| 1479 |
int Param::get_n_tensor() const { |
| 1480 |
return n_tensor ; |
| 1481 |
} |
| 1482 |
|
| 1483 |
// Addition |
| 1484 |
// -------- |
| 1485 |
|
| 1486 |
void Param::add_tensor(const Tensor& ti, int index){ |
| 1487 |
|
| 1488 |
if (index >= n_tensor) { // p_tensor must be rescaled |
| 1489 |
|
| 1490 |
int n_tensor_nouveau = index + 1 ; |
| 1491 |
const Tensor** p_tensor_nouveau = new const Tensor*[n_tensor_nouveau] ; |
| 1492 |
|
| 1493 |
|
| 1494 |
// Copy of the previous addresses |
| 1495 |
for (int i=0; i<n_tensor; i++) { |
| 1496 |
p_tensor_nouveau[i] = p_tensor[i] ; |
| 1497 |
} |
| 1498 |
|
| 1499 |
// The intermediate addresses are set to 0x0 |
| 1500 |
for (int i=n_tensor; i<index; i++) { |
| 1501 |
p_tensor_nouveau[i] = 0x0 ; |
| 1502 |
} |
| 1503 |
|
| 1504 |
// The new address |
| 1505 |
p_tensor_nouveau[index] = &ti ; |
| 1506 |
|
| 1507 |
// Update |
| 1508 |
if (n_tensor > 0) delete [] p_tensor ; |
| 1509 |
p_tensor = p_tensor_nouveau ; |
| 1510 |
n_tensor = n_tensor_nouveau ; |
| 1511 |
|
| 1512 |
} |
| 1513 |
else { |
| 1514 |
|
| 1515 |
if (p_tensor[index] != 0x0) { |
| 1516 |
cout << "Param::add_tensor : the position " << index |
| 1517 |
<< " is already occupied !" << endl ; |
| 1518 |
abort() ; |
| 1519 |
} |
| 1520 |
else{ |
| 1521 |
p_tensor[index] = &ti ; |
| 1522 |
} |
| 1523 |
|
| 1524 |
} |
| 1525 |
|
| 1526 |
} |
| 1527 |
|
| 1528 |
// Extraction |
| 1529 |
// ---------- |
| 1530 |
|
| 1531 |
const Tensor& Param::get_tensor(int index) const { |
| 1532 |
|
| 1533 |
assert(index >= 0) ; |
| 1534 |
assert(index < n_tensor) ; |
| 1535 |
|
| 1536 |
return *(p_tensor[index]) ; |
| 1537 |
|
| 1538 |
} |
| 1539 |
|
| 1540 |
|
| 1541 |
//------------------------------------// |
| 1542 |
// Modifiable Tensor storage // |
| 1543 |
//------------------------------------// |
| 1544 |
|
| 1545 |
// Total number of stored addresses |
| 1546 |
// -------------------------------- |
| 1547 |
|
| 1548 |
int Param::get_n_tensor_mod() const { |
| 1549 |
return n_tensor_mod ; |
| 1550 |
} |
| 1551 |
|
| 1552 |
// Addition |
| 1553 |
// -------- |
| 1554 |
|
| 1555 |
void Param::add_tensor_mod(Tensor& ti, int index){ |
| 1556 |
|
| 1557 |
if (index >= n_tensor_mod) { // p_tensor_mod must be rescaled |
| 1558 |
|
| 1559 |
int n_tensor_nouveau = index + 1 ; |
| 1560 |
Tensor** p_tensor_nouveau = new Tensor*[n_tensor_nouveau] ; |
| 1561 |
|
| 1562 |
|
| 1563 |
// Copy of the previous addresses |
| 1564 |
for (int i=0; i<n_tensor_mod; i++) { |
| 1565 |
p_tensor_nouveau[i] = p_tensor_mod[i] ; |
| 1566 |
} |
| 1567 |
|
| 1568 |
// The intermediate addresses are set to 0x0 |
| 1569 |
for (int i=n_tensor_mod; i<index; i++) { |
| 1570 |
p_tensor_nouveau[i] = 0x0 ; |
| 1571 |
} |
| 1572 |
|
| 1573 |
// The new address |
| 1574 |
p_tensor_nouveau[index] = &ti ; |
| 1575 |
|
| 1576 |
// Update |
| 1577 |
if (n_tensor_mod > 0) delete [] p_tensor_mod ; |
| 1578 |
p_tensor_mod = p_tensor_nouveau ; |
| 1579 |
n_tensor_mod = n_tensor_nouveau ; |
| 1580 |
|
| 1581 |
} |
| 1582 |
else { |
| 1583 |
|
| 1584 |
if (p_tensor_mod[index] != 0x0) { |
| 1585 |
cout << "Param::add_tensor_mod : the position " << index |
| 1586 |
<< " is already occupied !" << endl ; |
| 1587 |
abort() ; |
| 1588 |
} |
| 1589 |
else{ |
| 1590 |
p_tensor_mod[index] = &ti ; |
| 1591 |
} |
| 1592 |
|
| 1593 |
} |
| 1594 |
|
| 1595 |
} |
| 1596 |
|
| 1597 |
// Extraction |
| 1598 |
// ---------- |
| 1599 |
|
| 1600 |
Tensor& Param::get_tensor_mod(int index) const { |
| 1601 |
|
| 1602 |
assert(index >= 0) ; |
| 1603 |
assert(index < n_tensor_mod) ; |
| 1604 |
|
| 1605 |
return *(p_tensor_mod[index]) ; |
| 1606 |
|
| 1607 |
} |
| 1608 |
|
| 1609 |
|
| 1610 |
//------------------------------------// |
| 1611 |
// Etoile storage // |
| 1612 |
//------------------------------------// |
| 1613 |
|
| 1614 |
// Total number of stored addresses |
| 1615 |
// -------------------------------- |
| 1616 |
|
| 1617 |
int Param::get_n_etoile() const { |
| 1618 |
return n_etoile ; |
| 1619 |
} |
| 1620 |
|
| 1621 |
// Addition |
| 1622 |
// -------- |
| 1623 |
|
| 1624 |
void Param::add_etoile(const Etoile& eti, int index){ |
| 1625 |
|
| 1626 |
if (index >= n_etoile) { // p_etoile must be rescaled |
| 1627 |
|
| 1628 |
int n_etoile_nouveau = index + 1 ; |
| 1629 |
const Etoile** p_etoile_nouveau = new const Etoile*[n_etoile_nouveau] ; |
| 1630 |
|
| 1631 |
|
| 1632 |
// Copy of the previous addresses |
| 1633 |
for (int i=0; i<n_etoile; i++) { |
| 1634 |
p_etoile_nouveau[i] = p_etoile[i] ; |
| 1635 |
} |
| 1636 |
|
| 1637 |
// The intermediate addresses are set to 0x0 |
| 1638 |
for (int i=n_etoile; i<index; i++) { |
| 1639 |
p_etoile_nouveau[i] = 0x0 ; |
| 1640 |
} |
| 1641 |
|
| 1642 |
// The new address |
| 1643 |
p_etoile_nouveau[index] = &eti ; |
| 1644 |
|
| 1645 |
// Update |
| 1646 |
if (n_etoile > 0) delete [] p_etoile ; |
| 1647 |
p_etoile = p_etoile_nouveau ; |
| 1648 |
n_etoile = n_etoile_nouveau ; |
| 1649 |
|
| 1650 |
} |
| 1651 |
else { |
| 1652 |
|
| 1653 |
if (p_etoile[index] != 0x0) { |
| 1654 |
cout << "Param::add_etoile : the position " << index |
| 1655 |
<< " is already occupied !" << endl ; |
| 1656 |
abort() ; |
| 1657 |
} |
| 1658 |
else{ |
| 1659 |
p_etoile[index] = &eti ; |
| 1660 |
} |
| 1661 |
|
| 1662 |
} |
| 1663 |
|
| 1664 |
} |
| 1665 |
|
| 1666 |
// Extraction |
| 1667 |
// ---------- |
| 1668 |
|
| 1669 |
const Etoile& Param::get_etoile(int index) const { |
| 1670 |
|
| 1671 |
assert(index >= 0) ; |
| 1672 |
assert(index < n_etoile) ; |
| 1673 |
|
| 1674 |
return *(p_etoile[index]) ; |
| 1675 |
} |
| 1676 |
//------------------------------------// |
| 1677 |
// Star storage // |
| 1678 |
//------------------------------------// |
| 1679 |
|
| 1680 |
// Total number of stored addresses |
| 1681 |
// -------------------------------- |
| 1682 |
|
| 1683 |
int Param::get_n_star() const { |
| 1684 |
return n_star ; |
| 1685 |
} |
| 1686 |
|
| 1687 |
// Addition |
| 1688 |
// -------- |
| 1689 |
|
| 1690 |
void Param::add_star(const Star& eti, int index){ |
| 1691 |
|
| 1692 |
if (index >= n_star) { // p_star must be rescaled |
| 1693 |
|
| 1694 |
int n_star_nouveau = index + 1 ; |
| 1695 |
const Star** p_star_nouveau = new const Star*[n_star_nouveau] ; |
| 1696 |
|
| 1697 |
|
| 1698 |
// Copy of the previous addresses |
| 1699 |
for (int i=0; i<n_star; i++) { |
| 1700 |
p_star_nouveau[i] = p_star[i] ; |
| 1701 |
} |
| 1702 |
|
| 1703 |
// The intermediate addresses are set to 0x0 |
| 1704 |
for (int i=n_star; i<index; i++) { |
| 1705 |
p_star_nouveau[i] = 0x0 ; |
| 1706 |
} |
| 1707 |
|
| 1708 |
// The new address |
| 1709 |
p_star_nouveau[index] = &eti ; |
| 1710 |
|
| 1711 |
// Update |
| 1712 |
if (n_star > 0) delete [] p_star ; |
| 1713 |
p_star = p_star_nouveau ; |
| 1714 |
n_star = n_star_nouveau ; |
| 1715 |
|
| 1716 |
} |
| 1717 |
else { |
| 1718 |
|
| 1719 |
if (p_star[index] != 0x0) { |
| 1720 |
cout << "Param::add_star : the position " << index |
| 1721 |
<< " is already occupied !" << endl ; |
| 1722 |
abort() ; |
| 1723 |
} |
| 1724 |
else{ |
| 1725 |
p_star[index] = &eti ; |
| 1726 |
} |
| 1727 |
|
| 1728 |
} |
| 1729 |
|
| 1730 |
} |
| 1731 |
|
| 1732 |
// Extraction |
| 1733 |
// ---------- |
| 1734 |
|
| 1735 |
const Star& Param::get_star(int index) const { |
| 1736 |
|
| 1737 |
assert(index >= 0) ; |
| 1738 |
assert(index < n_star) ; |
| 1739 |
|
| 1740 |
return *(p_star[index]) ; |
| 1741 |
|
| 1742 |
|
| 1743 |
} |
| 1744 |
} |