1: /*
2: ================================================================================
3: RPL/2 (R) version 4.1.36
4: Copyright (C) 1989-2025 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 'legv'
29: ================================================================================
30: Entrées : pointeur sur une structure struct_processus
31: --------------------------------------------------------------------------------
32: Sorties :
33: --------------------------------------------------------------------------------
34: Effets de bord : néant
35: ================================================================================
36: */
37:
38: void
39: instruction_legv(struct_processus *s_etat_processus)
40: {
41: struct_objet *s_objet_argument;
42: struct_objet *s_objet_resultat_1;
43: struct_objet *s_objet_resultat_2;
44:
45: (*s_etat_processus).erreur_execution = d_ex;
46:
47: if ((*s_etat_processus).affichage_arguments == 'Y')
48: {
49: printf("\n LEGV ");
50:
51: if ((*s_etat_processus).langue == 'F')
52: {
53: printf("(valeurs et vecteurs propres gauches)\n\n");
54: }
55: else
56: {
57: printf("(eigenvalues and left eigenvectors)\n\n");
58: }
59:
60: printf(" 1: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
61: printf("-> 2: %s\n", d_MCX);
62: printf(" 1: %s\n", d_VCX);
63:
64: return;
65: }
66: else if ((*s_etat_processus).test_instruction == 'Y')
67: {
68: (*s_etat_processus).nombre_arguments = -1;
69: return;
70: }
71:
72: if (test_cfsf(s_etat_processus, 31) == d_vrai)
73: {
74: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
75: {
76: return;
77: }
78: }
79:
80: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
81: &s_objet_argument) == d_erreur)
82: {
83: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
84: return;
85: }
86:
87: /*
88: --------------------------------------------------------------------------------
89: L'argument est une matrice carrée
90: --------------------------------------------------------------------------------
91: */
92:
93: if (((*s_objet_argument).type == MIN) ||
94: ((*s_objet_argument).type == MRL) ||
95: ((*s_objet_argument).type == MCX))
96: {
97: if ((*((struct_matrice *) (*s_objet_argument).objet)).nombre_lignes !=
98: (*((struct_matrice *) (*s_objet_argument).objet))
99: .nombre_colonnes)
100: {
101: liberation(s_etat_processus, s_objet_argument);
102:
103: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
104: return;
105: }
106:
107: if ((s_objet_resultat_1 = allocation(s_etat_processus, VCX)) == NULL)
108: {
109: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
110: return;
111: }
112:
113: if ((s_objet_resultat_2 = allocation(s_etat_processus, MCX)) == NULL)
114: {
115: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
116: return;
117: }
118:
119: valeurs_propres(s_etat_processus,
120: (struct_matrice *) (*s_objet_argument).objet,
121: (struct_vecteur *) (*s_objet_resultat_1).objet,
122: (struct_matrice *) (*s_objet_resultat_2).objet, NULL);
123:
124: if ((*s_etat_processus).erreur_systeme != d_es)
125: {
126: return;
127: }
128:
129: if (((*s_etat_processus).exception != d_ep) ||
130: ((*s_etat_processus).erreur_execution != d_ex))
131: {
132: liberation(s_etat_processus, s_objet_argument);
133: liberation(s_etat_processus, s_objet_resultat_1);
134: liberation(s_etat_processus, s_objet_resultat_2);
135: return;
136: }
137: }
138:
139: /*
140: --------------------------------------------------------------------------------
141: Type incompatible
142: --------------------------------------------------------------------------------
143: */
144:
145: else
146: {
147: liberation(s_etat_processus, s_objet_argument);
148:
149: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
150: return;
151: }
152:
153: liberation(s_etat_processus, s_objet_argument);
154:
155: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
156: s_objet_resultat_2) == d_erreur)
157: {
158: return;
159: }
160:
161: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
162: s_objet_resultat_1) == d_erreur)
163: {
164: return;
165: }
166:
167: return;
168: }
169:
170:
171: /*
172: ================================================================================
173: Fonction 'lsq'
174: ================================================================================
175: Entrées : pointeur sur une structure struct_processus
176: --------------------------------------------------------------------------------
177: Sorties :
178: --------------------------------------------------------------------------------
179: Effets de bord : néant
180: ================================================================================
181: */
182:
183: void
184: instruction_lsq(struct_processus *s_etat_processus)
185: {
186: struct_objet *s_objet_argument_1;
187: struct_objet *s_objet_argument_2;
188: struct_objet *s_objet_resultat;
189:
190: struct_matrice s_matrice_tampon_b;
191: struct_matrice s_matrice_tampon_x;
192:
193: integer8 i;
194:
195: (*s_etat_processus).erreur_execution = d_ex;
196:
197: if ((*s_etat_processus).affichage_arguments == 'Y')
198: {
199: printf("\n LSQ ");
200:
201: if ((*s_etat_processus).langue == 'F')
202: {
203: printf("(moindres carrés)\n\n");
204: }
205: else
206: {
207: printf("(least squares)\n\n");
208: }
209:
210: printf(" 2: %s, %s\n", d_VIN, d_VRL);
211: printf(" 1: %s, %s\n", d_MIN, d_MRL);
212: printf("-> 1: %s\n\n", d_VRL);
213:
214: printf(" 2: %s, %s, %s\n", d_VIN, d_VRL, d_VCX);
215: printf(" 1: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
216: printf("-> 1: %s\n\n", d_VCX);
217:
218: printf(" 2: %s, %s\n", d_MIN, d_MRL);
219: printf(" 1: %s, %s\n", d_MIN, d_MRL);
220: printf("-> 1: %s\n\n", d_MRL);
221:
222: printf(" 2: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
223: printf(" 1: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
224: printf("-> 1: %s\n", d_MCX);
225:
226: return;
227: }
228: else if ((*s_etat_processus).test_instruction == 'Y')
229: {
230: (*s_etat_processus).nombre_arguments = -1;
231: return;
232: }
233:
234: if (test_cfsf(s_etat_processus, 31) == d_vrai)
235: {
236: if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
237: {
238: return;
239: }
240: }
241:
242: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
243: &s_objet_argument_1) == d_erreur)
244: {
245: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
246: return;
247: }
248:
249: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
250: &s_objet_argument_2) == d_erreur)
251: {
252: liberation(s_etat_processus, s_objet_argument_1);
253:
254: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
255: return;
256: }
257:
258: /*
259: --------------------------------------------------------------------------------
260: Vecteur et matrice
261: --------------------------------------------------------------------------------
262: */
263:
264: /*
265: * Résultat réel
266: */
267:
268: if ((((*s_objet_argument_1).type == MIN) ||
269: ((*s_objet_argument_1).type == MRL)) &&
270: (((*s_objet_argument_2).type == VIN) ||
271: ((*s_objet_argument_2).type == VRL)))
272: {
273: if ((*((struct_vecteur *) (*s_objet_argument_2).objet)).taille !=
274: (*((struct_matrice *) (*s_objet_argument_1).objet))
275: .nombre_lignes)
276: {
277: liberation(s_etat_processus, s_objet_argument_1);
278: liberation(s_etat_processus, s_objet_argument_2);
279:
280: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
281: return;
282: }
283:
284: if ((*s_objet_argument_2).type == VIN)
285: {
286: s_matrice_tampon_b.type = 'I';
287: s_matrice_tampon_b.nombre_lignes = (*((struct_vecteur *)
288: (*s_objet_argument_2).objet)).taille;
289: s_matrice_tampon_b.nombre_colonnes = 1;
290:
291: if ((s_matrice_tampon_b.tableau = malloc(((size_t)
292: s_matrice_tampon_b.nombre_lignes) *
293: sizeof(integer8 *))) == NULL)
294: {
295: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
296: return;
297: }
298:
299: for(i = 0; i < s_matrice_tampon_b.nombre_lignes; i++)
300: {
301: if ((((integer8 **) s_matrice_tampon_b.tableau)[i] =
302: malloc(sizeof(integer8))) == NULL)
303: {
304: (*s_etat_processus).erreur_systeme =
305: d_es_allocation_memoire;
306: return;
307: }
308:
309: ((integer8 **) s_matrice_tampon_b.tableau)[i][0] =
310: ((integer8 *) (*((struct_vecteur *)
311: (*s_objet_argument_2).objet)).tableau)[i];
312: }
313: }
314: else
315: {
316: s_matrice_tampon_b.type = 'R';
317: s_matrice_tampon_b.nombre_lignes = (*((struct_vecteur *)
318: (*s_objet_argument_2).objet)).taille;
319: s_matrice_tampon_b.nombre_colonnes = 1;
320:
321: if ((s_matrice_tampon_b.tableau = malloc(((size_t)
322: s_matrice_tampon_b.nombre_lignes) * sizeof(real8 *)))
323: == NULL)
324: {
325: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
326: return;
327: }
328:
329: for(i = 0; i < s_matrice_tampon_b.nombre_lignes; i++)
330: {
331: if ((((real8 **) s_matrice_tampon_b.tableau)[i] =
332: malloc(sizeof(real8))) == NULL)
333: {
334: (*s_etat_processus).erreur_systeme =
335: d_es_allocation_memoire;
336: return;
337: }
338:
339: ((real8 **) s_matrice_tampon_b.tableau)[i][0] =
340: ((real8 *) (*((struct_vecteur *)
341: (*s_objet_argument_2).objet)).tableau)[i];
342: }
343: }
344:
345: moindres_carres(s_etat_processus,
346: (struct_matrice *) (*s_objet_argument_1).objet,
347: &s_matrice_tampon_b, &s_matrice_tampon_x);
348:
349: if ((*s_objet_argument_2).type == VIN)
350: {
351: for(i = 0; i < s_matrice_tampon_b.nombre_lignes; i++)
352: {
353: free(((integer8 **) s_matrice_tampon_b.tableau)[i]);
354: }
355: }
356: else
357: {
358: for(i = 0; i < s_matrice_tampon_b.nombre_lignes; i++)
359: {
360: free(((real8 **) s_matrice_tampon_b.tableau)[i]);
361: }
362: }
363:
364: free(s_matrice_tampon_b.tableau);
365:
366: if ((*s_etat_processus).erreur_systeme != d_es)
367: {
368: return;
369: }
370:
371: if (((*s_etat_processus).exception != d_ep) ||
372: ((*s_etat_processus).erreur_execution != d_ex))
373: {
374: liberation(s_etat_processus, s_objet_argument_1);
375: liberation(s_etat_processus, s_objet_argument_2);
376: return;
377: }
378:
379: if ((s_objet_resultat = allocation(s_etat_processus, VRL)) == NULL)
380: {
381: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
382: return;
383: }
384:
385: (*((struct_vecteur *) (*s_objet_resultat).objet)).taille =
386: s_matrice_tampon_x.nombre_lignes;
387:
388: if (((*((struct_vecteur *) (*s_objet_resultat).objet)).tableau =
389: malloc(((size_t) (*((struct_vecteur *) (*s_objet_resultat)
390: .objet)).taille) * sizeof(real8))) == NULL)
391: {
392: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
393: return;
394: }
395:
396: for(i = 0; i < (*((struct_vecteur *) (*s_objet_resultat).objet)).taille;
397: i++)
398: {
399: ((real8 *) (*((struct_vecteur *) (*s_objet_resultat).objet))
400: .tableau)[i] = ((real8 **) s_matrice_tampon_x.tableau)
401: [i][0];
402: free(((real8 **) s_matrice_tampon_x.tableau)[i]);
403: }
404:
405: free(s_matrice_tampon_x.tableau);
406: }
407:
408: /*
409: * Résultat complexe
410: */
411:
412: else if ((((*s_objet_argument_1).type == MCX) &&
413: (((*s_objet_argument_2).type == VIN) ||
414: ((*s_objet_argument_2).type == VRL) ||
415: ((*s_objet_argument_2).type == VCX))) ||
416: (((*s_objet_argument_2).type == VCX) &&
417: (((*s_objet_argument_1).type == MIN) ||
418: ((*s_objet_argument_1).type == MRL))))
419: {
420: if ((*((struct_vecteur *) (*s_objet_argument_2).objet)).taille !=
421: (*((struct_matrice *) (*s_objet_argument_1).objet))
422: .nombre_lignes)
423: {
424: liberation(s_etat_processus, s_objet_argument_1);
425: liberation(s_etat_processus, s_objet_argument_2);
426:
427: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
428: return;
429: }
430:
431: if ((*s_objet_argument_2).type == VIN)
432: {
433: s_matrice_tampon_b.type = 'I';
434: s_matrice_tampon_b.nombre_lignes = (*((struct_vecteur *)
435: (*s_objet_argument_2).objet)).taille;
436: s_matrice_tampon_b.nombre_colonnes = 1;
437:
438: if ((s_matrice_tampon_b.tableau = malloc(((size_t)
439: s_matrice_tampon_b.nombre_lignes) * sizeof(integer8 *)))
440: == NULL)
441: {
442: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
443: return;
444: }
445:
446: for(i = 0; i < s_matrice_tampon_b.nombre_lignes; i++)
447: {
448: if ((((integer8 **) s_matrice_tampon_b.tableau)[i] =
449: malloc(sizeof(integer8))) == NULL)
450: {
451: (*s_etat_processus).erreur_systeme =
452: d_es_allocation_memoire;
453: return;
454: }
455:
456: ((integer8 **) s_matrice_tampon_b.tableau)[i][0] =
457: ((integer8 *) (*((struct_vecteur *)
458: (*s_objet_argument_2).objet)).tableau)[i];
459: }
460: }
461: else if ((*s_objet_argument_2).type == VRL)
462: {
463: s_matrice_tampon_b.type = 'R';
464: s_matrice_tampon_b.nombre_lignes = (*((struct_vecteur *)
465: (*s_objet_argument_2).objet)).taille;
466: s_matrice_tampon_b.nombre_colonnes = 1;
467:
468: if ((s_matrice_tampon_b.tableau = malloc(((size_t)
469: s_matrice_tampon_b.nombre_lignes) * sizeof(real8 *)))
470: == NULL)
471: {
472: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
473: return;
474: }
475:
476: for(i = 0; i < s_matrice_tampon_b.nombre_lignes; i++)
477: {
478: if ((((real8 **) s_matrice_tampon_b.tableau)[i] =
479: malloc(sizeof(real8))) == NULL)
480: {
481: (*s_etat_processus).erreur_systeme =
482: d_es_allocation_memoire;
483: return;
484: }
485:
486: ((real8 **) s_matrice_tampon_b.tableau)[i][0] =
487: ((real8 *) (*((struct_vecteur *)
488: (*s_objet_argument_2).objet)).tableau)[i];
489: }
490: }
491: else
492: {
493: s_matrice_tampon_b.type = 'C';
494: s_matrice_tampon_b.nombre_lignes = (*((struct_vecteur *)
495: (*s_objet_argument_2).objet)).taille;
496: s_matrice_tampon_b.nombre_colonnes = 1;
497:
498: if ((s_matrice_tampon_b.tableau = malloc(((size_t)
499: s_matrice_tampon_b.nombre_lignes) *
500: sizeof(struct_complexe16 *))) == NULL)
501: {
502: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
503: return;
504: }
505:
506: for(i = 0; i < s_matrice_tampon_b.nombre_lignes; i++)
507: {
508: if ((((struct_complexe16 **) s_matrice_tampon_b.tableau)[i] =
509: malloc(sizeof(struct_complexe16))) == NULL)
510: {
511: (*s_etat_processus).erreur_systeme =
512: d_es_allocation_memoire;
513: return;
514: }
515:
516: ((struct_complexe16 **) s_matrice_tampon_b.tableau)[i][0]
517: .partie_reelle = ((struct_complexe16 *)
518: (*((struct_vecteur *) (*s_objet_argument_2).objet))
519: .tableau)[i].partie_reelle;
520: ((struct_complexe16 **) s_matrice_tampon_b.tableau)[i][0]
521: .partie_imaginaire = ((struct_complexe16 *)
522: (*((struct_vecteur *) (*s_objet_argument_2).objet))
523: .tableau)[i].partie_imaginaire;
524: }
525: }
526:
527: moindres_carres(s_etat_processus,
528: (struct_matrice *) (*s_objet_argument_1).objet,
529: &s_matrice_tampon_b, &s_matrice_tampon_x);
530:
531: if ((*s_objet_argument_2).type == VIN)
532: {
533: for(i = 0; i < s_matrice_tampon_b.nombre_lignes; i++)
534: {
535: free(((integer8 **) s_matrice_tampon_b.tableau)[i]);
536: }
537: }
538: else if ((*s_objet_argument_2).type == VRL)
539: {
540: for(i = 0; i < s_matrice_tampon_b.nombre_lignes; i++)
541: {
542: free(((real8 **) s_matrice_tampon_b.tableau)[i]);
543: }
544: }
545: else
546: {
547: for(i = 0; i < s_matrice_tampon_b.nombre_lignes; i++)
548: {
549: free(((struct_complexe16 **) s_matrice_tampon_b.tableau)[i]);
550: }
551: }
552:
553: free(s_matrice_tampon_b.tableau);
554:
555: if ((*s_etat_processus).erreur_systeme != d_es)
556: {
557: return;
558: }
559:
560: if (((*s_etat_processus).exception != d_ep) ||
561: ((*s_etat_processus).erreur_execution != d_ex))
562: {
563: liberation(s_etat_processus, s_objet_argument_1);
564: liberation(s_etat_processus, s_objet_argument_2);
565: return;
566: }
567:
568: if ((s_objet_resultat = allocation(s_etat_processus, VCX)) == NULL)
569: {
570: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
571: return;
572: }
573:
574: (*((struct_vecteur *) (*s_objet_resultat).objet)).taille =
575: s_matrice_tampon_x.nombre_lignes;
576:
577: if (((*((struct_vecteur *) (*s_objet_resultat).objet)).tableau =
578: malloc(((size_t) (*((struct_vecteur *) (*s_objet_resultat)
579: .objet)).taille) * sizeof(struct_complexe16))) == NULL)
580: {
581: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
582: return;
583: }
584:
585: for(i = 0; i < (*((struct_vecteur *) (*s_objet_resultat).objet)).taille;
586: i++)
587: {
588: ((struct_complexe16 *) (*((struct_vecteur *) (*s_objet_resultat)
589: .objet)).tableau)[i].partie_reelle = ((struct_complexe16 **)
590: s_matrice_tampon_x.tableau)[i][0].partie_reelle;
591: ((struct_complexe16 *) (*((struct_vecteur *) (*s_objet_resultat)
592: .objet)).tableau)[i].partie_imaginaire =
593: ((struct_complexe16 **) s_matrice_tampon_x.tableau)[i][0]
594: .partie_imaginaire;
595: free(((real8 **) s_matrice_tampon_x.tableau)[i]);
596: }
597:
598: free(s_matrice_tampon_x.tableau);
599: }
600:
601: /*
602: --------------------------------------------------------------------------------
603: Matrices
604: --------------------------------------------------------------------------------
605: */
606:
607: /*
608: * Résultat réel
609: */
610:
611: else if ((((*s_objet_argument_1).type == MIN) ||
612: ((*s_objet_argument_1).type == MRL)) &&
613: (((*s_objet_argument_2).type == MIN) ||
614: ((*s_objet_argument_2).type == MRL)))
615: {
616: if ((*((struct_matrice *) (*s_objet_argument_2).objet)).nombre_lignes !=
617: (*((struct_matrice *) (*s_objet_argument_1).objet))
618: .nombre_lignes)
619: {
620: liberation(s_etat_processus, s_objet_argument_1);
621: liberation(s_etat_processus, s_objet_argument_2);
622:
623: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
624: return;
625: }
626:
627: moindres_carres(s_etat_processus,
628: (struct_matrice *) (*s_objet_argument_1).objet,
629: (struct_matrice *) (*s_objet_argument_2).objet,
630: &s_matrice_tampon_x);
631:
632: if ((*s_etat_processus).erreur_systeme != d_es)
633: {
634: return;
635: }
636:
637: if (((*s_etat_processus).exception != d_ep) ||
638: ((*s_etat_processus).erreur_execution != d_ex))
639: {
640: liberation(s_etat_processus, s_objet_argument_1);
641: liberation(s_etat_processus, s_objet_argument_2);
642: return;
643: }
644:
645: if ((s_objet_resultat = allocation(s_etat_processus, MRL)) == NULL)
646: {
647: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
648: return;
649: }
650:
651: (*((struct_matrice *) (*s_objet_resultat).objet)).nombre_lignes =
652: s_matrice_tampon_x.nombre_lignes;
653: (*((struct_matrice *) (*s_objet_resultat).objet)).nombre_colonnes =
654: s_matrice_tampon_x.nombre_colonnes;
655: (*((struct_matrice *) (*s_objet_resultat).objet)).tableau =
656: s_matrice_tampon_x.tableau;
657: }
658:
659: /*
660: * Résultat complexe
661: */
662:
663: else if ((((*s_objet_argument_1).type == MCX) &&
664: (((*s_objet_argument_2).type == MIN) ||
665: ((*s_objet_argument_2).type == MRL) ||
666: ((*s_objet_argument_2).type == MCX))) ||
667: (((*s_objet_argument_2).type == MCX) &&
668: (((*s_objet_argument_1).type == MIN) ||
669: ((*s_objet_argument_1).type == MRL))))
670: {
671: if ((*((struct_matrice *) (*s_objet_argument_2).objet)).nombre_lignes !=
672: (*((struct_matrice *) (*s_objet_argument_1).objet))
673: .nombre_lignes)
674: {
675: liberation(s_etat_processus, s_objet_argument_1);
676: liberation(s_etat_processus, s_objet_argument_2);
677:
678: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
679: return;
680: }
681:
682: moindres_carres(s_etat_processus,
683: (struct_matrice *) (*s_objet_argument_1).objet,
684: (struct_matrice *) (*s_objet_argument_2).objet,
685: &s_matrice_tampon_x);
686:
687: if ((*s_etat_processus).erreur_systeme != d_es)
688: {
689: return;
690: }
691:
692: if (((*s_etat_processus).exception != d_ep) ||
693: ((*s_etat_processus).erreur_execution != d_ex))
694: {
695: liberation(s_etat_processus, s_objet_argument_1);
696: liberation(s_etat_processus, s_objet_argument_2);
697: return;
698: }
699:
700: if ((s_objet_resultat = allocation(s_etat_processus, MCX)) == NULL)
701: {
702: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
703: return;
704: }
705:
706: (*((struct_matrice *) (*s_objet_resultat).objet)).nombre_lignes =
707: s_matrice_tampon_x.nombre_lignes;
708: (*((struct_matrice *) (*s_objet_resultat).objet)).nombre_colonnes =
709: s_matrice_tampon_x.nombre_colonnes;
710: (*((struct_matrice *) (*s_objet_resultat).objet)).tableau =
711: s_matrice_tampon_x.tableau;
712: }
713:
714: /*
715: --------------------------------------------------------------------------------
716: Types icompatibles avec la fonction LSQ
717: --------------------------------------------------------------------------------
718: */
719:
720: else
721: {
722: liberation(s_etat_processus, s_objet_argument_1);
723: liberation(s_etat_processus, s_objet_argument_2);
724:
725: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
726: return;
727: }
728:
729: liberation(s_etat_processus, s_objet_argument_1);
730: liberation(s_etat_processus, s_objet_argument_2);
731:
732: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
733: s_objet_resultat) == d_erreur)
734: {
735: return;
736: }
737:
738: return;
739: }
740:
741:
742: /*
743: ================================================================================
744: Fonction 'logscale'
745: ================================================================================
746: Entrées : pointeur sur une structure struct_processus
747: --------------------------------------------------------------------------------
748: Sorties :
749: --------------------------------------------------------------------------------
750: Effets de bord : néant
751: ================================================================================
752: */
753:
754: void
755: instruction_logscale(struct_processus *s_etat_processus)
756: {
757: logical1 presence[3];
758: logical1 systeme_auxiliaire;
759: logical1 systeme_principal;
760:
761: struct_liste_chainee *l_element_courant;
762:
763: struct_objet *s_objet;
764:
765: unsigned char *tampon;
766:
767: (*s_etat_processus).erreur_execution = d_ex;
768:
769: if ((*s_etat_processus).affichage_arguments == 'Y')
770: {
771: printf("\n LOGSCALE ");
772:
773: if ((*s_etat_processus).langue == 'F')
774: {
775: printf("(définition des axes)\n\n");
776: }
777: else
778: {
779: printf("(definitions of axes)\n\n");
780: }
781:
782: printf(" 1: %s\n\n", d_LST);
783:
784: printf(" 1: %s\n", d_NOM);
785:
786: if ((*s_etat_processus).langue == 'F')
787: {
788: printf(" Utilisation :\n\n");
789: }
790: else
791: {
792: printf(" Usage:\n\n");
793: }
794:
795: printf(" { X Z } LOGSCALE\n");
796: printf(" 'Y' LOGSCALE\n");
797:
798: return;
799: }
800: else if ((*s_etat_processus).test_instruction == 'Y')
801: {
802: (*s_etat_processus).nombre_arguments = -1;
803: return;
804: }
805:
806: if ((*s_etat_processus).l_base_pile == NULL)
807: {
808: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
809: return;
810: }
811:
812: if (test_cfsf(s_etat_processus, 31) == d_vrai)
813: {
814: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
815: {
816: return;
817: }
818: }
819:
820: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
821: &s_objet) == d_erreur)
822: {
823: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
824: return;
825: }
826:
827: if ((*s_objet).type == NOM)
828: {
829: tampon = conversion_majuscule(s_etat_processus,
830: (*((struct_nom *) (*s_objet).objet)).nom);
831:
832: if (tampon == NULL)
833: {
834: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
835: return;
836: }
837:
838: if ((strcmp(tampon, "X") != 0) && (strcmp(tampon, "Y") != 0) &&
839: (strcmp(tampon, "Z") != 0))
840: {
841: liberation(s_etat_processus, s_objet);
842:
843: free(tampon);
844:
845: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
846: return;
847: }
848:
849: if (tampon[0] == 'X')
850: {
851: (*s_etat_processus).echelle_log_x = d_vrai;
852: }
853: else if (tampon[0] == 'Y')
854: {
855: (*s_etat_processus).echelle_log_y = d_vrai;
856: }
857: else
858: {
859: (*s_etat_processus).echelle_log_z = d_vrai;
860: }
861:
862: free(tampon);
863: }
864: else if ((*s_objet).type == LST)
865: {
866: if ((*s_etat_processus).systeme_axes == 0)
867: {
868: systeme_principal = d_vrai;
869: systeme_auxiliaire = d_faux;
870: }
871: else
872: {
873: systeme_principal = d_faux;
874: systeme_auxiliaire = d_vrai;
875: }
876:
877: presence[0] = d_faux;
878: presence[1] = d_faux;
879: presence[2] = d_faux;
880:
881: l_element_courant = (struct_liste_chainee *) (*s_objet).objet;
882:
883: if (l_element_courant == NULL)
884: {
885: if (systeme_principal == d_vrai)
886: {
887: (*s_etat_processus).echelle_log_x = d_faux;
888: (*s_etat_processus).echelle_log_y = d_faux;
889: (*s_etat_processus).echelle_log_z = d_faux;
890: }
891: else
892: {
893: (*s_etat_processus).echelle_log_x2 = d_faux;
894: (*s_etat_processus).echelle_log_y2 = d_faux;
895: (*s_etat_processus).echelle_log_z2 = d_faux;
896: }
897: }
898: else
899: {
900: while(l_element_courant != NULL)
901: {
902: if ((*(*l_element_courant).donnee).type != NOM)
903: {
904: liberation(s_etat_processus, s_objet);
905:
906: (*s_etat_processus).erreur_execution =
907: d_ex_argument_invalide;
908: return;
909: }
910:
911: tampon = conversion_majuscule(s_etat_processus,
912: (*((struct_nom *) (*(*l_element_courant).donnee)
913: .objet)).nom);
914:
915: if ((strcmp(tampon, "X") != 0) && (strcmp(tampon, "Y") != 0) &&
916: (strcmp(tampon, "Z") != 0))
917: {
918: liberation(s_etat_processus, s_objet);
919: free(tampon);
920:
921: (*s_etat_processus).erreur_execution =
922: d_ex_argument_invalide;
923: return;
924: }
925:
926: if (tampon[0] == 'X')
927: {
928: if (presence[0] == d_vrai)
929: {
930: liberation(s_etat_processus, s_objet);
931: free(tampon);
932:
933: (*s_etat_processus).erreur_execution =
934: d_ex_argument_invalide;
935: return;
936: }
937:
938: if (systeme_principal == d_vrai)
939: {
940: (*s_etat_processus).echelle_log_x = d_vrai;
941: }
942:
943: if (systeme_auxiliaire == d_vrai)
944: {
945: (*s_etat_processus).echelle_log_x2 = d_vrai;
946: }
947:
948: presence[0] = d_vrai;
949: }
950: else if (tampon[0] == 'Y')
951: {
952: if (presence[1] == d_vrai)
953: {
954: liberation(s_etat_processus, s_objet);
955: free(tampon);
956:
957: (*s_etat_processus).erreur_execution =
958: d_ex_argument_invalide;
959: return;
960: }
961:
962: if (systeme_principal == d_vrai)
963: {
964: (*s_etat_processus).echelle_log_y = d_vrai;
965: }
966:
967: if (systeme_auxiliaire == d_vrai)
968: {
969: (*s_etat_processus).echelle_log_y2 = d_vrai;
970: }
971:
972: presence[1] = d_vrai;
973: }
974: else
975: {
976: if (presence[2] == d_vrai)
977: {
978: liberation(s_etat_processus, s_objet);
979: free(tampon);
980:
981: (*s_etat_processus).erreur_execution =
982: d_ex_argument_invalide;
983: return;
984: }
985:
986: if (systeme_principal == d_vrai)
987: {
988: (*s_etat_processus).echelle_log_z = d_vrai;
989: }
990:
991: if (systeme_auxiliaire == d_vrai)
992: {
993: (*s_etat_processus).echelle_log_z2 = d_vrai;
994: }
995:
996: presence[2] = d_vrai;
997: }
998:
999: l_element_courant = (*l_element_courant).suivant;
1000: free(tampon);
1001: }
1002: }
1003: }
1004: else
1005: {
1006: liberation(s_etat_processus, s_objet);
1007:
1008: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1009: return;
1010: }
1011:
1012: liberation(s_etat_processus, s_objet);
1013:
1014: if (test_cfsf(s_etat_processus, 52) == d_faux)
1015: {
1016: if ((*s_etat_processus).fichiers_graphiques != NULL)
1017: {
1018: appel_gnuplot(s_etat_processus, 'N');
1019: }
1020: }
1021:
1022: return;
1023: }
1024:
1025: // vim: ts=4
CVSweb interface <joel.bertrand@systella.fr>