/* ================================================================================ RPL/2 (R) version 4.1.22 Copyright (C) 1989-2015 Dr. BERTRAND Joël This file is part of RPL/2. RPL/2 is free software; you can redistribute it and/or modify it under the terms of the CeCILL V2 License as published by the french CEA, CNRS and INRIA. RPL/2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL V2 License for more details. You should have received a copy of the CeCILL License along with RPL/2. If not, write to info@cecill.info. ================================================================================ */ #include "rpl-conv.h" /* ================================================================================ Fonction 's+' ================================================================================ Entrées : structure processus -------------------------------------------------------------------------------- Sorties : -------------------------------------------------------------------------------- Effets de bord : néant ================================================================================ */ void instruction_s_plus(struct_processus *s_etat_processus) { logical1 creation_variable_sigma; struct_objet *s_copie; struct_objet *s_copie_statistique; struct_objet *s_objet; struct_objet *s_objet_statistique; struct_variable s_variable; integer8 i; integer8 j; integer8 k; integer8 nombre_colonnes; integer8 nombre_lignes; void *tampon; (*s_etat_processus).erreur_execution = d_ex; if ((*s_etat_processus).affichage_arguments == 'Y') { printf("\n S+ "); if ((*s_etat_processus).langue == 'F') { printf("(ajout d'une donnée dans la matrice statistique)\n\n"); } else { printf("(add a data value in statistical matrix)\n\n"); } printf(" 1: %s, %s, %s, %s, %s, %s\n", d_INT, d_REL, d_VIN, d_VRL, d_MIN, d_MRL); return; } else if ((*s_etat_processus).test_instruction == 'Y') { (*s_etat_processus).nombre_arguments = -1; return; } if (test_cfsf(s_etat_processus, 31) == d_vrai) { if (empilement_pile_last(s_etat_processus, 1) == d_erreur) { return; } } /* * Recherche d'une variable globale référencée par SIGMA */ if (recherche_variable_globale(s_etat_processus, ds_sdat) == d_faux) { /* * Aucune variable SIGMA, donc il faut la créer en fonction * de l'objet à introduire. */ (*s_etat_processus).erreur_systeme = d_es; creation_variable_sigma = d_vrai; nombre_colonnes = 0; } else { creation_variable_sigma = d_faux; if ((*(*s_etat_processus).pointeur_variable_courante) .variable_verrouillee == d_vrai) { (*s_etat_processus).erreur_execution = d_ex_variable_verrouillee; return; } if (((*(*(*s_etat_processus).pointeur_variable_courante).objet) .type != MIN) && ((*(*(*s_etat_processus) .pointeur_variable_courante).objet).type != MRL)) { (*s_etat_processus).erreur_execution = d_ex_matrice_statistique_invalide; return; } if ((s_copie_statistique = copie_objet(s_etat_processus, (*(*s_etat_processus).pointeur_variable_courante).objet, 'Q')) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } liberation(s_etat_processus, (*(*s_etat_processus) .pointeur_variable_courante).objet); (*(*s_etat_processus).pointeur_variable_courante).objet = s_copie_statistique; nombre_colonnes = (*((struct_matrice *) (*(*(*s_etat_processus) .pointeur_variable_courante).objet).objet)).nombre_colonnes; } if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile), &s_objet) == d_erreur) { (*s_etat_processus).erreur_execution = d_ex_manque_argument; return; } if ((s_copie = copie_objet(s_etat_processus, s_objet, 'O')) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } liberation(s_etat_processus, s_objet); s_objet = s_copie; /* * Ajout d'un scalaire */ if (((*s_objet).type == INT) || ((*s_objet).type == REL)) { if (creation_variable_sigma == d_vrai) { /* * Création d'une matrice statistique 1*1 */ if ((s_variable.nom = malloc(6 * sizeof(unsigned char))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } strcpy(s_variable.nom, ds_sdat); s_variable.niveau = 1; if ((*s_objet).type == INT) { if ((s_objet_statistique = allocation(s_etat_processus, MIN)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } if (((*((struct_matrice *) (*s_objet_statistique).objet)) .tableau = malloc(sizeof(integer8 *))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } ((integer8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[0] = (integer8 *) (*s_objet).objet; } else { if ((s_objet_statistique = allocation(s_etat_processus, MRL)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } if (((*((struct_matrice *) (*s_objet_statistique).objet)) .tableau = malloc(sizeof(real8 *))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } ((real8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[0] = (real8 *) (*s_objet).objet; } (*((struct_matrice *) (*s_objet_statistique).objet)) .nombre_colonnes = 1; (*((struct_matrice *) (*s_objet_statistique).objet)) .nombre_lignes = 1; free(s_objet); s_objet = NULL; s_variable.objet = s_objet_statistique; if (creation_variable(s_etat_processus, &s_variable, 'V', 'P') == d_erreur) { return; } } else { /* * La variable existe déjà, il faut lui rajouter une ligne. */ if (nombre_colonnes != 1) { (*s_etat_processus).erreur_execution = d_ex_dimensions_matrice_statistique; liberation(s_etat_processus, s_objet); return; } s_objet_statistique = (*(*s_etat_processus) .pointeur_variable_courante).objet; if (((*s_objet_statistique).type == MIN) && ((*s_objet).type == INT)) { tampon = (*((struct_matrice *) (*s_objet_statistique).objet)) .tableau; (*((struct_matrice *) (*s_objet_statistique).objet)) .nombre_lignes++; if (((*((struct_matrice *) (*s_objet_statistique).objet)) .tableau = malloc(((size_t) (*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes) * sizeof(integer8 *))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } for(i = 0; i < ((*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes - 1); i++) { ((integer8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i] = ((integer8 **) tampon)[i]; } free(tampon); ((integer8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i] = (integer8 *) (*s_objet).objet; free(s_objet); s_objet = NULL; } else if (((*s_objet_statistique).type == MRL) && ((*s_objet).type == REL)) { tampon = (*((struct_matrice *) (*s_objet_statistique).objet)) .tableau; (*((struct_matrice *) (*s_objet_statistique).objet)) .nombre_lignes++; if (((*((struct_matrice *) (*s_objet_statistique).objet)) .tableau = malloc(((size_t) (*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes) * sizeof(real8 *))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } for(i = 0; i < ((*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes - 1); i++) { ((real8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i] = ((real8 **) tampon)[i]; } free(tampon); ((real8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i] = (real8 *) (*s_objet).objet; free(s_objet); s_objet = NULL; } else if (((*s_objet_statistique).type == MRL) && ((*s_objet).type == INT)) { tampon = (*((struct_matrice *) (*s_objet_statistique).objet)) .tableau; (*((struct_matrice *) (*s_objet_statistique).objet)) .nombre_lignes++; if (((*((struct_matrice *) (*s_objet_statistique).objet)) .tableau = malloc(((size_t) (*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes) * sizeof(real8 *))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } for(i = 0; i < ((*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes - 1); i++) { ((real8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i] = ((real8 **) tampon)[i]; } free(tampon); if ((((real8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i] = malloc(sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } ((real8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i][0] = (real8) (*((integer8 *) (*s_objet).objet)); } else { tampon = (*((struct_matrice *) (*s_objet_statistique).objet)) .tableau; (*((struct_matrice *) (*s_objet_statistique).objet)) .nombre_lignes++; if (((*((struct_matrice *) (*s_objet_statistique).objet)) .tableau = malloc(((size_t) (*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes) * sizeof(real8 *))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } for(i = 0; i < ((*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes - 1); i++) { if ((((real8 **) (*((struct_matrice *) (*s_objet_statistique).objet)).tableau)[i] = malloc(sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } ((real8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i][0] = (real8) ((integer8 **) tampon)[i][0]; free(((integer8 **) tampon)[i]); } if ((((real8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i] = malloc(sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } ((real8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i][0] = (*((real8 *) (*s_objet).objet)); (*((struct_matrice *) (*s_objet_statistique).objet)).type = 'R'; (*s_objet_statistique).type = MRL; free(tampon); } } } /* * Ajout d'un vecteur */ else if (((*s_objet).type == VIN) || ((*s_objet).type == VRL)) { if (creation_variable_sigma == d_vrai) { /* * Création d'une matrice statistique 1*NC */ if ((s_variable.nom = malloc(6 * sizeof(unsigned char))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } strcpy(s_variable.nom, ds_sdat); s_variable.niveau = 1; if ((*s_objet).type == VIN) { if ((s_objet_statistique = allocation(s_etat_processus, MIN)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } if (((*((struct_matrice *) (*s_objet_statistique).objet)) .tableau = malloc(sizeof(integer8 **))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } ((integer8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[0] = (*((struct_vecteur *) (*s_objet).objet)).tableau; } else { if ((s_objet_statistique = allocation(s_etat_processus, MRL)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } if (((*((struct_matrice *) (*s_objet_statistique).objet)) .tableau = malloc(sizeof(real8 **))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } ((real8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[0] = (*((struct_vecteur *) (*s_objet).objet)).tableau; } (*((struct_matrice *) (*s_objet_statistique).objet)) .nombre_colonnes = (*((struct_vecteur *) (*s_objet).objet)) .taille; (*((struct_matrice *) (*s_objet_statistique).objet)) .nombre_lignes = 1; free((struct_vecteur *) (*s_objet).objet); free(s_objet); s_objet = NULL; s_variable.objet = s_objet_statistique; if (creation_variable(s_etat_processus, &s_variable, 'V', 'P') == d_erreur) { return; } } else { /* * La variable existe déjà, il faut lui rajouter une ligne. */ if (nombre_colonnes != (*((struct_vecteur *) (*s_objet).objet)) .taille) { (*s_etat_processus).erreur_execution = d_ex_dimensions_matrice_statistique; liberation(s_etat_processus, s_objet); return; } s_objet_statistique = (*(*s_etat_processus) .pointeur_variable_courante).objet; if (((*s_objet_statistique).type == MIN) && ((*s_objet).type == VIN)) { tampon = (*((struct_matrice *) (*s_objet_statistique).objet)) .tableau; (*((struct_matrice *) (*s_objet_statistique).objet)) .nombre_lignes++; if (((*((struct_matrice *) (*s_objet_statistique).objet)) .tableau = malloc(((size_t) (*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes) * sizeof(integer8 *))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } for(i = 0; i < ((*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes - 1); i++) { ((integer8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i] = ((integer8 **) tampon)[i]; } free(tampon); ((integer8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i] = (integer8 *) (*((struct_vecteur *) (*s_objet).objet)).tableau; free((struct_vecteur *) (*s_objet).objet); free(s_objet); s_objet = NULL; } else if (((*s_objet_statistique).type == MRL) && ((*s_objet).type == VRL)) { tampon = (*((struct_matrice *) (*s_objet_statistique).objet)) .tableau; (*((struct_matrice *) (*s_objet_statistique).objet)) .nombre_lignes++; if (((*((struct_matrice *) (*s_objet_statistique).objet)) .tableau = malloc(((size_t) (*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes) * sizeof(real8 *))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } for(i = 0; i < ((*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes - 1); i++) { ((real8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i] = ((real8 **) tampon)[i]; } free(tampon); ((real8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i] = (real8 *) (*((struct_vecteur *) (*s_objet).objet)).tableau; free((struct_vecteur *) (*s_objet).objet); free(s_objet); s_objet = NULL; } else if (((*s_objet_statistique).type == MRL) && ((*s_objet).type == VIN)) { tampon = (*((struct_matrice *) (*s_objet_statistique).objet)) .tableau; (*((struct_matrice *) (*s_objet_statistique).objet)) .nombre_lignes++; if (((*((struct_matrice *) (*s_objet_statistique).objet)) .tableau = malloc(((size_t) (*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes) * sizeof(real8 *))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } for(i = 0; i < ((*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes - 1); i++) { ((real8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i] = ((real8 **) tampon)[i]; } free(tampon); if ((((real8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i] = malloc(((size_t) nombre_colonnes) * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } for(j = 0; j < nombre_colonnes; j++) { ((real8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i][j] = (real8) (((integer8 *) (*((struct_vecteur *) (*s_objet).objet)).tableau)[j]); } } else { tampon = (*((struct_matrice *) (*s_objet_statistique).objet)) .tableau; (*((struct_matrice *) (*s_objet_statistique).objet)) .nombre_lignes++; if (((*((struct_matrice *) (*s_objet_statistique).objet)) .tableau = malloc(((size_t) (*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes) * sizeof(real8 *))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } for(i = 0; i < ((*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes - 1); i++) { if ((((real8 **) (*((struct_matrice *) (*s_objet_statistique).objet)).tableau)[i] = malloc(((size_t) nombre_colonnes) * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } for(j = 0; j < nombre_colonnes; j++) { ((real8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i][j] = (real8) ((integer8 **) tampon)[i][j]; } free(((integer8 **) tampon)[i]); } free(tampon); ((real8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i] = (real8 *) (*((struct_vecteur *) (*s_objet).objet)).tableau; free((struct_vecteur *) (*s_objet).objet); free(s_objet); s_objet = NULL; (*((struct_matrice *) (*s_objet_statistique).objet)).type = 'R'; (*s_objet_statistique).type = MRL; } } } /* * Ajout d'une matrice */ else if (((*s_objet).type == MIN) || ((*s_objet).type == MRL)) { if (creation_variable_sigma == d_vrai) { /* * Création d'une matrice statistique NL*NC */ if ((s_variable.nom = malloc(6 * sizeof(unsigned char))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } strcpy(s_variable.nom, ds_sdat); s_variable.niveau = 1; if ((*s_objet).type == MIN) { if ((s_objet_statistique = allocation(s_etat_processus, MIN)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } (*s_objet_statistique).objet = (*s_objet).objet; } else { if ((s_objet_statistique = allocation(s_etat_processus, MRL)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } (*s_objet_statistique).objet = (*s_objet).objet; } free(s_objet); s_objet = NULL; s_variable.objet = s_objet_statistique; if (creation_variable(s_etat_processus, &s_variable, 'V', 'P') == d_erreur) { return; } } else { /* * La variable existe déjà, il faut lui rajouter le nombre * de lignes de la matrice passée en argument. */ if (nombre_colonnes != (*((struct_matrice *) (*s_objet).objet)) .nombre_colonnes) { (*s_etat_processus).erreur_execution = d_ex_dimensions_matrice_statistique; liberation(s_etat_processus, s_objet); return; } s_objet_statistique = (*(*s_etat_processus) .pointeur_variable_courante).objet; nombre_lignes = (*((struct_matrice *) (*s_objet).objet)) .nombre_lignes; if (((*s_objet_statistique).type == MIN) && ((*s_objet).type == MIN)) { tampon = (*((struct_matrice *) (*s_objet_statistique).objet)) .tableau; (*((struct_matrice *) (*s_objet_statistique).objet)) .nombre_lignes += nombre_lignes; if (((*((struct_matrice *) (*s_objet_statistique).objet)) .tableau = malloc(((size_t) (*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes) * sizeof(integer8 *))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } for(i = 0; i < ((*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes - nombre_lignes); i++) { ((integer8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i] = ((integer8 **) tampon)[i]; } free(tampon); for(k = 0; i < ((*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes); i++, k++) { ((integer8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i] = ((integer8 **) (*((struct_matrice *) (*s_objet).objet)) .tableau)[k]; } free((integer8 **) (*((struct_matrice *) (*s_objet).objet)) .tableau); free((struct_matrice *) (*s_objet).objet); free(s_objet); s_objet = NULL; } else if (((*s_objet_statistique).type == MRL) && ((*s_objet).type == MRL)) { tampon = (*((struct_matrice *) (*s_objet_statistique).objet)) .tableau; (*((struct_matrice *) (*s_objet_statistique).objet)) .nombre_lignes += nombre_lignes; if (((*((struct_matrice *) (*s_objet_statistique).objet)) .tableau = malloc(((size_t) (*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes) * sizeof(real8 *))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } for(i = 0; i < ((*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes - nombre_lignes); i++) { ((real8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i] = ((real8 **) tampon)[i]; } free(tampon); for(k = 0; i < ((*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes); i++, k++) { ((real8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i] = ((real8 **) (*((struct_matrice *) (*s_objet).objet)) .tableau)[k]; } free((real8 **) (*((struct_matrice *) (*s_objet).objet)) .tableau); free((struct_matrice *) (*s_objet).objet); free(s_objet); s_objet = NULL; } else if (((*s_objet_statistique).type == MRL) && ((*s_objet).type == MIN)) { tampon = (*((struct_matrice *) (*s_objet_statistique).objet)) .tableau; (*((struct_matrice *) (*s_objet_statistique).objet)) .nombre_lignes += nombre_lignes; if (((*((struct_matrice *) (*s_objet_statistique).objet)) .tableau = malloc(((size_t) (*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes) * sizeof(real8 *))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } for(i = 0; i < ((*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes - nombre_lignes); i++) { ((real8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i] = ((real8 **) tampon)[i]; } free(tampon); for(k = 0; i < ((*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes); i++, k++) { if ((((real8 **) (*((struct_matrice *) (*s_objet_statistique).objet)).tableau)[i] = malloc(((size_t) nombre_colonnes) * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } for(j = 0; j < nombre_colonnes; j++) { ((real8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i][j] = (real8) (((integer8 **) (*((struct_matrice *) (*s_objet).objet)).tableau)[k][j]); } } } else { tampon = (*((struct_matrice *) (*s_objet_statistique).objet)) .tableau; (*((struct_matrice *) (*s_objet_statistique).objet)) .nombre_lignes += nombre_lignes; if (((*((struct_matrice *) (*s_objet_statistique).objet)) .tableau = malloc(((size_t) (*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes) * sizeof(real8 *))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } for(i = 0; i < ((*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes - nombre_lignes); i++) { if ((((real8 **) (*((struct_matrice *) (*s_objet_statistique).objet)).tableau)[i] = malloc(((size_t) nombre_colonnes) * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } for(j = 0; j < nombre_colonnes; j++) { ((real8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i][j] = (real8) ((integer8 **) tampon)[i][j]; } free(((integer8 **) tampon)[i]); } free(tampon); for(k = 0; i < ((*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes); i++, k++) { ((real8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i] = ((real8 **) (*((struct_matrice *) (*s_objet).objet)) .tableau)[k]; } free((real8 **) (*((struct_matrice *) (*s_objet).objet)) .tableau); free((struct_matrice *) (*s_objet).objet); free(s_objet); s_objet = NULL; (*((struct_matrice *) (*s_objet_statistique).objet)).type = 'R'; (*s_objet_statistique).type = MRL; } } } /* * Type incompatible en entrée */ else { liberation(s_etat_processus, s_objet); (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; return; } liberation(s_etat_processus, s_objet); return; } /* ================================================================================ Fonction 's-' ================================================================================ Entrées : structure processus -------------------------------------------------------------------------------- Sorties : -------------------------------------------------------------------------------- Effets de bord : néant ================================================================================ */ void instruction_s_moins(struct_processus *s_etat_processus) { struct_objet *s_copie_statistique; struct_objet *s_objet; struct_objet *s_objet_statistique; integer8 i; integer8 nombre_colonnes; integer8 nombre_lignes; void *tampon; (*s_etat_processus).erreur_execution = d_ex; if ((*s_etat_processus).affichage_arguments == 'Y') { printf("\n S- "); if ((*s_etat_processus).langue == 'F') { printf("(retrait une donnée dans la matrice statistique)\n\n"); } else { printf("(remove a data value from statistical matrix)\n\n"); } printf("-> 1: %s, %s, %s, %s\n", d_INT, d_REL, d_VIN, d_VRL); return; } else if ((*s_etat_processus).test_instruction == 'Y') { (*s_etat_processus).nombre_arguments = -1; return; } if (test_cfsf(s_etat_processus, 31) == d_vrai) { if (empilement_pile_last(s_etat_processus, 0) == d_erreur) { return; } } /* * Recherche d'une variable globale référencée par SIGMA */ if (recherche_variable_globale(s_etat_processus, ds_sdat) == d_faux) { /* * Aucune variable SIGMA */ (*s_etat_processus).erreur_systeme = d_es; if ((*s_etat_processus).erreur_execution == d_ex) { (*s_etat_processus).erreur_execution = d_ex_absence_observations; } return; } else { if ((*(*s_etat_processus).pointeur_variable_courante) .variable_verrouillee == d_vrai) { (*s_etat_processus).erreur_execution = d_ex_variable_verrouillee; return; } if (((*(*(*s_etat_processus).pointeur_variable_courante).objet) .type != MIN) && ((*(*(*s_etat_processus) .pointeur_variable_courante).objet).type != MRL)) { (*s_etat_processus).erreur_execution = d_ex_matrice_statistique_invalide; return; } if ((s_copie_statistique = copie_objet(s_etat_processus, (*(*s_etat_processus).pointeur_variable_courante).objet, 'O')) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } liberation(s_etat_processus, (*(*s_etat_processus) .pointeur_variable_courante).objet); (*(*s_etat_processus).pointeur_variable_courante).objet = s_copie_statistique; nombre_colonnes = (*((struct_matrice *) (*(*(*s_etat_processus) .pointeur_variable_courante).objet).objet)).nombre_colonnes; nombre_lignes = (*((struct_matrice *) (*(*(*s_etat_processus) .pointeur_variable_courante).objet).objet)).nombre_lignes; } s_objet_statistique = (*(*s_etat_processus).pointeur_variable_courante) .objet; if ((*s_objet_statistique).type == MIN) { if (nombre_colonnes == 1) { /* * Formation d'un entier */ if ((s_objet = allocation(s_etat_processus, NON)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } (*s_objet).type = INT; if (nombre_lignes == 1) { if (((*s_objet).objet = malloc(sizeof(integer8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } (*((integer8 *) (*s_objet).objet)) = ((integer8 **) (*((struct_matrice *) (*s_objet_statistique).objet)) .tableau)[nombre_lignes - 1][0]; } else { (*s_objet).objet = ((integer8 **) (*((struct_matrice *) (*s_objet_statistique).objet)) .tableau)[nombre_lignes - 1]; } } else { /* * Formation d'un vecteur d'entiers */ if ((s_objet = allocation(s_etat_processus, NON)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } if (((*s_objet).objet = malloc(sizeof(struct_vecteur))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } (*s_objet).type = VIN; (*((struct_vecteur *) (*s_objet).objet)).type = 'I'; (*((struct_vecteur *) (*s_objet).objet)).taille = nombre_colonnes; if (nombre_lignes == 1) { if (((*((struct_vecteur *) (*s_objet).objet)) .tableau = malloc(((size_t) nombre_colonnes) * sizeof(integer8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } for(i = 0; i < nombre_colonnes; i++) { ((integer8 *) (*((struct_vecteur *) (*s_objet).objet)) .tableau)[i] = ((integer8 **) (*((struct_matrice *) (*s_objet_statistique).objet)).tableau) [nombre_lignes - 1][i]; } } else { (*((struct_vecteur *) (*s_objet).objet)).tableau = ((integer8 **) (*((struct_matrice *) (*s_objet_statistique).objet)).tableau) [nombre_lignes - 1]; } } if (nombre_lignes == 1) { /* * Destruction de la variable globale SIGMA */ if (retrait_variable(s_etat_processus, ds_sdat, 'G') == d_erreur) { return; } } else { /* * Elimination de la dernière ligne de la matrice SIGMA */ tampon = (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau; (*((struct_matrice *) (*s_objet_statistique).objet)) .nombre_lignes--; if (((*((struct_matrice *) (*s_objet_statistique) .objet)).tableau = malloc(((size_t) (*((struct_matrice *) (*s_objet_statistique).objet)) .nombre_lignes) * sizeof(integer8 *))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } for(i = 0; i < (*((struct_matrice *) (*s_objet_statistique) .objet)).nombre_lignes; i++) { ((integer8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i] = ((integer8 **) tampon)[i]; } free(tampon); } } else if ((*s_objet_statistique).type == MRL) { if (nombre_colonnes == 1) { /* * Formation d'un réel */ if ((s_objet = allocation(s_etat_processus, NON)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } (*s_objet).type = REL; if (nombre_lignes == 1) { if (((*s_objet).objet = malloc(sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } (*((real8 *) (*s_objet).objet)) = ((real8 **) (*((struct_matrice *) (*s_objet_statistique).objet)) .tableau)[nombre_lignes - 1][0]; } else { (*s_objet).objet = ((real8 **) (*((struct_matrice *) (*s_objet_statistique).objet)) .tableau)[nombre_lignes - 1]; } } else { /* * Formation d'un vecteur de réels */ if ((s_objet = allocation(s_etat_processus, NON)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } if (((*s_objet).objet = malloc(sizeof(struct_vecteur))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } (*s_objet).type = VRL; (*((struct_vecteur *) (*s_objet).objet)).type = 'R'; (*((struct_vecteur *) (*s_objet).objet)).taille = nombre_colonnes; if (nombre_lignes == 1) { if (((*((struct_vecteur *) (*s_objet).objet)) .tableau = malloc(((size_t) nombre_colonnes) * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } for(i = 0; i < nombre_colonnes; i++) { ((real8 *) (*((struct_vecteur *) (*s_objet).objet)) .tableau)[i] = ((real8 **) (*((struct_matrice *) (*s_objet_statistique).objet)).tableau) [nombre_lignes - 1][i]; } } else { (*((struct_vecteur *) (*s_objet).objet)).tableau = ((real8 **) (*((struct_matrice *) (*s_objet_statistique).objet)).tableau) [nombre_lignes - 1]; } } if (nombre_lignes == 1) { /* * Destruction de la variable globale SIGMA */ if (retrait_variable(s_etat_processus, ds_sdat, 'G') == d_erreur) { return; } } else { /* * Elimination de la dernière ligne de la matrice SIGMA */ tampon = (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau; (*((struct_matrice *) (*s_objet_statistique).objet)) .nombre_lignes--; if (((*((struct_matrice *) (*s_objet_statistique).objet)) .tableau = malloc(((size_t) (*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes) * sizeof(real8 *))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } for(i = 0; i < (*((struct_matrice *) (*s_objet_statistique) .objet)).nombre_lignes; i++) { ((real8 **) (*((struct_matrice *) (*s_objet_statistique) .objet)).tableau)[i] = ((real8 **) tampon)[i]; } free(tampon); } } else { (*s_etat_processus).erreur_execution = d_ex_matrice_statistique_invalide; return; } if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), s_objet) == d_erreur) { return; } return; } // vim: ts=4