![]() ![]() | ![]() |
Passage de la branche 4.1 en branche stable.
1: /* 2: ================================================================================ 3: RPL/2 (R) version 4.1.0 4: Copyright (C) 1989-2011 Dr. BERTRAND Joël 5: 6: This file is part of RPL/2. 7: 8: RPL/2 is free software; you can redistribute it and/or modify it 9: under the terms of the CeCILL V2 License as published by the french 10: CEA, CNRS and INRIA. 11: 12: RPL/2 is distributed in the hope that it will be useful, but WITHOUT 13: ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14: FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL V2 License 15: for more details. 16: 17: You should have received a copy of the CeCILL License 18: along with RPL/2. If not, write to info@cecill.info. 19: ================================================================================ 20: */ 21: 22: 23: #include "rpl-conv.h" 24: 25: 26: /* 27: ================================================================================ 28: Fonction 's+' 29: ================================================================================ 30: Entrées : structure processus 31: -------------------------------------------------------------------------------- 32: Sorties : 33: -------------------------------------------------------------------------------- 34: Effets de bord : néant 35: ================================================================================ 36: */ 37: 38: void 39: instruction_s_plus(struct_processus *s_etat_processus) 40: { 41: logical1 creation_variable_sigma; 42: 43: struct_objet *s_copie; 44: struct_objet *s_copie_statistique; 45: struct_objet *s_objet; 46: struct_objet *s_objet_statistique; 47: 48: struct_variable s_variable; 49: 50: unsigned long i; 51: unsigned long j; 52: unsigned long k; 53: unsigned long nombre_colonnes; 54: unsigned long nombre_lignes; 55: 56: void *tampon; 57: 58: (*s_etat_processus).erreur_execution = d_ex; 59: 60: if ((*s_etat_processus).affichage_arguments == 'Y') 61: { 62: printf("\n S+ "); 63: 64: if ((*s_etat_processus).langue == 'F') 65: { 66: printf("(ajout d'une donnée dans la matrice statistique)\n\n"); 67: } 68: else 69: { 70: printf("(add a data value in statistical matrix)\n\n"); 71: } 72: 73: printf(" 1: %s, %s, %s, %s, %s, %s\n", d_INT, d_REL, d_VIN, d_VRL, 74: d_MIN, d_MRL); 75: 76: return; 77: } 78: else if ((*s_etat_processus).test_instruction == 'Y') 79: { 80: (*s_etat_processus).nombre_arguments = -1; 81: return; 82: } 83: 84: if (test_cfsf(s_etat_processus, 31) == d_vrai) 85: { 86: if (empilement_pile_last(s_etat_processus, 1) == d_erreur) 87: { 88: return; 89: } 90: } 91: 92: /* 93: * Recherche d'une variable globale référencée par SIGMA 94: */ 95: 96: if (recherche_variable_globale(s_etat_processus, ds_sdat) == d_faux) 97: { 98: /* 99: * Aucune variable SIGMA, donc il faut la créer en fonction 100: * de l'objet à introduire. 101: */ 102: 103: (*s_etat_processus).erreur_systeme = d_es; 104: creation_variable_sigma = d_vrai; 105: nombre_colonnes = 0; 106: } 107: else 108: { 109: creation_variable_sigma = d_faux; 110: 111: if ((*(*s_etat_processus).pointeur_variable_courante) 112: .variable_verrouillee == d_vrai) 113: { 114: (*s_etat_processus).erreur_execution = 115: d_ex_variable_verrouillee; 116: return; 117: } 118: 119: if (((*(*(*s_etat_processus).pointeur_variable_courante).objet) 120: .type != MIN) && ((*(*(*s_etat_processus) 121: .pointeur_variable_courante).objet).type != MRL)) 122: { 123: (*s_etat_processus).erreur_execution = 124: d_ex_matrice_statistique_invalide; 125: return; 126: } 127: 128: if ((s_copie_statistique = copie_objet(s_etat_processus, 129: (*(*s_etat_processus).pointeur_variable_courante).objet, 'Q')) 130: == NULL) 131: { 132: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; 133: return; 134: } 135: 136: liberation(s_etat_processus, (*(*s_etat_processus) 137: .pointeur_variable_courante).objet); 138: (*(*s_etat_processus).pointeur_variable_courante).objet = 139: s_copie_statistique; 140: 141: nombre_colonnes = (*((struct_matrice *) (*(*(*s_etat_processus) 142: .pointeur_variable_courante).objet).objet)).nombre_colonnes; 143: } 144: 145: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile), 146: &s_objet) == d_erreur) 147: { 148: (*s_etat_processus).erreur_execution = d_ex_manque_argument; 149: return; 150: } 151: 152: if ((s_copie = copie_objet(s_etat_processus, s_objet, 'O')) == NULL) 153: { 154: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; 155: return; 156: } 157: 158: liberation(s_etat_processus, s_objet); 159: s_objet = s_copie; 160: 161: /* 162: * Ajout d'un scalaire 163: */ 164: 165: if (((*s_objet).type == INT) || 166: ((*s_objet).type == REL)) 167: { 168: if (creation_variable_sigma == d_vrai) 169: { 170: /* 171: * Création d'une matrice statistique 1*1 172: */ 173: 174: if ((s_variable.nom = malloc(6 * sizeof(unsigned char))) == NULL) 175: { 176: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; 177: return; 178: } 179: 180: strcpy(s_variable.nom, ds_sdat); 181: s_variable.niveau = 1; 182: 183: if ((*s_objet).type == INT) 184: { 185: if ((s_objet_statistique = allocation(s_etat_processus, MIN)) 186: == NULL) 187: { 188: (*s_etat_processus).erreur_systeme = 189: d_es_allocation_memoire; 190: return; 191: } 192: 193: if (((*((struct_matrice *) (*s_objet_statistique).objet)) 194: .tableau = malloc(sizeof(integer8 *))) == NULL) 195: { 196: (*s_etat_processus).erreur_systeme = 197: d_es_allocation_memoire; 198: return; 199: } 200: 201: ((integer8 **) (*((struct_matrice *) (*s_objet_statistique) 202: .objet)).tableau)[0] = (integer8 *) (*s_objet).objet; 203: } 204: else 205: { 206: if ((s_objet_statistique = allocation(s_etat_processus, MRL)) 207: == NULL) 208: { 209: (*s_etat_processus).erreur_systeme = 210: d_es_allocation_memoire; 211: return; 212: } 213: 214: if (((*((struct_matrice *) (*s_objet_statistique).objet)) 215: .tableau = malloc(sizeof(real8 *))) == NULL) 216: { 217: (*s_etat_processus).erreur_systeme = 218: d_es_allocation_memoire; 219: return; 220: } 221: 222: ((real8 **) (*((struct_matrice *) (*s_objet_statistique) 223: .objet)).tableau)[0] = (real8 *) (*s_objet).objet; 224: } 225: 226: (*((struct_matrice *) (*s_objet_statistique).objet)) 227: .nombre_colonnes = 1; 228: (*((struct_matrice *) (*s_objet_statistique).objet)) 229: .nombre_lignes = 1; 230: 231: free(s_objet); 232: s_objet = NULL; 233: 234: s_variable.objet = s_objet_statistique; 235: 236: if (creation_variable(s_etat_processus, &s_variable, 'V', 'P') 237: == d_erreur) 238: { 239: return; 240: } 241: } 242: else 243: { 244: /* 245: * La variable existe déjà, il faut lui rajouter une ligne. 246: */ 247: 248: if (nombre_colonnes != 1) 249: { 250: (*s_etat_processus).erreur_execution = 251: d_ex_dimensions_matrice_statistique; 252: 253: liberation(s_etat_processus, s_objet); 254: return; 255: } 256: 257: s_objet_statistique = (*(*s_etat_processus) 258: .pointeur_variable_courante).objet; 259: 260: if (((*s_objet_statistique).type == MIN) && 261: ((*s_objet).type == INT)) 262: { 263: tampon = (*((struct_matrice *) (*s_objet_statistique).objet)) 264: .tableau; 265: (*((struct_matrice *) (*s_objet_statistique).objet)) 266: .nombre_lignes++; 267: 268: if (((*((struct_matrice *) (*s_objet_statistique).objet)) 269: .tableau = malloc((*((struct_matrice *) 270: (*s_objet_statistique).objet)).nombre_lignes * 271: sizeof(integer8 *))) == NULL) 272: { 273: (*s_etat_processus).erreur_systeme = 274: d_es_allocation_memoire; 275: return; 276: } 277: 278: for(i = 0; i < ((*((struct_matrice *) 279: (*s_objet_statistique).objet)).nombre_lignes - 1); i++) 280: { 281: ((integer8 **) (*((struct_matrice *) (*s_objet_statistique) 282: .objet)).tableau)[i] = ((integer8 **) tampon)[i]; 283: } 284: 285: free(tampon); 286: 287: ((integer8 **) (*((struct_matrice *) (*s_objet_statistique) 288: .objet)).tableau)[i] = (integer8 *) (*s_objet).objet; 289: 290: free(s_objet); 291: s_objet = NULL; 292: } 293: else if (((*s_objet_statistique).type == MRL) && 294: ((*s_objet).type == REL)) 295: { 296: tampon = (*((struct_matrice *) (*s_objet_statistique).objet)) 297: .tableau; 298: (*((struct_matrice *) (*s_objet_statistique).objet)) 299: .nombre_lignes++; 300: 301: if (((*((struct_matrice *) (*s_objet_statistique).objet)) 302: .tableau = malloc((*((struct_matrice *) 303: (*s_objet_statistique).objet)).nombre_lignes * 304: sizeof(real8 *))) == NULL) 305: { 306: (*s_etat_processus).erreur_systeme = 307: d_es_allocation_memoire; 308: return; 309: } 310: 311: for(i = 0; i < ((*((struct_matrice *) 312: (*s_objet_statistique).objet)).nombre_lignes - 1); i++) 313: { 314: ((real8 **) (*((struct_matrice *) (*s_objet_statistique) 315: .objet)).tableau)[i] = ((real8 **) tampon)[i]; 316: } 317: 318: free(tampon); 319: 320: ((real8 **) (*((struct_matrice *) (*s_objet_statistique) 321: .objet)).tableau)[i] = (real8 *) (*s_objet).objet; 322: 323: free(s_objet); 324: s_objet = NULL; 325: } 326: else if (((*s_objet_statistique).type == MRL) && 327: ((*s_objet).type == INT)) 328: { 329: tampon = (*((struct_matrice *) (*s_objet_statistique).objet)) 330: .tableau; 331: (*((struct_matrice *) (*s_objet_statistique).objet)) 332: .nombre_lignes++; 333: 334: if (((*((struct_matrice *) (*s_objet_statistique).objet)) 335: .tableau = malloc((*((struct_matrice *) 336: (*s_objet_statistique).objet)).nombre_lignes * 337: sizeof(real8 *))) == NULL) 338: { 339: (*s_etat_processus).erreur_systeme = 340: d_es_allocation_memoire; 341: return; 342: } 343: 344: for(i = 0; i < ((*((struct_matrice *) 345: (*s_objet_statistique).objet)).nombre_lignes - 1); i++) 346: { 347: ((real8 **) (*((struct_matrice *) (*s_objet_statistique) 348: .objet)).tableau)[i] = ((real8 **) tampon)[i]; 349: } 350: 351: free(tampon); 352: 353: if ((((real8 **) (*((struct_matrice *) (*s_objet_statistique) 354: .objet)).tableau)[i] = malloc(sizeof(real8))) 355: == NULL) 356: { 357: (*s_etat_processus).erreur_systeme = 358: d_es_allocation_memoire; 359: return; 360: } 361: 362: ((real8 **) (*((struct_matrice *) (*s_objet_statistique) 363: .objet)).tableau)[i][0] = 364: (real8) (*((integer8 *) (*s_objet).objet)); 365: } 366: else 367: { 368: tampon = (*((struct_matrice *) (*s_objet_statistique).objet)) 369: .tableau; 370: (*((struct_matrice *) (*s_objet_statistique).objet)) 371: .nombre_lignes++; 372: 373: if (((*((struct_matrice *) (*s_objet_statistique).objet)) 374: .tableau = malloc((*((struct_matrice *) 375: (*s_objet_statistique).objet)).nombre_lignes * 376: sizeof(real8 *))) == NULL) 377: { 378: (*s_etat_processus).erreur_systeme = 379: d_es_allocation_memoire; 380: return; 381: } 382: 383: for(i = 0; i < ((*((struct_matrice *) 384: (*s_objet_statistique).objet)).nombre_lignes - 1); i++) 385: { 386: if ((((real8 **) (*((struct_matrice *) 387: (*s_objet_statistique).objet)).tableau)[i] = 388: malloc(sizeof(real8))) == NULL) 389: { 390: (*s_etat_processus).erreur_systeme = 391: d_es_allocation_memoire; 392: return; 393: } 394: 395: ((real8 **) (*((struct_matrice *) (*s_objet_statistique) 396: .objet)).tableau)[i][0] = (real8) 397: ((integer8 **) tampon)[i][0]; 398: 399: free(((integer8 **) tampon)[i]); 400: } 401: 402: if ((((real8 **) (*((struct_matrice *) (*s_objet_statistique) 403: .objet)).tableau)[i] = malloc(sizeof(real8))) 404: == NULL) 405: { 406: (*s_etat_processus).erreur_systeme = 407: d_es_allocation_memoire; 408: return; 409: } 410: 411: ((real8 **) (*((struct_matrice *) (*s_objet_statistique) 412: .objet)).tableau)[i][0] = (*((real8 *) 413: (*s_objet).objet)); 414: 415: (*((struct_matrice *) (*s_objet_statistique).objet)).type = 'R'; 416: (*s_objet_statistique).type = MRL; 417: 418: free(tampon); 419: } 420: } 421: } 422: 423: /* 424: * Ajout d'un vecteur 425: */ 426: 427: else if (((*s_objet).type == VIN) || 428: ((*s_objet).type == VRL)) 429: { 430: if (creation_variable_sigma == d_vrai) 431: { 432: /* 433: * Création d'une matrice statistique 1*NC 434: */ 435: 436: if ((s_variable.nom = malloc(6 * sizeof(unsigned char))) == NULL) 437: { 438: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; 439: return; 440: } 441: 442: strcpy(s_variable.nom, ds_sdat); 443: s_variable.niveau = 1; 444: 445: if ((*s_objet).type == VIN) 446: { 447: if ((s_objet_statistique = allocation(s_etat_processus, MIN)) 448: == NULL) 449: { 450: (*s_etat_processus).erreur_systeme = 451: d_es_allocation_memoire; 452: return; 453: } 454: 455: if (((*((struct_matrice *) (*s_objet_statistique).objet)) 456: .tableau = malloc(sizeof(integer8 **))) == NULL) 457: { 458: (*s_etat_processus).erreur_systeme = 459: d_es_allocation_memoire; 460: return; 461: } 462: 463: ((integer8 **) (*((struct_matrice *) (*s_objet_statistique) 464: .objet)).tableau)[0] = (*((struct_vecteur *) 465: (*s_objet).objet)).tableau; 466: } 467: else 468: { 469: if ((s_objet_statistique = allocation(s_etat_processus, MRL)) 470: == NULL) 471: { 472: (*s_etat_processus).erreur_systeme = 473: d_es_allocation_memoire; 474: return; 475: } 476: 477: if (((*((struct_matrice *) (*s_objet_statistique).objet)) 478: .tableau = malloc(sizeof(real8 **))) == NULL) 479: { 480: (*s_etat_processus).erreur_systeme = 481: d_es_allocation_memoire; 482: return; 483: } 484: 485: ((real8 **) (*((struct_matrice *) (*s_objet_statistique) 486: .objet)).tableau)[0] = (*((struct_vecteur *) 487: (*s_objet).objet)).tableau; 488: } 489: 490: (*((struct_matrice *) (*s_objet_statistique).objet)) 491: .nombre_colonnes = (*((struct_vecteur *) (*s_objet).objet)) 492: .taille; 493: (*((struct_matrice *) (*s_objet_statistique).objet)) 494: .nombre_lignes = 1; 495: 496: free((struct_vecteur *) (*s_objet).objet); 497: free(s_objet); 498: s_objet = NULL; 499: 500: s_variable.objet = s_objet_statistique; 501: 502: if (creation_variable(s_etat_processus, &s_variable, 'V', 'P') 503: == d_erreur) 504: { 505: return; 506: } 507: } 508: else 509: { 510: /* 511: * La variable existe déjà, il faut lui rajouter une ligne. 512: */ 513: 514: if (nombre_colonnes != (*((struct_vecteur *) (*s_objet).objet)) 515: .taille) 516: { 517: (*s_etat_processus).erreur_execution = 518: d_ex_dimensions_matrice_statistique; 519: 520: liberation(s_etat_processus, s_objet); 521: return; 522: } 523: 524: s_objet_statistique = (*(*s_etat_processus) 525: .pointeur_variable_courante).objet; 526: 527: if (((*s_objet_statistique).type == MIN) && 528: ((*s_objet).type == VIN)) 529: { 530: tampon = (*((struct_matrice *) (*s_objet_statistique).objet)) 531: .tableau; 532: (*((struct_matrice *) (*s_objet_statistique).objet)) 533: .nombre_lignes++; 534: 535: if (((*((struct_matrice *) (*s_objet_statistique).objet)) 536: .tableau = malloc((*((struct_matrice *) 537: (*s_objet_statistique).objet)).nombre_lignes * 538: sizeof(integer8 *))) == NULL) 539: { 540: (*s_etat_processus).erreur_systeme = 541: d_es_allocation_memoire; 542: return; 543: } 544: 545: for(i = 0; i < ((*((struct_matrice *) 546: (*s_objet_statistique).objet)).nombre_lignes - 1); i++) 547: { 548: ((integer8 **) (*((struct_matrice *) (*s_objet_statistique) 549: .objet)).tableau)[i] = ((integer8 **) tampon)[i]; 550: } 551: 552: free(tampon); 553: 554: ((integer8 **) (*((struct_matrice *) (*s_objet_statistique) 555: .objet)).tableau)[i] = (integer8 *) 556: (*((struct_vecteur *) (*s_objet).objet)).tableau; 557: 558: free((struct_vecteur *) (*s_objet).objet); 559: free(s_objet); 560: s_objet = NULL; 561: } 562: else if (((*s_objet_statistique).type == MRL) && 563: ((*s_objet).type == VRL)) 564: { 565: tampon = (*((struct_matrice *) (*s_objet_statistique).objet)) 566: .tableau; 567: (*((struct_matrice *) (*s_objet_statistique).objet)) 568: .nombre_lignes++; 569: 570: if (((*((struct_matrice *) (*s_objet_statistique).objet)) 571: .tableau = malloc((*((struct_matrice *) 572: (*s_objet_statistique).objet)).nombre_lignes * 573: sizeof(real8 *))) == NULL) 574: { 575: (*s_etat_processus).erreur_systeme = 576: d_es_allocation_memoire; 577: return; 578: } 579: 580: for(i = 0; i < ((*((struct_matrice *) 581: (*s_objet_statistique).objet)).nombre_lignes - 1); i++) 582: { 583: ((real8 **) (*((struct_matrice *) (*s_objet_statistique) 584: .objet)).tableau)[i] = ((real8 **) tampon)[i]; 585: } 586: 587: free(tampon); 588: 589: ((real8 **) (*((struct_matrice *) (*s_objet_statistique) 590: .objet)).tableau)[i] = (real8 *) 591: (*((struct_vecteur *) (*s_objet).objet)).tableau; 592: 593: free((struct_vecteur *) (*s_objet).objet); 594: free(s_objet); 595: s_objet = NULL; 596: } 597: else if (((*s_objet_statistique).type == MRL) && 598: ((*s_objet).type == VIN)) 599: { 600: tampon = (*((struct_matrice *) (*s_objet_statistique).objet)) 601: .tableau; 602: (*((struct_matrice *) (*s_objet_statistique).objet)) 603: .nombre_lignes++; 604: 605: if (((*((struct_matrice *) (*s_objet_statistique).objet)) 606: .tableau = malloc((*((struct_matrice *) 607: (*s_objet_statistique).objet)).nombre_lignes * 608: sizeof(real8 *))) == NULL) 609: { 610: (*s_etat_processus).erreur_systeme = 611: d_es_allocation_memoire; 612: return; 613: } 614: 615: for(i = 0; i < ((*((struct_matrice *) 616: (*s_objet_statistique).objet)).nombre_lignes - 1); i++) 617: { 618: ((real8 **) (*((struct_matrice *) (*s_objet_statistique) 619: .objet)).tableau)[i] = ((real8 **) tampon)[i]; 620: } 621: 622: free(tampon); 623: 624: if ((((real8 **) (*((struct_matrice *) (*s_objet_statistique) 625: .objet)).tableau)[i] = 626: malloc(nombre_colonnes * sizeof(real8))) == NULL) 627: { 628: (*s_etat_processus).erreur_systeme = 629: d_es_allocation_memoire; 630: return; 631: } 632: 633: for(j = 0; j < nombre_colonnes; j++) 634: { 635: ((real8 **) (*((struct_matrice *) (*s_objet_statistique) 636: .objet)).tableau)[i][j] = 637: (real8) (((integer8 *) (*((struct_vecteur *) 638: (*s_objet).objet)).tableau)[j]); 639: } 640: } 641: else 642: { 643: tampon = (*((struct_matrice *) (*s_objet_statistique).objet)) 644: .tableau; 645: (*((struct_matrice *) (*s_objet_statistique).objet)) 646: .nombre_lignes++; 647: 648: if (((*((struct_matrice *) (*s_objet_statistique).objet)) 649: .tableau = malloc((*((struct_matrice *) 650: (*s_objet_statistique).objet)).nombre_lignes * 651: sizeof(real8 *))) == NULL) 652: { 653: (*s_etat_processus).erreur_systeme = 654: d_es_allocation_memoire; 655: return; 656: } 657: 658: for(i = 0; i < ((*((struct_matrice *) 659: (*s_objet_statistique).objet)).nombre_lignes - 1); i++) 660: { 661: if ((((real8 **) (*((struct_matrice *) 662: (*s_objet_statistique).objet)).tableau)[i] = 663: malloc(nombre_colonnes * sizeof(real8))) == NULL) 664: { 665: (*s_etat_processus).erreur_systeme = 666: d_es_allocation_memoire; 667: return; 668: } 669: 670: for(j = 0; j < nombre_colonnes; j++) 671: { 672: ((real8 **) (*((struct_matrice *) (*s_objet_statistique) 673: .objet)).tableau)[i][j] = (real8) 674: ((integer8 **) tampon)[i][j]; 675: } 676: 677: free(((integer8 **) tampon)[i]); 678: } 679: 680: free(tampon); 681: 682: ((real8 **) (*((struct_matrice *) (*s_objet_statistique) 683: .objet)).tableau)[i] = (real8 *) (*((struct_vecteur *) 684: (*s_objet).objet)).tableau; 685: 686: free((struct_vecteur *) (*s_objet).objet); 687: free(s_objet); 688: s_objet = NULL; 689: 690: (*((struct_matrice *) (*s_objet_statistique).objet)).type = 'R'; 691: (*s_objet_statistique).type = MRL; 692: } 693: } 694: } 695: 696: /* 697: * Ajout d'une matrice 698: */ 699: 700: else if (((*s_objet).type == MIN) || 701: ((*s_objet).type == MRL)) 702: { 703: if (creation_variable_sigma == d_vrai) 704: { 705: /* 706: * Création d'une matrice statistique NL*NC 707: */ 708: 709: if ((s_variable.nom = malloc(6 * sizeof(unsigned char))) == NULL) 710: { 711: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; 712: return; 713: } 714: 715: strcpy(s_variable.nom, ds_sdat); 716: s_variable.niveau = 1; 717: 718: if ((*s_objet).type == MIN) 719: { 720: if ((s_objet_statistique = allocation(s_etat_processus, MIN)) 721: == NULL) 722: { 723: (*s_etat_processus).erreur_systeme = 724: d_es_allocation_memoire; 725: return; 726: } 727: 728: (*s_objet_statistique).objet = (*s_objet).objet; 729: } 730: else 731: { 732: if ((s_objet_statistique = allocation(s_etat_processus, MRL)) 733: == NULL) 734: { 735: (*s_etat_processus).erreur_systeme = 736: d_es_allocation_memoire; 737: return; 738: } 739: 740: (*s_objet_statistique).objet = (*s_objet).objet; 741: } 742: 743: free(s_objet); 744: s_objet = NULL; 745: 746: s_variable.objet = s_objet_statistique; 747: 748: if (creation_variable(s_etat_processus, &s_variable, 'V', 'P') 749: == d_erreur) 750: { 751: return; 752: } 753: } 754: else 755: { 756: /* 757: * La variable existe déjà, il faut lui rajouter le nombre 758: * de lignes de la matrice passée en argument. 759: */ 760: 761: if (nombre_colonnes != (*((struct_matrice *) (*s_objet).objet)) 762: .nombre_colonnes) 763: { 764: (*s_etat_processus).erreur_execution = 765: d_ex_dimensions_matrice_statistique; 766: 767: liberation(s_etat_processus, s_objet); 768: return; 769: } 770: 771: s_objet_statistique = (*(*s_etat_processus) 772: .pointeur_variable_courante).objet; 773: 774: nombre_lignes = (*((struct_matrice *) (*s_objet).objet)) 775: .nombre_lignes; 776: 777: if (((*s_objet_statistique).type == MIN) && 778: ((*s_objet).type == MIN)) 779: { 780: tampon = (*((struct_matrice *) (*s_objet_statistique).objet)) 781: .tableau; 782: (*((struct_matrice *) (*s_objet_statistique).objet)) 783: .nombre_lignes += nombre_lignes; 784: 785: if (((*((struct_matrice *) (*s_objet_statistique).objet)) 786: .tableau = malloc((*((struct_matrice *) 787: (*s_objet_statistique).objet)).nombre_lignes * 788: sizeof(integer8 *))) == NULL) 789: { 790: (*s_etat_processus).erreur_systeme = 791: d_es_allocation_memoire; 792: return; 793: } 794: 795: for(i = 0; i < ((*((struct_matrice *) 796: (*s_objet_statistique).objet)).nombre_lignes 797: - nombre_lignes); i++) 798: { 799: ((integer8 **) (*((struct_matrice *) (*s_objet_statistique) 800: .objet)).tableau)[i] = ((integer8 **) tampon)[i]; 801: } 802: 803: free(tampon); 804: 805: for(k = 0; i < ((*((struct_matrice *) 806: (*s_objet_statistique).objet)).nombre_lignes); i++, k++) 807: { 808: ((integer8 **) (*((struct_matrice *) (*s_objet_statistique) 809: .objet)).tableau)[i] = ((integer8 **) 810: (*((struct_matrice *) (*s_objet).objet)) 811: .tableau)[k]; 812: } 813: 814: free((integer8 **) (*((struct_matrice *) (*s_objet).objet)) 815: .tableau); 816: free((struct_matrice *) (*s_objet).objet); 817: free(s_objet); 818: s_objet = NULL; 819: } 820: else if (((*s_objet_statistique).type == MRL) && 821: ((*s_objet).type == MRL)) 822: { 823: tampon = (*((struct_matrice *) (*s_objet_statistique).objet)) 824: .tableau; 825: (*((struct_matrice *) (*s_objet_statistique).objet)) 826: .nombre_lignes += nombre_lignes; 827: 828: if (((*((struct_matrice *) (*s_objet_statistique).objet)) 829: .tableau = malloc((*((struct_matrice *) 830: (*s_objet_statistique).objet)).nombre_lignes * 831: sizeof(real8 *))) == NULL) 832: { 833: (*s_etat_processus).erreur_systeme = 834: d_es_allocation_memoire; 835: return; 836: } 837: 838: for(i = 0; i < ((*((struct_matrice *) 839: (*s_objet_statistique).objet)).nombre_lignes 840: - nombre_lignes); i++) 841: { 842: ((real8 **) (*((struct_matrice *) (*s_objet_statistique) 843: .objet)).tableau)[i] = ((real8 **) tampon)[i]; 844: } 845: 846: free(tampon); 847: 848: for(k = 0; i < ((*((struct_matrice *) 849: (*s_objet_statistique).objet)).nombre_lignes); i++, k++) 850: { 851: ((real8 **) (*((struct_matrice *) (*s_objet_statistique) 852: .objet)).tableau)[i] = ((real8 **) 853: (*((struct_matrice *) (*s_objet).objet)) 854: .tableau)[k]; 855: } 856: 857: free((real8 **) (*((struct_matrice *) (*s_objet).objet)) 858: .tableau); 859: free((struct_matrice *) (*s_objet).objet); 860: free(s_objet); 861: s_objet = NULL; 862: } 863: else if (((*s_objet_statistique).type == MRL) && 864: ((*s_objet).type == MIN)) 865: { 866: tampon = (*((struct_matrice *) (*s_objet_statistique).objet)) 867: .tableau; 868: (*((struct_matrice *) (*s_objet_statistique).objet)) 869: .nombre_lignes += nombre_lignes; 870: 871: if (((*((struct_matrice *) (*s_objet_statistique).objet)) 872: .tableau = malloc((*((struct_matrice *) 873: (*s_objet_statistique).objet)).nombre_lignes * 874: sizeof(real8 *))) == NULL) 875: { 876: (*s_etat_processus).erreur_systeme = 877: d_es_allocation_memoire; 878: return; 879: } 880: 881: for(i = 0; i < ((*((struct_matrice *) 882: (*s_objet_statistique).objet)).nombre_lignes 883: - nombre_lignes); i++) 884: { 885: ((real8 **) (*((struct_matrice *) (*s_objet_statistique) 886: .objet)).tableau)[i] = ((real8 **) tampon)[i]; 887: } 888: 889: free(tampon); 890: 891: for(k = 0; i < ((*((struct_matrice *) 892: (*s_objet_statistique).objet)).nombre_lignes); i++, k++) 893: { 894: if ((((real8 **) (*((struct_matrice *) 895: (*s_objet_statistique).objet)).tableau)[i] = 896: malloc(nombre_colonnes * sizeof(real8))) == NULL) 897: { 898: (*s_etat_processus).erreur_systeme = 899: d_es_allocation_memoire; 900: return; 901: } 902: 903: for(j = 0; j < nombre_colonnes; j++) 904: { 905: ((real8 **) (*((struct_matrice *) (*s_objet_statistique) 906: .objet)).tableau)[i][j] = 907: (real8) (((integer8 **) (*((struct_matrice *) 908: (*s_objet).objet)).tableau)[k][j]); 909: } 910: } 911: } 912: else 913: { 914: tampon = (*((struct_matrice *) (*s_objet_statistique).objet)) 915: .tableau; 916: (*((struct_matrice *) (*s_objet_statistique).objet)) 917: .nombre_lignes += nombre_lignes; 918: 919: if (((*((struct_matrice *) (*s_objet_statistique).objet)) 920: .tableau = malloc((*((struct_matrice *) 921: (*s_objet_statistique).objet)).nombre_lignes * 922: sizeof(real8 *))) == NULL) 923: { 924: (*s_etat_processus).erreur_systeme = 925: d_es_allocation_memoire; 926: return; 927: } 928: 929: for(i = 0; i < ((*((struct_matrice *) 930: (*s_objet_statistique).objet)).nombre_lignes 931: - nombre_lignes); i++) 932: { 933: if ((((real8 **) (*((struct_matrice *) 934: (*s_objet_statistique).objet)).tableau)[i] = 935: malloc(nombre_colonnes * sizeof(real8))) 936: == NULL) 937: { 938: (*s_etat_processus).erreur_systeme = 939: d_es_allocation_memoire; 940: return; 941: } 942: 943: for(j = 0; j < nombre_colonnes; j++) 944: { 945: ((real8 **) (*((struct_matrice *) (*s_objet_statistique) 946: .objet)).tableau)[i][j] = (real8) 947: ((integer8 **) tampon)[i][j]; 948: } 949: 950: free(((integer8 **) tampon)[i]); 951: } 952: 953: free(tampon); 954: 955: for(k = 0; i < ((*((struct_matrice *) 956: (*s_objet_statistique).objet)).nombre_lignes); i++, k++) 957: { 958: ((real8 **) (*((struct_matrice *) (*s_objet_statistique) 959: .objet)).tableau)[i] = ((real8 **) 960: (*((struct_matrice *) (*s_objet).objet)) 961: .tableau)[k]; 962: } 963: 964: free((real8 **) (*((struct_matrice *) (*s_objet).objet)) 965: .tableau); 966: free((struct_matrice *) (*s_objet).objet); 967: free(s_objet); 968: s_objet = NULL; 969: 970: (*((struct_matrice *) (*s_objet_statistique).objet)).type = 'R'; 971: (*s_objet_statistique).type = MRL; 972: } 973: } 974: } 975: 976: /* 977: * Type incompatible en entrée 978: */ 979: 980: else 981: { 982: liberation(s_etat_processus, s_objet); 983: 984: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; 985: return; 986: } 987: 988: liberation(s_etat_processus, s_objet); 989: 990: return; 991: } 992: 993: 994: /* 995: ================================================================================ 996: Fonction 's-' 997: ================================================================================ 998: Entrées : structure processus 999: -------------------------------------------------------------------------------- 1000: Sorties : 1001: -------------------------------------------------------------------------------- 1002: Effets de bord : néant 1003: ================================================================================ 1004: */ 1005: 1006: void 1007: instruction_s_moins(struct_processus *s_etat_processus) 1008: { 1009: struct_objet *s_copie_statistique; 1010: struct_objet *s_objet; 1011: struct_objet *s_objet_statistique; 1012: 1013: unsigned long i; 1014: unsigned long nombre_colonnes; 1015: unsigned long nombre_lignes; 1016: 1017: void *tampon; 1018: 1019: (*s_etat_processus).erreur_execution = d_ex; 1020: 1021: if ((*s_etat_processus).affichage_arguments == 'Y') 1022: { 1023: printf("\n S- "); 1024: 1025: if ((*s_etat_processus).langue == 'F') 1026: { 1027: printf("(retrait une donnée dans la matrice statistique)\n\n"); 1028: } 1029: else 1030: { 1031: printf("(remove a data value from statistical matrix)\n\n"); 1032: } 1033: 1034: printf("-> 1: %s, %s, %s, %s\n", d_INT, d_REL, d_VIN, d_VRL); 1035: 1036: return; 1037: } 1038: else if ((*s_etat_processus).test_instruction == 'Y') 1039: { 1040: (*s_etat_processus).nombre_arguments = -1; 1041: return; 1042: } 1043: 1044: if (test_cfsf(s_etat_processus, 31) == d_vrai) 1045: { 1046: if (empilement_pile_last(s_etat_processus, 0) == d_erreur) 1047: { 1048: return; 1049: } 1050: } 1051: 1052: /* 1053: * Recherche d'une variable globale référencée par SIGMA 1054: */ 1055: 1056: if (recherche_variable_globale(s_etat_processus, ds_sdat) == d_faux) 1057: { 1058: /* 1059: * Aucune variable SIGMA 1060: */ 1061: 1062: (*s_etat_processus).erreur_systeme = d_es; 1063: 1064: if ((*s_etat_processus).erreur_execution == d_ex) 1065: { 1066: (*s_etat_processus).erreur_execution = d_ex_absence_observations; 1067: } 1068: 1069: return; 1070: } 1071: else 1072: { 1073: if ((*(*s_etat_processus).pointeur_variable_courante) 1074: .variable_verrouillee == d_vrai) 1075: { 1076: (*s_etat_processus).erreur_execution = 1077: d_ex_variable_verrouillee; 1078: return; 1079: } 1080: 1081: if (((*(*(*s_etat_processus).pointeur_variable_courante).objet) 1082: .type != MIN) && ((*(*(*s_etat_processus) 1083: .pointeur_variable_courante).objet).type != MRL)) 1084: { 1085: (*s_etat_processus).erreur_execution = 1086: d_ex_matrice_statistique_invalide; 1087: return; 1088: } 1089: 1090: if ((s_copie_statistique = copie_objet(s_etat_processus, 1091: (*(*s_etat_processus).pointeur_variable_courante).objet, 'O')) 1092: == NULL) 1093: { 1094: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; 1095: return; 1096: } 1097: 1098: liberation(s_etat_processus, (*(*s_etat_processus) 1099: .pointeur_variable_courante).objet); 1100: (*(*s_etat_processus).pointeur_variable_courante).objet = 1101: s_copie_statistique; 1102: 1103: nombre_colonnes = (*((struct_matrice *) (*(*(*s_etat_processus) 1104: .pointeur_variable_courante).objet).objet)).nombre_colonnes; 1105: nombre_lignes = (*((struct_matrice *) (*(*(*s_etat_processus) 1106: .pointeur_variable_courante).objet).objet)).nombre_lignes; 1107: } 1108: 1109: s_objet_statistique = (*(*s_etat_processus).pointeur_variable_courante) 1110: .objet; 1111: 1112: if ((*s_objet_statistique).type == MIN) 1113: { 1114: if (nombre_colonnes == 1) 1115: { 1116: /* 1117: * Formation d'un entier 1118: */ 1119: 1120: if ((s_objet = allocation(s_etat_processus, NON)) == NULL) 1121: { 1122: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; 1123: return; 1124: } 1125: 1126: (*s_objet).type = INT; 1127: 1128: if (nombre_lignes == 1) 1129: { 1130: if (((*s_objet).objet = malloc(sizeof(integer8))) == NULL) 1131: { 1132: (*s_etat_processus).erreur_systeme = 1133: d_es_allocation_memoire; 1134: return; 1135: } 1136: 1137: (*((integer8 *) (*s_objet).objet)) = ((integer8 **) 1138: (*((struct_matrice *) (*s_objet_statistique).objet)) 1139: .tableau)[nombre_lignes - 1][0]; 1140: } 1141: else 1142: { 1143: (*s_objet).objet = ((integer8 **) 1144: (*((struct_matrice *) (*s_objet_statistique).objet)) 1145: .tableau)[nombre_lignes - 1]; 1146: } 1147: } 1148: else 1149: { 1150: /* 1151: * Formation d'un vecteur d'entiers 1152: */ 1153: 1154: if ((s_objet = allocation(s_etat_processus, NON)) == NULL) 1155: { 1156: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; 1157: return; 1158: } 1159: 1160: if (((*s_objet).objet = malloc(sizeof(struct_vecteur))) == NULL) 1161: { 1162: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; 1163: return; 1164: } 1165: 1166: (*s_objet).type = VIN; 1167: (*((struct_vecteur *) (*s_objet).objet)).type = 'I'; 1168: (*((struct_vecteur *) (*s_objet).objet)).taille = nombre_colonnes; 1169: 1170: if (nombre_lignes == 1) 1171: { 1172: if (((*((struct_vecteur *) (*s_objet).objet)) 1173: .tableau = malloc(nombre_colonnes * 1174: sizeof(integer8))) == NULL) 1175: { 1176: (*s_etat_processus).erreur_systeme = 1177: d_es_allocation_memoire; 1178: return; 1179: } 1180: 1181: for(i = 0; i < nombre_colonnes; i++) 1182: { 1183: ((integer8 *) (*((struct_vecteur *) (*s_objet).objet)) 1184: .tableau)[i] = ((integer8 **) (*((struct_matrice *) 1185: (*s_objet_statistique).objet)).tableau) 1186: [nombre_lignes - 1][i]; 1187: } 1188: } 1189: else 1190: { 1191: (*((struct_vecteur *) (*s_objet).objet)).tableau = 1192: ((integer8 **) (*((struct_matrice *) 1193: (*s_objet_statistique).objet)).tableau) 1194: [nombre_lignes - 1]; 1195: } 1196: } 1197: 1198: if (nombre_lignes == 1) 1199: { 1200: /* 1201: * Destruction de la variable globale SIGMA 1202: */ 1203: 1204: if (retrait_variable(s_etat_processus, ds_sdat, 'G') == d_erreur) 1205: { 1206: return; 1207: } 1208: } 1209: else 1210: { 1211: /* 1212: * Elimination de la dernière ligne de la matrice SIGMA 1213: */ 1214: 1215: tampon = (*((struct_matrice *) (*s_objet_statistique) 1216: .objet)).tableau; 1217: (*((struct_matrice *) (*s_objet_statistique).objet)) 1218: .nombre_lignes--; 1219: 1220: if (((*((struct_matrice *) (*s_objet_statistique) 1221: .objet)).tableau = malloc( 1222: (*((struct_matrice *) (*s_objet_statistique).objet)) 1223: .nombre_lignes * sizeof(integer8 *))) == NULL) 1224: { 1225: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; 1226: return; 1227: } 1228: 1229: for(i = 0; i < (*((struct_matrice *) (*s_objet_statistique) 1230: .objet)).nombre_lignes; i++) 1231: { 1232: ((integer8 **) (*((struct_matrice *) (*s_objet_statistique) 1233: .objet)).tableau)[i] = ((integer8 **) tampon)[i]; 1234: } 1235: 1236: free(tampon); 1237: } 1238: } 1239: else if ((*s_objet_statistique).type == MRL) 1240: { 1241: if (nombre_colonnes == 1) 1242: { 1243: /* 1244: * Formation d'un réel 1245: */ 1246: 1247: if ((s_objet = allocation(s_etat_processus, NON)) == NULL) 1248: { 1249: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; 1250: return; 1251: } 1252: 1253: (*s_objet).type = REL; 1254: 1255: if (nombre_lignes == 1) 1256: { 1257: if (((*s_objet).objet = malloc(sizeof(real8))) 1258: == NULL) 1259: { 1260: (*s_etat_processus).erreur_systeme = 1261: d_es_allocation_memoire; 1262: return; 1263: } 1264: 1265: (*((real8 *) (*s_objet).objet)) = ((real8 **) 1266: (*((struct_matrice *) (*s_objet_statistique).objet)) 1267: .tableau)[nombre_lignes - 1][0]; 1268: } 1269: else 1270: { 1271: (*s_objet).objet = ((real8 **) 1272: (*((struct_matrice *) (*s_objet_statistique).objet)) 1273: .tableau)[nombre_lignes - 1]; 1274: } 1275: } 1276: else 1277: { 1278: /* 1279: * Formation d'un vecteur de réels 1280: */ 1281: 1282: if ((s_objet = allocation(s_etat_processus, NON)) == NULL) 1283: { 1284: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; 1285: return; 1286: } 1287: 1288: if (((*s_objet).objet = malloc(sizeof(struct_vecteur))) == NULL) 1289: { 1290: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; 1291: return; 1292: } 1293: 1294: (*s_objet).type = VRL; 1295: (*((struct_vecteur *) (*s_objet).objet)).type = 'R'; 1296: (*((struct_vecteur *) (*s_objet).objet)).taille = nombre_colonnes; 1297: 1298: if (nombre_lignes == 1) 1299: { 1300: if (((*((struct_vecteur *) (*s_objet).objet)) 1301: .tableau = malloc(nombre_colonnes * 1302: sizeof(real8))) == NULL) 1303: { 1304: (*s_etat_processus).erreur_systeme = 1305: d_es_allocation_memoire; 1306: return; 1307: } 1308: 1309: for(i = 0; i < nombre_colonnes; i++) 1310: { 1311: ((real8 *) (*((struct_vecteur *) (*s_objet).objet)) 1312: .tableau)[i] = ((real8 **) (*((struct_matrice *) 1313: (*s_objet_statistique).objet)).tableau) 1314: [nombre_lignes - 1][i]; 1315: } 1316: } 1317: else 1318: { 1319: (*((struct_vecteur *) (*s_objet).objet)).tableau = 1320: ((real8 **) (*((struct_matrice *) 1321: (*s_objet_statistique).objet)).tableau) 1322: [nombre_lignes - 1]; 1323: } 1324: } 1325: 1326: if (nombre_lignes == 1) 1327: { 1328: /* 1329: * Destruction de la variable globale SIGMA 1330: */ 1331: 1332: if (retrait_variable(s_etat_processus, ds_sdat, 'G') == d_erreur) 1333: { 1334: return; 1335: } 1336: } 1337: else 1338: { 1339: /* 1340: * Elimination de la dernière ligne de la matrice SIGMA 1341: */ 1342: 1343: tampon = (*((struct_matrice *) (*s_objet_statistique) 1344: .objet)).tableau; 1345: (*((struct_matrice *) (*s_objet_statistique).objet)) 1346: .nombre_lignes--; 1347: 1348: if (((*((struct_matrice *) (*s_objet_statistique).objet)) 1349: .tableau = malloc((*((struct_matrice *) 1350: (*s_objet_statistique).objet)).nombre_lignes * 1351: sizeof(real8 *))) == NULL) 1352: { 1353: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; 1354: return; 1355: } 1356: 1357: for(i = 0; i < (*((struct_matrice *) (*s_objet_statistique) 1358: .objet)).nombre_lignes; i++) 1359: { 1360: ((real8 **) (*((struct_matrice *) (*s_objet_statistique) 1361: .objet)).tableau)[i] = ((real8 **) tampon)[i]; 1362: } 1363: 1364: free(tampon); 1365: } 1366: } 1367: else 1368: { 1369: (*s_etat_processus).erreur_execution = 1370: d_ex_matrice_statistique_invalide; 1371: return; 1372: } 1373: 1374: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), 1375: s_objet) == d_erreur) 1376: { 1377: return; 1378: } 1379: 1380: return; 1381: } 1382: 1383: // vim: ts=4