![]() ![]() | ![]() |
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 'col+' 29: ================================================================================ 30: Entrées : 31: -------------------------------------------------------------------------------- 32: Sorties : 33: -------------------------------------------------------------------------------- 34: Effets de bord : néant 35: ================================================================================ 36: */ 37: 38: void 39: instruction_col_plus(struct_processus *s_etat_processus) 40: { 41: integer8 position; 42: 43: logical1 presence_nom; 44: logical1 variable_partagee; 45: 46: struct_objet *s_copie_argument_3; 47: struct_objet *s_objet_argument_1; 48: struct_objet *s_objet_argument_2; 49: struct_objet *s_objet_argument_3; 50: 51: unsigned long i; 52: unsigned long j; 53: unsigned long l; 54: 55: void *tampon; 56: 57: (*s_etat_processus).erreur_execution = d_ex; 58: 59: if ((*s_etat_processus).affichage_arguments == 'Y') 60: { 61: printf("\n COL+ "); 62: 63: if ((*s_etat_processus).langue == 'F') 64: { 65: printf("(ajout d'une colonne dans une matrice)\n\n"); 66: } 67: else 68: { 69: printf("(add a column in a matrix)\n\n"); 70: } 71: 72: printf(" 3: %s, %s, %s\n", d_MIN, d_MRL, d_MCX); 73: printf(" 2: %s\n", d_INT); 74: printf(" 1: %s, %s, %s\n\n", d_MIN, d_MRL, d_MCX); 75: printf("-> 1: %s, %s, %s\n\n", d_MIN, d_MRL, d_MCX); 76: 77: printf(" 3: %s\n", d_NOM); 78: printf(" 2: %s\n", d_INT); 79: printf(" 1: %s, %s, %s\n", d_MIN, d_MRL, d_MCX); 80: 81: return; 82: } 83: else if ((*s_etat_processus).test_instruction == 'Y') 84: { 85: (*s_etat_processus).nombre_arguments = -1; 86: return; 87: } 88: 89: if (test_cfsf(s_etat_processus, 31) == d_vrai) 90: { 91: if (empilement_pile_last(s_etat_processus, 3) == d_erreur) 92: { 93: return; 94: } 95: } 96: 97: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile), 98: &s_objet_argument_1) == d_erreur) 99: { 100: (*s_etat_processus).erreur_execution = d_ex_manque_argument; 101: return; 102: } 103: 104: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile), 105: &s_objet_argument_2) == d_erreur) 106: { 107: liberation(s_etat_processus, s_objet_argument_1); 108: 109: (*s_etat_processus).erreur_execution = d_ex_manque_argument; 110: return; 111: } 112: 113: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile), 114: &s_objet_argument_3) == d_erreur) 115: { 116: liberation(s_etat_processus, s_objet_argument_1); 117: liberation(s_etat_processus, s_objet_argument_2); 118: 119: (*s_etat_processus).erreur_execution = d_ex_manque_argument; 120: return; 121: } 122: 123: if (((*s_objet_argument_1).type != MIN) && 124: ((*s_objet_argument_1).type != MRL) && 125: ((*s_objet_argument_1).type != MCX)) 126: { 127: liberation(s_etat_processus, s_objet_argument_1); 128: liberation(s_etat_processus, s_objet_argument_2); 129: liberation(s_etat_processus, s_objet_argument_3); 130: 131: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; 132: return; 133: } 134: 135: if ((*((struct_matrice *) (*s_objet_argument_1).objet)).nombre_colonnes 136: != 1) 137: { 138: liberation(s_etat_processus, s_objet_argument_1); 139: liberation(s_etat_processus, s_objet_argument_2); 140: liberation(s_etat_processus, s_objet_argument_3); 141: 142: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides; 143: return; 144: } 145: 146: if ((*s_objet_argument_2).type != INT) 147: { 148: liberation(s_etat_processus, s_objet_argument_1); 149: liberation(s_etat_processus, s_objet_argument_2); 150: liberation(s_etat_processus, s_objet_argument_3); 151: 152: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; 153: return; 154: } 155: 156: variable_partagee = d_faux; 157: 158: if ((*s_objet_argument_3).type == NOM) 159: { 160: presence_nom = d_vrai; 161: 162: if (recherche_variable(s_etat_processus, (*((struct_nom *) 163: (*s_objet_argument_3).objet)).nom) == d_faux) 164: { 165: (*s_etat_processus).erreur_systeme = d_es; 166: (*s_etat_processus).erreur_execution = d_ex_variable_non_definie; 167: 168: liberation(s_etat_processus, s_objet_argument_1); 169: liberation(s_etat_processus, s_objet_argument_2); 170: liberation(s_etat_processus, s_objet_argument_3); 171: 172: return; 173: } 174: 175: liberation(s_etat_processus, s_objet_argument_3); 176: 177: if ((*(*s_etat_processus).pointeur_variable_courante) 178: .variable_verrouillee == d_vrai) 179: { 180: liberation(s_etat_processus, s_objet_argument_1); 181: liberation(s_etat_processus, s_objet_argument_2); 182: 183: (*s_etat_processus).erreur_execution = d_ex_variable_verrouillee; 184: return; 185: } 186: 187: if ((*(*s_etat_processus).pointeur_variable_courante).objet == NULL) 188: { 189: if (pthread_mutex_lock(&((*(*s_etat_processus) 190: .s_liste_variables_partagees).mutex)) != 0) 191: { 192: (*s_etat_processus).erreur_systeme = d_es_processus; 193: return; 194: } 195: 196: if (recherche_variable_partagee(s_etat_processus, 197: (*(*s_etat_processus).pointeur_variable_courante).nom, 198: (*(*s_etat_processus).pointeur_variable_courante) 199: .variable_partagee, (*(*s_etat_processus) 200: .pointeur_variable_courante).origine) == d_faux) 201: { 202: (*s_etat_processus).erreur_systeme = d_es; 203: (*s_etat_processus).erreur_execution = 204: d_ex_variable_non_definie; 205: 206: if (pthread_mutex_unlock(&((*(*s_etat_processus) 207: .s_liste_variables_partagees).mutex)) != 0) 208: { 209: (*s_etat_processus).erreur_systeme = d_es_processus; 210: return; 211: } 212: 213: liberation(s_etat_processus, s_objet_argument_1); 214: liberation(s_etat_processus, s_objet_argument_2); 215: return; 216: } 217: 218: variable_partagee = d_vrai; 219: s_objet_argument_3 = (*(*s_etat_processus) 220: .s_liste_variables_partagees).table[(*(*s_etat_processus) 221: .s_liste_variables_partagees).position_variable].objet; 222: } 223: else 224: { 225: s_objet_argument_3 = (*(*s_etat_processus) 226: .pointeur_variable_courante).objet; 227: } 228: } 229: else 230: { 231: presence_nom = d_faux; 232: } 233: 234: if ((*((struct_matrice *) (*s_objet_argument_1).objet)).nombre_lignes 235: != (*((struct_matrice *) (*s_objet_argument_3).objet)) 236: .nombre_lignes) 237: { 238: liberation(s_etat_processus, s_objet_argument_1); 239: liberation(s_etat_processus, s_objet_argument_2); 240: 241: if (variable_partagee == d_vrai) 242: { 243: if (pthread_mutex_unlock(&((*(*s_etat_processus) 244: .s_liste_variables_partagees).mutex)) != 0) 245: { 246: (*s_etat_processus).erreur_systeme = d_es_processus; 247: return; 248: } 249: } 250: 251: if (presence_nom == d_faux) 252: { 253: liberation(s_etat_processus, s_objet_argument_3); 254: } 255: 256: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides; 257: return; 258: } 259: 260: if ((s_copie_argument_3 = copie_objet(s_etat_processus, 261: s_objet_argument_3, 'Q')) == NULL) 262: { 263: if (variable_partagee == d_vrai) 264: { 265: if (pthread_mutex_unlock(&((*(*s_etat_processus) 266: .s_liste_variables_partagees).mutex)) != 0) 267: { 268: (*s_etat_processus).erreur_systeme = d_es_processus; 269: return; 270: } 271: } 272: 273: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; 274: return; 275: } 276: 277: if ((*s_objet_argument_1).type == MRL) 278: { 279: if ((*s_copie_argument_3).type == MIN) 280: { 281: // Conversion de la matrice entière en matrice réelle 282: 283: for(i = 0; i < (*((struct_matrice *) (*s_copie_argument_3).objet)) 284: .nombre_lignes; i++) 285: { 286: tampon = (*((struct_matrice *) (*s_copie_argument_3).objet)) 287: .tableau[i]; 288: 289: if (((*((struct_matrice *) (*s_copie_argument_3).objet)) 290: .tableau[i] = malloc((*((struct_matrice *) 291: (*s_copie_argument_3).objet)).nombre_colonnes * 292: sizeof(real8))) == NULL) 293: { 294: if (variable_partagee == d_vrai) 295: { 296: if (pthread_mutex_unlock(&((*(*s_etat_processus) 297: .s_liste_variables_partagees).mutex)) != 0) 298: { 299: (*s_etat_processus).erreur_systeme = d_es_processus; 300: return; 301: } 302: } 303: 304: (*s_etat_processus).erreur_systeme = 305: d_es_allocation_memoire; 306: return; 307: } 308: 309: for(j = 0; j < (*((struct_matrice *) (*s_copie_argument_3) 310: .objet)).nombre_colonnes; j++) 311: { 312: ((real8 **) (*((struct_matrice *) (*s_copie_argument_3) 313: .objet)).tableau)[i][j] = (real8) (((integer8 *) 314: tampon)[j]); 315: } 316: 317: free(tampon); 318: } 319: 320: (*((struct_matrice *) (*s_copie_argument_3).objet)).type = 'R'; 321: (*s_copie_argument_3).type = MRL; 322: } 323: } 324: else if ((*s_objet_argument_1).type == MCX) 325: { 326: if ((*s_copie_argument_3).type == MIN) 327: { 328: // Conversion de la matrice entière en matrice complexe 329: 330: for(i = 0; i < (*((struct_matrice *) (*s_copie_argument_3).objet)) 331: .nombre_lignes; i++) 332: { 333: tampon = (*((struct_matrice *) (*s_copie_argument_3).objet)) 334: .tableau[i]; 335: 336: if (((*((struct_matrice *) (*s_copie_argument_3).objet)) 337: .tableau[i] = malloc((*((struct_matrice *) 338: (*s_copie_argument_3).objet)).nombre_colonnes * 339: sizeof(complex16))) == NULL) 340: { 341: if (variable_partagee == d_vrai) 342: { 343: if (pthread_mutex_unlock(&((*(*s_etat_processus) 344: .s_liste_variables_partagees).mutex)) != 0) 345: { 346: (*s_etat_processus).erreur_systeme = d_es_processus; 347: return; 348: } 349: } 350: 351: (*s_etat_processus).erreur_systeme = 352: d_es_allocation_memoire; 353: return; 354: } 355: 356: for(j = 0; j < (*((struct_matrice *) (*s_copie_argument_3) 357: .objet)).nombre_colonnes; j++) 358: { 359: ((complex16 **) (*((struct_matrice *) (*s_copie_argument_3) 360: .objet)).tableau)[i][j].partie_reelle = 361: (real8) (((integer8 *) tampon)[j]); 362: ((complex16 **) (*((struct_matrice *) (*s_copie_argument_3) 363: .objet)).tableau)[i][j].partie_imaginaire = 0; 364: } 365: 366: free(tampon); 367: } 368: 369: (*((struct_matrice *) (*s_copie_argument_3).objet)).type = 'C'; 370: (*s_copie_argument_3).type = MCX; 371: } 372: else if ((*s_copie_argument_3).type == MRL) 373: { 374: // Conversion de la matrice réelle en matrice complexe 375: 376: for(i = 0; i < (*((struct_matrice *) (*s_copie_argument_3).objet)) 377: .nombre_lignes; i++) 378: { 379: tampon = (*((struct_matrice *) (*s_copie_argument_3).objet)) 380: .tableau[i]; 381: 382: if (((*((struct_matrice *) (*s_copie_argument_3).objet)) 383: .tableau[i] = malloc((*((struct_matrice *) 384: (*s_copie_argument_3).objet)).nombre_colonnes * 385: sizeof(complex16))) == NULL) 386: { 387: if (variable_partagee == d_vrai) 388: { 389: if (pthread_mutex_unlock(&((*(*s_etat_processus) 390: .s_liste_variables_partagees).mutex)) != 0) 391: { 392: (*s_etat_processus).erreur_systeme = d_es_processus; 393: return; 394: } 395: } 396: 397: (*s_etat_processus).erreur_systeme = 398: d_es_allocation_memoire; 399: return; 400: } 401: 402: for(j = 0; j < (*((struct_matrice *) (*s_copie_argument_3) 403: .objet)).nombre_colonnes; j++) 404: { 405: ((complex16 **) (*((struct_matrice *) (*s_copie_argument_3) 406: .objet)).tableau)[i][j].partie_reelle = 407: ((real8 *) tampon)[j]; 408: ((complex16 **) (*((struct_matrice *) (*s_copie_argument_3) 409: .objet)).tableau)[i][j].partie_imaginaire = 0; 410: } 411: 412: free(tampon); 413: } 414: 415: (*((struct_matrice *) (*s_copie_argument_3).objet)).type = 'C'; 416: (*s_copie_argument_3).type = MCX; 417: } 418: } 419: 420: position = (*((integer8 *) (*s_objet_argument_2).objet)); 421: 422: if ((*s_copie_argument_3).type == MIN) 423: { 424: if ((*((struct_matrice *) (*s_objet_argument_1).objet)).nombre_lignes 425: != (*((struct_matrice *) (*s_copie_argument_3).objet)) 426: .nombre_lignes) 427: { 428: if (variable_partagee == d_vrai) 429: { 430: if (pthread_mutex_unlock(&((*(*s_etat_processus) 431: .s_liste_variables_partagees).mutex)) != 0) 432: { 433: (*s_etat_processus).erreur_systeme = d_es_processus; 434: return; 435: } 436: } 437: 438: liberation(s_etat_processus, s_objet_argument_1); 439: liberation(s_etat_processus, s_objet_argument_2); 440: liberation(s_etat_processus, s_objet_argument_3); 441: 442: if (presence_nom == d_faux) 443: { 444: liberation(s_etat_processus, s_copie_argument_3); 445: } 446: 447: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides; 448: return; 449: } 450: 451: if ((position < 1) || (position > ((signed long) (*((struct_matrice *) 452: (*s_copie_argument_3).objet)).nombre_colonnes + 1))) 453: { 454: if (variable_partagee == d_vrai) 455: { 456: if (pthread_mutex_unlock(&((*(*s_etat_processus) 457: .s_liste_variables_partagees).mutex)) != 0) 458: { 459: (*s_etat_processus).erreur_systeme = d_es_processus; 460: return; 461: } 462: } 463: 464: liberation(s_etat_processus, s_objet_argument_1); 465: liberation(s_etat_processus, s_objet_argument_2); 466: liberation(s_etat_processus, s_objet_argument_3); 467: 468: if (presence_nom == d_faux) 469: { 470: liberation(s_etat_processus, s_copie_argument_3); 471: } 472: 473: (*s_etat_processus).erreur_execution = 474: d_ex_argument_invalide; 475: return; 476: } 477: 478: for(i = 0; i < (*((struct_matrice *) (*s_copie_argument_3).objet)) 479: .nombre_lignes; i++) 480: { 481: tampon = (*((struct_matrice *) (*s_copie_argument_3).objet)) 482: .tableau[i]; 483: 484: if (((*((struct_matrice *) (*s_copie_argument_3).objet)).tableau[i] 485: = malloc((((*((struct_matrice *) (*s_copie_argument_3) 486: .objet)).nombre_colonnes) + 1) * sizeof(integer8))) == NULL) 487: { 488: if (variable_partagee == d_vrai) 489: { 490: if (pthread_mutex_unlock(&((*(*s_etat_processus) 491: .s_liste_variables_partagees).mutex)) != 0) 492: { 493: (*s_etat_processus).erreur_systeme = d_es_processus; 494: return; 495: } 496: } 497: 498: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; 499: return; 500: } 501: 502: for(l = j = 0; j < (*((struct_matrice *) (*s_copie_argument_3) 503: .objet)).nombre_colonnes; j++) 504: { 505: if ((signed long) j == (position - 1)) 506: { 507: ((integer8 **) (*((struct_matrice *) (*s_copie_argument_3) 508: .objet)).tableau)[i][j] = ((integer8 **) 509: (*((struct_matrice *) (*s_objet_argument_1).objet)) 510: .tableau)[i][0]; 511: l = 1; 512: } 513: 514: ((integer8 **) (*((struct_matrice *) (*s_copie_argument_3) 515: .objet)).tableau)[i][j + l] = ((integer8 *) tampon)[j]; 516: } 517: 518: if (l == 0) 519: { 520: ((integer8 **) (*((struct_matrice *) (*s_copie_argument_3) 521: .objet)).tableau)[i][(*((struct_matrice *) 522: (*s_copie_argument_3).objet)).nombre_colonnes] = 523: ((integer8 **) (*((struct_matrice *) 524: (*s_objet_argument_1).objet)).tableau)[i][0]; 525: } 526: 527: free(tampon); 528: } 529: 530: (*((struct_matrice *) (*s_copie_argument_3).objet)).nombre_colonnes++; 531: } 532: else if ((*s_copie_argument_3).type == MRL) 533: { 534: if ((*s_objet_argument_1).type == MIN) 535: { 536: if ((*((struct_matrice *) (*s_objet_argument_1).objet)) 537: .nombre_lignes != (*((struct_matrice *) 538: (*s_copie_argument_3).objet)).nombre_lignes) 539: { 540: if (variable_partagee == d_vrai) 541: { 542: if (pthread_mutex_unlock(&((*(*s_etat_processus) 543: .s_liste_variables_partagees).mutex)) != 0) 544: { 545: (*s_etat_processus).erreur_systeme = d_es_processus; 546: return; 547: } 548: } 549: 550: liberation(s_etat_processus, s_objet_argument_1); 551: liberation(s_etat_processus, s_objet_argument_2); 552: liberation(s_etat_processus, s_objet_argument_3); 553: 554: if (presence_nom == d_faux) 555: { 556: liberation(s_etat_processus, s_copie_argument_3); 557: } 558: 559: (*s_etat_processus).erreur_execution = 560: d_ex_dimensions_invalides; 561: return; 562: } 563: 564: if ((position < 1) || (position > ((signed long) 565: (*((struct_matrice *) (*s_copie_argument_3).objet)) 566: .nombre_colonnes + 1))) 567: { 568: if (variable_partagee == d_vrai) 569: { 570: if (pthread_mutex_unlock(&((*(*s_etat_processus) 571: .s_liste_variables_partagees).mutex)) != 0) 572: { 573: (*s_etat_processus).erreur_systeme = d_es_processus; 574: return; 575: } 576: } 577: 578: liberation(s_etat_processus, s_objet_argument_1); 579: liberation(s_etat_processus, s_objet_argument_2); 580: liberation(s_etat_processus, s_objet_argument_3); 581: 582: if (presence_nom == d_faux) 583: { 584: liberation(s_etat_processus, s_copie_argument_3); 585: } 586: 587: (*s_etat_processus).erreur_execution = 588: d_ex_argument_invalide; 589: return; 590: } 591: 592: for(i = 0; i < (*((struct_matrice *) (*s_copie_argument_3).objet)) 593: .nombre_lignes; i++) 594: { 595: tampon = (*((struct_matrice *) (*s_copie_argument_3).objet)) 596: .tableau[i]; 597: 598: if (((*((struct_matrice *) (*s_copie_argument_3).objet)) 599: .tableau[i] = malloc((((*((struct_matrice *) 600: (*s_copie_argument_3).objet)).nombre_colonnes) + 1) * 601: sizeof(real8))) == NULL) 602: { 603: if (variable_partagee == d_vrai) 604: { 605: if (pthread_mutex_unlock(&((*(*s_etat_processus) 606: .s_liste_variables_partagees).mutex)) != 0) 607: { 608: (*s_etat_processus).erreur_systeme = d_es_processus; 609: return; 610: } 611: } 612: 613: (*s_etat_processus).erreur_systeme = 614: d_es_allocation_memoire; 615: return; 616: } 617: 618: for(l = j = 0; j < (*((struct_matrice *) (*s_copie_argument_3) 619: .objet)).nombre_colonnes; j++) 620: { 621: if ((signed long) j == (position - 1)) 622: { 623: ((real8 **) (*((struct_matrice *) (*s_copie_argument_3) 624: .objet)).tableau)[i][j] = ((integer8 **) 625: (*((struct_matrice *) (*s_objet_argument_1) 626: .objet)).tableau)[i][0]; 627: l = 1; 628: } 629: 630: ((real8 **) (*((struct_matrice *) (*s_copie_argument_3) 631: .objet)).tableau)[i][j + l] = ((real8 *) tampon)[j]; 632: } 633: 634: if (l == 0) 635: { 636: ((real8 **) (*((struct_matrice *) (*s_copie_argument_3) 637: .objet)).tableau)[i][(*((struct_matrice *) 638: (*s_copie_argument_3).objet)).nombre_colonnes] = 639: ((integer8 **) (*((struct_matrice *) 640: (*s_objet_argument_1).objet)).tableau)[i][0]; 641: } 642: 643: free(tampon); 644: } 645: 646: (*((struct_matrice *) (*s_copie_argument_3).objet)) 647: .nombre_colonnes++; 648: } 649: else // Matrice réelle 650: { 651: if ((*((struct_matrice *) (*s_objet_argument_1).objet)) 652: .nombre_lignes != (*((struct_matrice *) 653: (*s_copie_argument_3).objet)).nombre_lignes) 654: { 655: if (variable_partagee == d_vrai) 656: { 657: if (pthread_mutex_unlock(&((*(*s_etat_processus) 658: .s_liste_variables_partagees).mutex)) != 0) 659: { 660: (*s_etat_processus).erreur_systeme = d_es_processus; 661: return; 662: } 663: } 664: 665: liberation(s_etat_processus, s_objet_argument_1); 666: liberation(s_etat_processus, s_objet_argument_2); 667: liberation(s_etat_processus, s_objet_argument_3); 668: 669: if (presence_nom == d_faux) 670: { 671: liberation(s_etat_processus, s_copie_argument_3); 672: } 673: 674: (*s_etat_processus).erreur_execution = 675: d_ex_dimensions_invalides; 676: return; 677: } 678: 679: if ((position < 1) || (position > ((signed long) 680: (*((struct_matrice *) (*s_copie_argument_3).objet)) 681: .nombre_colonnes + 1))) 682: { 683: if (variable_partagee == d_vrai) 684: { 685: if (pthread_mutex_unlock(&((*(*s_etat_processus) 686: .s_liste_variables_partagees).mutex)) != 0) 687: { 688: (*s_etat_processus).erreur_systeme = d_es_processus; 689: return; 690: } 691: } 692: 693: liberation(s_etat_processus, s_objet_argument_1); 694: liberation(s_etat_processus, s_objet_argument_2); 695: liberation(s_etat_processus, s_objet_argument_3); 696: 697: if (presence_nom == d_faux) 698: { 699: liberation(s_etat_processus, s_copie_argument_3); 700: } 701: 702: (*s_etat_processus).erreur_execution = 703: d_ex_argument_invalide; 704: return; 705: } 706: 707: for(i = 0; i < (*((struct_matrice *) (*s_copie_argument_3).objet)) 708: .nombre_lignes; i++) 709: { 710: tampon = (*((struct_matrice *) (*s_copie_argument_3).objet)) 711: .tableau[i]; 712: 713: if (((*((struct_matrice *) (*s_copie_argument_3).objet)) 714: .tableau[i] = malloc((((*((struct_matrice *) 715: (*s_copie_argument_3).objet)).nombre_colonnes) + 1) * 716: sizeof(real8))) == NULL) 717: { 718: if (variable_partagee == d_vrai) 719: { 720: if (pthread_mutex_unlock(&((*(*s_etat_processus) 721: .s_liste_variables_partagees).mutex)) != 0) 722: { 723: (*s_etat_processus).erreur_systeme = d_es_processus; 724: return; 725: } 726: } 727: 728: (*s_etat_processus).erreur_systeme = 729: d_es_allocation_memoire; 730: return; 731: } 732: 733: for(l = j = 0; j < (*((struct_matrice *) (*s_copie_argument_3) 734: .objet)).nombre_colonnes; j++) 735: { 736: if ((signed long) j == (position - 1)) 737: { 738: ((real8 **) (*((struct_matrice *) (*s_copie_argument_3) 739: .objet)).tableau)[i][j] = ((real8 **) 740: (*((struct_matrice *) (*s_objet_argument_1) 741: .objet)).tableau)[i][0]; 742: l = 1; 743: } 744: 745: ((real8 **) (*((struct_matrice *) (*s_copie_argument_3) 746: .objet)).tableau)[i][j + l] = ((real8 *) tampon)[j]; 747: } 748: 749: if (l == 0) 750: { 751: ((real8 **) (*((struct_matrice *) (*s_copie_argument_3) 752: .objet)).tableau)[i][(*((struct_matrice *) 753: (*s_copie_argument_3).objet)).nombre_colonnes] = 754: ((real8 **) (*((struct_matrice *) 755: (*s_objet_argument_1).objet)).tableau)[i][0]; 756: } 757: 758: free(tampon); 759: } 760: 761: (*((struct_matrice *) (*s_copie_argument_3).objet)) 762: .nombre_colonnes++; 763: } 764: } 765: else if ((*s_copie_argument_3).type == MCX) 766: { 767: if ((*s_objet_argument_1).type == MIN) 768: { 769: if ((*((struct_matrice *) (*s_objet_argument_1).objet)) 770: .nombre_lignes != (*((struct_matrice *) 771: (*s_copie_argument_3).objet)).nombre_lignes) 772: { 773: if (variable_partagee == d_vrai) 774: { 775: if (pthread_mutex_unlock(&((*(*s_etat_processus) 776: .s_liste_variables_partagees).mutex)) != 0) 777: { 778: (*s_etat_processus).erreur_systeme = d_es_processus; 779: return; 780: } 781: } 782: 783: liberation(s_etat_processus, s_objet_argument_1); 784: liberation(s_etat_processus, s_objet_argument_2); 785: liberation(s_etat_processus, s_objet_argument_3); 786: 787: if (presence_nom == d_faux) 788: { 789: liberation(s_etat_processus, s_copie_argument_3); 790: } 791: 792: (*s_etat_processus).erreur_execution = 793: d_ex_dimensions_invalides; 794: return; 795: } 796: 797: if ((position < 1) || (position > ((signed long) 798: (*((struct_matrice *) 799: (*s_copie_argument_3).objet)).nombre_colonnes + 1))) 800: { 801: if (variable_partagee == d_vrai) 802: { 803: if (pthread_mutex_unlock(&((*(*s_etat_processus) 804: .s_liste_variables_partagees).mutex)) != 0) 805: { 806: (*s_etat_processus).erreur_systeme = d_es_processus; 807: return; 808: } 809: } 810: 811: liberation(s_etat_processus, s_objet_argument_1); 812: liberation(s_etat_processus, s_objet_argument_2); 813: liberation(s_etat_processus, s_objet_argument_3); 814: 815: if (presence_nom == d_faux) 816: { 817: liberation(s_etat_processus, s_copie_argument_3); 818: } 819: 820: (*s_etat_processus).erreur_execution = 821: d_ex_argument_invalide; 822: return; 823: } 824: 825: for(i = 0; i < (*((struct_matrice *) (*s_copie_argument_3).objet)) 826: .nombre_lignes; i++) 827: { 828: tampon = (*((struct_matrice *) (*s_copie_argument_3).objet)) 829: .tableau[i]; 830: 831: if (((*((struct_matrice *) (*s_copie_argument_3).objet)) 832: .tableau[i] = malloc((((*((struct_matrice *) 833: (*s_copie_argument_3).objet)).nombre_colonnes) + 1) * 834: sizeof(complex16))) == NULL) 835: { 836: if (variable_partagee == d_vrai) 837: { 838: if (pthread_mutex_unlock(&((*(*s_etat_processus) 839: .s_liste_variables_partagees).mutex)) != 0) 840: { 841: (*s_etat_processus).erreur_systeme = d_es_processus; 842: return; 843: } 844: } 845: 846: (*s_etat_processus).erreur_systeme = 847: d_es_allocation_memoire; 848: return; 849: } 850: 851: for(l = j = 0; j < (*((struct_matrice *) (*s_copie_argument_3) 852: .objet)).nombre_colonnes; j++) 853: { 854: if ((signed long) j == (position - 1)) 855: { 856: ((complex16 **) (*((struct_matrice *) 857: (*s_copie_argument_3).objet)).tableau)[i][j] 858: .partie_reelle = ((integer8 **) 859: (*((struct_matrice *) (*s_objet_argument_1) 860: .objet)).tableau)[i][0]; 861: ((complex16 **) (*((struct_matrice *) 862: (*s_copie_argument_3).objet)).tableau)[i][j] 863: .partie_imaginaire = 0; 864: l = 1; 865: } 866: 867: ((complex16 **) (*((struct_matrice *) (*s_copie_argument_3) 868: .objet)).tableau)[i][j + l].partie_reelle = 869: ((complex16 *) tampon)[j].partie_reelle; 870: ((complex16 **) (*((struct_matrice *) (*s_copie_argument_3) 871: .objet)).tableau)[i][j + l].partie_imaginaire = 872: ((complex16 *) tampon)[j].partie_imaginaire; 873: } 874: 875: if (l == 0) 876: { 877: ((complex16 **) (*((struct_matrice *) (*s_copie_argument_3) 878: .objet)).tableau)[i][(*((struct_matrice *) 879: (*s_copie_argument_3).objet)).nombre_colonnes] 880: .partie_reelle = ((integer8 **) 881: (*((struct_matrice *) (*s_objet_argument_1).objet)) 882: .tableau)[i][0]; 883: ((complex16 **) (*((struct_matrice *) (*s_copie_argument_3) 884: .objet)).tableau)[i][(*((struct_matrice *) 885: (*s_copie_argument_3).objet)).nombre_colonnes] 886: .partie_imaginaire = 0; 887: } 888: 889: free(tampon); 890: } 891: 892: (*((struct_matrice *) (*s_copie_argument_3).objet)) 893: .nombre_colonnes++; 894: } 895: else if ((*s_objet_argument_1).type == MRL) 896: { 897: if ((*((struct_matrice *) (*s_objet_argument_1).objet)) 898: .nombre_lignes != (*((struct_matrice *) 899: (*s_copie_argument_3).objet)).nombre_lignes) 900: { 901: if (variable_partagee == d_vrai) 902: { 903: if (pthread_mutex_unlock(&((*(*s_etat_processus) 904: .s_liste_variables_partagees).mutex)) != 0) 905: { 906: (*s_etat_processus).erreur_systeme = d_es_processus; 907: return; 908: } 909: } 910: 911: liberation(s_etat_processus, s_objet_argument_1); 912: liberation(s_etat_processus, s_objet_argument_2); 913: liberation(s_etat_processus, s_objet_argument_3); 914: 915: if (presence_nom == d_faux) 916: { 917: liberation(s_etat_processus, s_copie_argument_3); 918: } 919: 920: (*s_etat_processus).erreur_execution = 921: d_ex_dimensions_invalides; 922: return; 923: } 924: 925: if ((position < 1) || (position > ((signed long) 926: (*((struct_matrice *) 927: (*s_copie_argument_3).objet)).nombre_colonnes + 1))) 928: { 929: if (variable_partagee == d_vrai) 930: { 931: if (pthread_mutex_unlock(&((*(*s_etat_processus) 932: .s_liste_variables_partagees).mutex)) != 0) 933: { 934: (*s_etat_processus).erreur_systeme = d_es_processus; 935: return; 936: } 937: } 938: 939: liberation(s_etat_processus, s_objet_argument_1); 940: liberation(s_etat_processus, s_objet_argument_2); 941: liberation(s_etat_processus, s_objet_argument_3); 942: 943: if (presence_nom == d_faux) 944: { 945: liberation(s_etat_processus, s_copie_argument_3); 946: } 947: 948: (*s_etat_processus).erreur_execution = 949: d_ex_argument_invalide; 950: return; 951: } 952: 953: for(i = 0; i < (*((struct_matrice *) (*s_copie_argument_3).objet)) 954: .nombre_lignes; i++) 955: { 956: tampon = (*((struct_matrice *) (*s_copie_argument_3).objet)) 957: .tableau[i]; 958: 959: if (((*((struct_matrice *) (*s_copie_argument_3).objet)) 960: .tableau[i] = malloc((((*((struct_matrice *) 961: (*s_copie_argument_3).objet)).nombre_colonnes) + 1) * 962: sizeof(complex16))) == NULL) 963: { 964: if (variable_partagee == d_vrai) 965: { 966: if (pthread_mutex_unlock(&((*(*s_etat_processus) 967: .s_liste_variables_partagees).mutex)) != 0) 968: { 969: (*s_etat_processus).erreur_systeme = d_es_processus; 970: return; 971: } 972: } 973: 974: (*s_etat_processus).erreur_systeme = 975: d_es_allocation_memoire; 976: return; 977: } 978: 979: for(l = j = 0; j < (*((struct_matrice *) (*s_copie_argument_3) 980: .objet)).nombre_colonnes; j++) 981: { 982: if ((signed long) j == (position - 1)) 983: { 984: ((complex16 **) (*((struct_matrice *) 985: (*s_copie_argument_3).objet)).tableau)[i][j] 986: .partie_reelle = ((real8 **) 987: (*((struct_matrice *) (*s_objet_argument_1) 988: .objet)).tableau)[i][0]; 989: ((complex16 **) (*((struct_matrice *) 990: (*s_copie_argument_3).objet)).tableau)[i][j] 991: .partie_imaginaire = 0; 992: l = 1; 993: } 994: 995: ((complex16 **) (*((struct_matrice *) (*s_copie_argument_3) 996: .objet)).tableau)[i][j + l].partie_reelle = 997: ((complex16 *) tampon)[j].partie_reelle; 998: ((complex16 **) (*((struct_matrice *) (*s_copie_argument_3) 999: .objet)).tableau)[i][j + l].partie_imaginaire = 1000: ((complex16 *) tampon)[j].partie_imaginaire; 1001: } 1002: 1003: if (l == 0) 1004: { 1005: ((complex16 **) (*((struct_matrice *) (*s_copie_argument_3) 1006: .objet)).tableau)[i][(*((struct_matrice *) 1007: (*s_copie_argument_3).objet)).nombre_colonnes] 1008: .partie_reelle = ((real8 **) 1009: (*((struct_matrice *) (*s_objet_argument_1).objet)) 1010: .tableau)[i][0]; 1011: ((complex16 **) (*((struct_matrice *) (*s_copie_argument_3) 1012: .objet)).tableau)[i][(*((struct_matrice *) 1013: (*s_copie_argument_3).objet)).nombre_colonnes] 1014: .partie_imaginaire = 0; 1015: } 1016: 1017: free(tampon); 1018: } 1019: 1020: (*((struct_matrice *) (*s_copie_argument_3).objet)) 1021: .nombre_colonnes++; 1022: } 1023: else // Matrice complexe 1024: { 1025: if ((*((struct_matrice *) (*s_objet_argument_1).objet)) 1026: .nombre_lignes != (*((struct_matrice *) 1027: (*s_copie_argument_3).objet)).nombre_lignes) 1028: { 1029: if (variable_partagee == d_vrai) 1030: { 1031: if (pthread_mutex_unlock(&((*(*s_etat_processus) 1032: .s_liste_variables_partagees).mutex)) != 0) 1033: { 1034: (*s_etat_processus).erreur_systeme = d_es_processus; 1035: return; 1036: } 1037: } 1038: 1039: liberation(s_etat_processus, s_objet_argument_1); 1040: liberation(s_etat_processus, s_objet_argument_2); 1041: liberation(s_etat_processus, s_objet_argument_3); 1042: 1043: if (presence_nom == d_faux) 1044: { 1045: liberation(s_etat_processus, s_copie_argument_3); 1046: } 1047: 1048: (*s_etat_processus).erreur_execution = 1049: d_ex_dimensions_invalides; 1050: return; 1051: } 1052: 1053: if ((position < 1) || (position > ((signed long) 1054: (*((struct_matrice *) 1055: (*s_copie_argument_3).objet)).nombre_colonnes + 1))) 1056: { 1057: if (variable_partagee == d_vrai) 1058: { 1059: if (pthread_mutex_unlock(&((*(*s_etat_processus) 1060: .s_liste_variables_partagees).mutex)) != 0) 1061: { 1062: (*s_etat_processus).erreur_systeme = d_es_processus; 1063: return; 1064: } 1065: } 1066: 1067: liberation(s_etat_processus, s_objet_argument_1); 1068: liberation(s_etat_processus, s_objet_argument_2); 1069: liberation(s_etat_processus, s_objet_argument_3); 1070: 1071: if (presence_nom == d_faux) 1072: { 1073: liberation(s_etat_processus, s_copie_argument_3); 1074: } 1075: 1076: (*s_etat_processus).erreur_execution = 1077: d_ex_argument_invalide; 1078: return; 1079: } 1080: 1081: for(i = 0; i < (*((struct_matrice *) (*s_copie_argument_3).objet)) 1082: .nombre_lignes; i++) 1083: { 1084: tampon = (*((struct_matrice *) (*s_copie_argument_3).objet)) 1085: .tableau[i]; 1086: 1087: if (((*((struct_matrice *) (*s_copie_argument_3).objet)) 1088: .tableau[i] = malloc((((*((struct_matrice *) 1089: (*s_copie_argument_3).objet)).nombre_colonnes) + 1) * 1090: sizeof(complex16))) == NULL) 1091: { 1092: if (variable_partagee == d_vrai) 1093: { 1094: if (pthread_mutex_unlock(&((*(*s_etat_processus) 1095: .s_liste_variables_partagees).mutex)) != 0) 1096: { 1097: (*s_etat_processus).erreur_systeme = d_es_processus; 1098: return; 1099: } 1100: } 1101: 1102: (*s_etat_processus).erreur_systeme = 1103: d_es_allocation_memoire; 1104: return; 1105: } 1106: 1107: for(l = j = 0; j < (*((struct_matrice *) (*s_copie_argument_3) 1108: .objet)).nombre_colonnes; j++) 1109: { 1110: if ((signed long) j == (position - 1)) 1111: { 1112: ((complex16 **) (*((struct_matrice *) 1113: (*s_copie_argument_3).objet)).tableau)[i][j] 1114: .partie_reelle = ((complex16 **) 1115: (*((struct_matrice *) (*s_objet_argument_1) 1116: .objet)).tableau)[i][0].partie_reelle; 1117: ((complex16 **) (*((struct_matrice *) 1118: (*s_copie_argument_3).objet)).tableau)[i][j] 1119: .partie_imaginaire = ((complex16 **) 1120: (*((struct_matrice *) (*s_objet_argument_1) 1121: .objet)).tableau)[i][0].partie_imaginaire; 1122: l = 1; 1123: } 1124: 1125: ((complex16 **) (*((struct_matrice *) (*s_copie_argument_3) 1126: .objet)).tableau)[i][j + l].partie_reelle = 1127: ((complex16 *) tampon)[j].partie_reelle; 1128: ((complex16 **) (*((struct_matrice *) (*s_copie_argument_3) 1129: .objet)).tableau)[i][j + l].partie_imaginaire = 1130: ((complex16 *) tampon)[j].partie_imaginaire; 1131: } 1132: 1133: if (l == 0) 1134: { 1135: ((complex16 **) (*((struct_matrice *) (*s_copie_argument_3) 1136: .objet)).tableau)[i][(*((struct_matrice *) 1137: (*s_copie_argument_3).objet)).nombre_colonnes] 1138: .partie_reelle = ((complex16 **) 1139: (*((struct_matrice *) (*s_objet_argument_1).objet)) 1140: .tableau)[i][0].partie_reelle; 1141: ((complex16 **) (*((struct_matrice *) (*s_copie_argument_3) 1142: .objet)).tableau)[i][(*((struct_matrice *) 1143: (*s_copie_argument_3).objet)).nombre_colonnes] 1144: .partie_imaginaire = ((complex16 **) 1145: (*((struct_matrice *) (*s_objet_argument_1).objet)) 1146: .tableau)[i][0].partie_imaginaire; 1147: } 1148: 1149: free(tampon); 1150: } 1151: 1152: (*((struct_matrice *) (*s_copie_argument_3).objet)) 1153: .nombre_colonnes++; 1154: } 1155: } 1156: else 1157: { 1158: liberation(s_etat_processus, s_objet_argument_1); 1159: liberation(s_etat_processus, s_objet_argument_2); 1160: liberation(s_etat_processus, s_objet_argument_3); 1161: 1162: if (presence_nom == d_faux) 1163: { 1164: liberation(s_etat_processus, s_copie_argument_3); 1165: } 1166: 1167: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; 1168: return; 1169: } 1170: 1171: if (presence_nom == d_faux) 1172: { 1173: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), 1174: s_copie_argument_3) == d_erreur) 1175: { 1176: return; 1177: } 1178: } 1179: else 1180: { 1181: if (variable_partagee == d_faux) 1182: { 1183: (*(*s_etat_processus).pointeur_variable_courante).objet = 1184: s_copie_argument_3; 1185: } 1186: else 1187: { 1188: (*(*s_etat_processus).s_liste_variables_partagees).table 1189: [(*(*s_etat_processus).s_liste_variables_partagees) 1190: .position_variable].objet = s_copie_argument_3; 1191: (*(*s_etat_processus).pointeur_variable_courante).objet = NULL; 1192: 1193: if (pthread_mutex_unlock(&((*(*s_etat_processus) 1194: .s_liste_variables_partagees).mutex)) != 0) 1195: { 1196: (*s_etat_processus).erreur_systeme = d_es_processus; 1197: return; 1198: } 1199: } 1200: } 1201: 1202: liberation(s_etat_processus, s_objet_argument_1); 1203: liberation(s_etat_processus, s_objet_argument_2); 1204: liberation(s_etat_processus, s_objet_argument_3); 1205: 1206: return; 1207: } 1208: 1209: 1210: /* 1211: ================================================================================ 1212: Fonction 'col-' 1213: ================================================================================ 1214: Entrées : pointeur sur une structure struct_processus 1215: -------------------------------------------------------------------------------- 1216: Sorties : 1217: -------------------------------------------------------------------------------- 1218: Effets de bord : néant 1219: ================================================================================ 1220: */ 1221: 1222: void 1223: instruction_col_moins(struct_processus *s_etat_processus) 1224: { 1225: integer8 position; 1226: 1227: logical1 presence_variable; 1228: logical1 variable_partagee; 1229: 1230: struct_objet *s_copie_argument_2; 1231: struct_objet *s_objet_argument_1; 1232: struct_objet *s_objet_argument_2; 1233: struct_objet *s_objet_resultat; 1234: 1235: unsigned long i; 1236: unsigned long j; 1237: unsigned long k; 1238: unsigned long colonne; 1239: 1240: void *tampon; 1241: 1242: (*s_etat_processus).erreur_execution = d_ex; 1243: 1244: if ((*s_etat_processus).affichage_arguments == 'Y') 1245: { 1246: printf("\n COL- "); 1247: 1248: if ((*s_etat_processus).langue == 'F') 1249: { 1250: printf("(retrait d'une colonne dans une matrice)\n\n"); 1251: } 1252: else 1253: { 1254: printf("(remove a column from a matrix)\n\n"); 1255: } 1256: 1257: printf(" 2: %s, %s, %s\n", d_MIN, d_MRL, d_MCX); 1258: printf(" 1: %s\n", d_INT); 1259: printf("-> 2: %s, %s, %s\n\n", d_MIN, d_MRL, d_MCX); 1260: printf(" 1: %s, %s, %s\n\n", d_MIN, d_MRL, d_MCX); 1261: 1262: printf(" 2: %s\n", d_NOM); 1263: printf(" 1: %s\n", d_INT); 1264: printf("-> 1: %s, %s, %s\n", d_MIN, d_MRL, d_MCX); 1265: 1266: return; 1267: } 1268: else if ((*s_etat_processus).test_instruction == 'Y') 1269: { 1270: (*s_etat_processus).nombre_arguments = -1; 1271: return; 1272: } 1273: 1274: if (test_cfsf(s_etat_processus, 31) == d_vrai) 1275: { 1276: if (empilement_pile_last(s_etat_processus, 2) == d_erreur) 1277: { 1278: return; 1279: } 1280: } 1281: 1282: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile), 1283: &s_objet_argument_1) == d_erreur) 1284: { 1285: (*s_etat_processus).erreur_execution = d_ex_manque_argument; 1286: return; 1287: } 1288: 1289: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile), 1290: &s_objet_argument_2) == d_erreur) 1291: { 1292: liberation(s_etat_processus, s_objet_argument_1); 1293: 1294: (*s_etat_processus).erreur_execution = d_ex_manque_argument; 1295: return; 1296: } 1297: 1298: variable_partagee = d_faux; 1299: 1300: if ((*s_objet_argument_2).type == NOM) 1301: { 1302: if (recherche_variable(s_etat_processus, (*((struct_nom *) 1303: (*s_objet_argument_2).objet)).nom) == d_faux) 1304: { 1305: (*s_etat_processus).erreur_systeme = d_es; 1306: (*s_etat_processus).erreur_execution = d_ex_variable_non_definie; 1307: 1308: liberation(s_etat_processus, s_objet_argument_1); 1309: liberation(s_etat_processus, s_objet_argument_2); 1310: 1311: return; 1312: } 1313: 1314: liberation(s_etat_processus, s_objet_argument_2); 1315: 1316: if ((*(*s_etat_processus).pointeur_variable_courante) 1317: .variable_verrouillee == d_vrai) 1318: { 1319: liberation(s_etat_processus, s_objet_argument_1); 1320: 1321: (*s_etat_processus).erreur_execution = d_ex_variable_verrouillee; 1322: return; 1323: } 1324: 1325: if ((*(*s_etat_processus).pointeur_variable_courante).objet == NULL) 1326: { 1327: if (pthread_mutex_lock(&((*(*s_etat_processus) 1328: .s_liste_variables_partagees).mutex)) != 0) 1329: { 1330: (*s_etat_processus).erreur_systeme = d_es_processus; 1331: return; 1332: } 1333: 1334: if (recherche_variable_partagee(s_etat_processus, 1335: (*(*s_etat_processus).pointeur_variable_courante).nom, 1336: (*(*s_etat_processus).pointeur_variable_courante) 1337: .variable_partagee, (*(*s_etat_processus) 1338: .pointeur_variable_courante).origine) == d_faux) 1339: { 1340: (*s_etat_processus).erreur_systeme = d_es; 1341: (*s_etat_processus).erreur_execution = 1342: d_ex_variable_non_definie; 1343: 1344: if (pthread_mutex_unlock(&((*(*s_etat_processus) 1345: .s_liste_variables_partagees).mutex)) != 0) 1346: { 1347: (*s_etat_processus).erreur_systeme = d_es_processus; 1348: return; 1349: } 1350: 1351: liberation(s_etat_processus, s_objet_argument_1); 1352: return; 1353: } 1354: 1355: variable_partagee = d_vrai; 1356: s_objet_argument_2 = (*(*s_etat_processus) 1357: .s_liste_variables_partagees).table[(*(*s_etat_processus) 1358: .s_liste_variables_partagees).position_variable].objet; 1359: } 1360: else 1361: { 1362: s_objet_argument_2 = (*(*s_etat_processus) 1363: .pointeur_variable_courante).objet; 1364: } 1365: 1366: presence_variable = d_vrai; 1367: } 1368: else 1369: { 1370: presence_variable = d_faux; 1371: } 1372: 1373: if ((s_copie_argument_2 = copie_objet(s_etat_processus, 1374: s_objet_argument_2, 'Q')) == NULL) 1375: { 1376: if (variable_partagee == d_vrai) 1377: { 1378: if (pthread_mutex_unlock(&((*(*s_etat_processus) 1379: .s_liste_variables_partagees).mutex)) != 0) 1380: { 1381: (*s_etat_processus).erreur_systeme = d_es_processus; 1382: return; 1383: } 1384: } 1385: 1386: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; 1387: return; 1388: } 1389: 1390: if (((*s_copie_argument_2).type == MIN) || 1391: ((*s_copie_argument_2).type == MRL) || 1392: ((*s_copie_argument_2).type == MCX)) 1393: { 1394: if ((*s_objet_argument_1).type == INT) 1395: { 1396: position = (*((integer8 *) (*s_objet_argument_1).objet)); 1397: 1398: if ((position <= 0) || (position > (signed long) 1399: (*((struct_matrice *) 1400: (*s_copie_argument_2).objet)).nombre_colonnes)) 1401: { 1402: if (variable_partagee == d_vrai) 1403: { 1404: if (pthread_mutex_unlock(&((*(*s_etat_processus) 1405: .s_liste_variables_partagees).mutex)) != 0) 1406: { 1407: (*s_etat_processus).erreur_systeme = d_es_processus; 1408: return; 1409: } 1410: } 1411: 1412: liberation(s_etat_processus, s_objet_argument_1); 1413: liberation(s_etat_processus, s_objet_argument_2); 1414: 1415: if (presence_variable == d_faux) 1416: { 1417: liberation(s_etat_processus, s_copie_argument_2); 1418: } 1419: 1420: (*s_etat_processus).erreur_execution = 1421: d_ex_argument_invalide; 1422: return; 1423: } 1424: 1425: if ((s_objet_resultat = allocation(s_etat_processus, NON)) 1426: == NULL) 1427: { 1428: if (variable_partagee == d_vrai) 1429: { 1430: if (pthread_mutex_unlock(&((*(*s_etat_processus) 1431: .s_liste_variables_partagees).mutex)) != 0) 1432: { 1433: (*s_etat_processus).erreur_systeme = d_es_processus; 1434: return; 1435: } 1436: } 1437: 1438: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; 1439: return; 1440: } 1441: 1442: if (((*s_objet_resultat).objet = 1443: malloc(sizeof(struct_matrice))) == NULL) 1444: { 1445: if (variable_partagee == d_vrai) 1446: { 1447: if (pthread_mutex_unlock(&((*(*s_etat_processus) 1448: .s_liste_variables_partagees).mutex)) != 0) 1449: { 1450: (*s_etat_processus).erreur_systeme = d_es_processus; 1451: return; 1452: } 1453: } 1454: 1455: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; 1456: return; 1457: } 1458: 1459: (*((struct_matrice *) (*s_objet_resultat).objet)).nombre_colonnes = 1460: 1; 1461: (*((struct_matrice *) (*s_objet_resultat).objet)).nombre_lignes = 1462: (*((struct_matrice *) (*s_copie_argument_2).objet)) 1463: .nombre_lignes; 1464: (*((struct_matrice *) (*s_objet_resultat).objet)).type = 1465: (*((struct_matrice *) (*s_copie_argument_2).objet)).type; 1466: 1467: switch((*((struct_matrice *) (*s_objet_resultat).objet)).type) 1468: { 1469: case 'I' : 1470: { 1471: (*s_objet_resultat).type = MIN; 1472: 1473: if (((*((struct_matrice *) (*s_objet_resultat).objet)) 1474: .tableau = malloc((*((struct_matrice *) 1475: (*s_objet_resultat).objet)).nombre_lignes * 1476: sizeof(integer8 *))) == NULL) 1477: { 1478: if (variable_partagee == d_vrai) 1479: { 1480: if (pthread_mutex_unlock(&((*(*s_etat_processus) 1481: .s_liste_variables_partagees).mutex)) != 0) 1482: { 1483: (*s_etat_processus).erreur_systeme = 1484: d_es_processus; 1485: return; 1486: } 1487: } 1488: 1489: (*s_etat_processus).erreur_systeme = 1490: d_es_allocation_memoire; 1491: return; 1492: } 1493: 1494: for(i = 0; i < (*((struct_matrice *) (*s_objet_resultat) 1495: .objet)).nombre_lignes; i++) 1496: { 1497: if (((*((struct_matrice *) (*s_objet_resultat).objet)) 1498: .tableau[i] = malloc(sizeof(integer8))) == NULL) 1499: { 1500: if (variable_partagee == d_vrai) 1501: { 1502: if (pthread_mutex_unlock(&((*(*s_etat_processus) 1503: .s_liste_variables_partagees).mutex)) 1504: != 0) 1505: { 1506: (*s_etat_processus).erreur_systeme = 1507: d_es_processus; 1508: return; 1509: } 1510: } 1511: 1512: (*s_etat_processus).erreur_systeme = 1513: d_es_allocation_memoire; 1514: return; 1515: } 1516: 1517: } 1518: 1519: colonne = position - 1; 1520: 1521: for(i = 0; i < (*((struct_matrice *) (*s_objet_resultat) 1522: .objet)).nombre_lignes; i++) 1523: { 1524: ((integer8 **) (*((struct_matrice *) 1525: (*s_objet_resultat).objet)).tableau)[i][0] = 1526: ((integer8 **) (*((struct_matrice *) 1527: (*s_copie_argument_2).objet)) 1528: .tableau)[i][colonne]; 1529: 1530: tampon = ((integer8 **) (*((struct_matrice *) 1531: (*s_copie_argument_2).objet)).tableau)[i]; 1532: 1533: if ((((*((struct_matrice *) (*s_copie_argument_2) 1534: .objet)).tableau)[i] = malloc( 1535: ((*((struct_matrice *) (*s_copie_argument_2) 1536: .objet)).nombre_colonnes - 1) * 1537: sizeof(integer8))) == NULL) 1538: { 1539: if (variable_partagee == d_vrai) 1540: { 1541: if (pthread_mutex_unlock(&((*(*s_etat_processus) 1542: .s_liste_variables_partagees).mutex)) 1543: != 0) 1544: { 1545: (*s_etat_processus).erreur_systeme = 1546: d_es_processus; 1547: return; 1548: } 1549: } 1550: 1551: (*s_etat_processus).erreur_systeme = 1552: d_es_allocation_memoire; 1553: return; 1554: } 1555: 1556: for(j = k = 0; j < (*((struct_matrice *) 1557: (*s_copie_argument_2).objet)).nombre_colonnes 1558: - 1; j++) 1559: { 1560: if (j == colonne) 1561: { 1562: k = 1; 1563: } 1564: 1565: ((integer8 **) (*((struct_matrice *) 1566: (*s_copie_argument_2).objet)).tableau) 1567: [i][j] = ((integer8 *) tampon)[j + k]; 1568: } 1569: 1570: free(tampon); 1571: } 1572: 1573: (*((struct_matrice *) (*s_copie_argument_2).objet)) 1574: .nombre_colonnes--; 1575: break; 1576: } 1577: 1578: case 'R' : 1579: { 1580: (*s_objet_resultat).type = MRL; 1581: 1582: if (((*((struct_matrice *) (*s_objet_resultat).objet)) 1583: .tableau = malloc((*((struct_matrice *) 1584: (*s_objet_resultat).objet)).nombre_lignes * 1585: sizeof(real8 *))) == NULL) 1586: { 1587: if (variable_partagee == d_vrai) 1588: { 1589: if (pthread_mutex_unlock(&((*(*s_etat_processus) 1590: .s_liste_variables_partagees).mutex)) != 0) 1591: { 1592: (*s_etat_processus).erreur_systeme = 1593: d_es_processus; 1594: return; 1595: } 1596: } 1597: 1598: (*s_etat_processus).erreur_systeme = 1599: d_es_allocation_memoire; 1600: return; 1601: } 1602: 1603: for(i = 0; i < (*((struct_matrice *) (*s_objet_resultat) 1604: .objet)).nombre_lignes; i++) 1605: { 1606: if (((*((struct_matrice *) (*s_objet_resultat).objet)) 1607: .tableau[i] = malloc(sizeof(real8))) == NULL) 1608: { 1609: if (variable_partagee == d_vrai) 1610: { 1611: if (pthread_mutex_unlock(&((*(*s_etat_processus) 1612: .s_liste_variables_partagees).mutex)) 1613: != 0) 1614: { 1615: (*s_etat_processus).erreur_systeme = 1616: d_es_processus; 1617: return; 1618: } 1619: } 1620: 1621: (*s_etat_processus).erreur_systeme = 1622: d_es_allocation_memoire; 1623: return; 1624: } 1625: 1626: } 1627: 1628: colonne = position - 1; 1629: 1630: for(i = 0; i < (*((struct_matrice *) (*s_objet_resultat) 1631: .objet)).nombre_lignes; i++) 1632: { 1633: ((real8 **) (*((struct_matrice *) 1634: (*s_objet_resultat).objet)).tableau)[i][0] = 1635: ((real8 **) (*((struct_matrice *) 1636: (*s_copie_argument_2).objet)) 1637: .tableau)[i][colonne]; 1638: 1639: tampon = ((real8 **) (*((struct_matrice *) 1640: (*s_copie_argument_2).objet)).tableau)[i]; 1641: 1642: if ((((*((struct_matrice *) (*s_copie_argument_2) 1643: .objet)).tableau)[i] = malloc( 1644: ((*((struct_matrice *) (*s_copie_argument_2) 1645: .objet)).nombre_colonnes - 1) * 1646: sizeof(real8))) == NULL) 1647: { 1648: if (variable_partagee == d_vrai) 1649: { 1650: if (pthread_mutex_unlock(&((*(*s_etat_processus) 1651: .s_liste_variables_partagees).mutex)) 1652: != 0) 1653: { 1654: (*s_etat_processus).erreur_systeme = 1655: d_es_processus; 1656: return; 1657: } 1658: } 1659: 1660: (*s_etat_processus).erreur_systeme = 1661: d_es_allocation_memoire; 1662: return; 1663: } 1664: 1665: for(j = k = 0; j < (*((struct_matrice *) 1666: (*s_copie_argument_2).objet)).nombre_colonnes 1667: - 1; j++) 1668: { 1669: if (j == colonne) 1670: { 1671: k = 1; 1672: } 1673: 1674: ((real8 **) (*((struct_matrice *) 1675: (*s_copie_argument_2).objet)).tableau) 1676: [i][j] = ((real8 *) tampon)[j + k]; 1677: } 1678: 1679: free(tampon); 1680: } 1681: 1682: (*((struct_matrice *) (*s_copie_argument_2).objet)) 1683: .nombre_colonnes--; 1684: break; 1685: } 1686: 1687: case 'C' : 1688: { 1689: (*s_objet_resultat).type = MCX; 1690: 1691: if (((*((struct_matrice *) (*s_objet_resultat).objet)) 1692: .tableau = malloc((*((struct_matrice *) 1693: (*s_objet_resultat).objet)).nombre_lignes * 1694: sizeof(complex16 *))) == NULL) 1695: { 1696: if (variable_partagee == d_vrai) 1697: { 1698: if (pthread_mutex_unlock(&((*(*s_etat_processus) 1699: .s_liste_variables_partagees).mutex)) 1700: != 0) 1701: { 1702: (*s_etat_processus).erreur_systeme = 1703: d_es_processus; 1704: return; 1705: } 1706: } 1707: 1708: (*s_etat_processus).erreur_systeme = 1709: d_es_allocation_memoire; 1710: return; 1711: } 1712: 1713: for(i = 0; i < (*((struct_matrice *) (*s_objet_resultat) 1714: .objet)).nombre_lignes; i++) 1715: { 1716: if (((*((struct_matrice *) (*s_objet_resultat).objet)) 1717: .tableau[i] = malloc(sizeof(complex16))) 1718: == NULL) 1719: { 1720: if (variable_partagee == d_vrai) 1721: { 1722: if (pthread_mutex_unlock(&((*(*s_etat_processus) 1723: .s_liste_variables_partagees).mutex)) 1724: != 0) 1725: { 1726: (*s_etat_processus).erreur_systeme = 1727: d_es_processus; 1728: return; 1729: } 1730: } 1731: 1732: (*s_etat_processus).erreur_systeme = 1733: d_es_allocation_memoire; 1734: return; 1735: } 1736: 1737: } 1738: 1739: colonne = position - 1; 1740: 1741: for(i = 0; i < (*((struct_matrice *) (*s_objet_resultat) 1742: .objet)).nombre_lignes; i++) 1743: { 1744: ((complex16 **) (*((struct_matrice *) 1745: (*s_objet_resultat).objet)).tableau)[i][0] 1746: .partie_reelle = 1747: ((complex16 **) (*((struct_matrice *) 1748: (*s_copie_argument_2).objet)) 1749: .tableau)[i][colonne].partie_reelle; 1750: ((complex16 **) (*((struct_matrice *) 1751: (*s_objet_resultat).objet)).tableau)[i][0] 1752: .partie_imaginaire = 1753: ((complex16 **) (*((struct_matrice *) 1754: (*s_copie_argument_2).objet)) 1755: .tableau)[i][colonne].partie_imaginaire; 1756: 1757: tampon = ((complex16 **) (*((struct_matrice *) 1758: (*s_copie_argument_2).objet)).tableau)[i]; 1759: 1760: if ((((*((struct_matrice *) (*s_copie_argument_2) 1761: .objet)).tableau)[i] = malloc( 1762: ((*((struct_matrice *) (*s_copie_argument_2) 1763: .objet)).nombre_colonnes - 1) * 1764: sizeof(complex16))) == NULL) 1765: { 1766: if (variable_partagee == d_vrai) 1767: { 1768: if (pthread_mutex_unlock(&((*(*s_etat_processus) 1769: .s_liste_variables_partagees).mutex)) 1770: != 0) 1771: { 1772: (*s_etat_processus).erreur_systeme = 1773: d_es_processus; 1774: return; 1775: } 1776: } 1777: 1778: (*s_etat_processus).erreur_systeme = 1779: d_es_allocation_memoire; 1780: return; 1781: } 1782: 1783: for(j = k = 0; j < (*((struct_matrice *) 1784: (*s_copie_argument_2).objet)).nombre_colonnes 1785: - 1; j++) 1786: { 1787: if (j == colonne) 1788: { 1789: k = 1; 1790: } 1791: 1792: ((complex16 **) (*((struct_matrice *) 1793: (*s_copie_argument_2).objet)).tableau) 1794: [i][j].partie_reelle = ((complex16 *) 1795: tampon)[j + k].partie_reelle; 1796: ((complex16 **) (*((struct_matrice *) 1797: (*s_copie_argument_2).objet)).tableau) 1798: [i][j].partie_imaginaire = ((complex16 *) 1799: tampon)[j + k].partie_imaginaire; 1800: } 1801: 1802: free(tampon); 1803: } 1804: 1805: (*((struct_matrice *) (*s_copie_argument_2).objet)) 1806: .nombre_colonnes--; 1807: break; 1808: } 1809: } 1810: } 1811: else 1812: { 1813: liberation(s_etat_processus, s_objet_argument_1); 1814: liberation(s_etat_processus, s_objet_argument_2); 1815: 1816: if (presence_variable == d_faux) 1817: { 1818: liberation(s_etat_processus, s_copie_argument_2); 1819: } 1820: 1821: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; 1822: return; 1823: } 1824: } 1825: else 1826: { 1827: liberation(s_etat_processus, s_objet_argument_1); 1828: liberation(s_etat_processus, s_objet_argument_2); 1829: 1830: if (presence_variable == d_faux) 1831: { 1832: liberation(s_etat_processus, s_copie_argument_2); 1833: } 1834: 1835: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; 1836: return; 1837: } 1838: 1839: liberation(s_etat_processus, s_objet_argument_1); 1840: liberation(s_etat_processus, s_objet_argument_2); 1841: 1842: if (presence_variable == d_faux) 1843: { 1844: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), 1845: s_copie_argument_2) == d_erreur) 1846: { 1847: return; 1848: } 1849: } 1850: else 1851: { 1852: if (variable_partagee == d_faux) 1853: { 1854: (*(*s_etat_processus).pointeur_variable_courante).objet = 1855: s_copie_argument_2; 1856: } 1857: else 1858: { 1859: (*(*s_etat_processus).s_liste_variables_partagees).table 1860: [(*(*s_etat_processus).s_liste_variables_partagees) 1861: .position_variable].objet = s_copie_argument_2; 1862: (*(*s_etat_processus).pointeur_variable_courante).objet = NULL; 1863: 1864: if (pthread_mutex_unlock(&((*(*s_etat_processus) 1865: .s_liste_variables_partagees).mutex)) != 0) 1866: { 1867: (*s_etat_processus).erreur_systeme = d_es_processus; 1868: return; 1869: } 1870: } 1871: } 1872: 1873: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), 1874: s_objet_resultat) == d_erreur) 1875: { 1876: return; 1877: } 1878: 1879: return; 1880: } 1881: 1882: // vim: ts=4