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