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