Annotation of rpl/src/instructions_l3.c, revision 1.38

1.1       bertrand    1: /*
                      2: ================================================================================
1.37      bertrand    3:   RPL/2 (R) version 4.1.12
1.30      bertrand    4:   Copyright (C) 1989-2012 Dr. BERTRAND Joël
1.1       bertrand    5: 
                      6:   This file is part of RPL/2.
                      7: 
                      8:   RPL/2 is free software; you can redistribute it and/or modify it
                      9:   under the terms of the CeCILL V2 License as published by the french
                     10:   CEA, CNRS and INRIA.
                     11:  
                     12:   RPL/2 is distributed in the hope that it will be useful, but WITHOUT
                     13:   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
                     14:   FITNESS FOR A PARTICULAR PURPOSE.  See the CeCILL V2 License
                     15:   for more details.
                     16:  
                     17:   You should have received a copy of the CeCILL License
                     18:   along with RPL/2. If not, write to info@cecill.info.
                     19: ================================================================================
                     20: */
                     21: 
                     22: 
1.11      bertrand   23: #include "rpl-conv.h"
1.1       bertrand   24: 
                     25: 
                     26: /*
                     27: ================================================================================
                     28:   Fonction '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:    unsigned long               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(s_matrice_tampon_b
                    292:                    .nombre_lignes * sizeof(integer8 *))) == NULL)
                    293:            {
                    294:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    295:                return;
                    296:            }
                    297: 
                    298:            for(i = 0; i < s_matrice_tampon_b.nombre_lignes; i++)
                    299:            {
                    300:                if ((((integer8 **) s_matrice_tampon_b.tableau)[i] =
                    301:                        malloc(sizeof(integer8))) == NULL)
                    302:                {
                    303:                    (*s_etat_processus).erreur_systeme =
                    304:                            d_es_allocation_memoire;
                    305:                    return;
                    306:                }
                    307: 
                    308:                ((integer8 **) s_matrice_tampon_b.tableau)[i][0] =
                    309:                        ((integer8 *) (*((struct_vecteur *)
                    310:                        (*s_objet_argument_2).objet)).tableau)[i];
                    311:            }
                    312:        }
                    313:        else
                    314:        {
                    315:            s_matrice_tampon_b.type = 'R';
                    316:            s_matrice_tampon_b.nombre_lignes = (*((struct_vecteur *)
                    317:                    (*s_objet_argument_2).objet)).taille;
                    318:            s_matrice_tampon_b.nombre_colonnes = 1;
                    319: 
                    320:            if ((s_matrice_tampon_b.tableau = malloc(s_matrice_tampon_b
                    321:                    .nombre_lignes * sizeof(real8 *))) == NULL)
                    322:            {
                    323:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    324:                return;
                    325:            }
                    326: 
                    327:            for(i = 0; i < s_matrice_tampon_b.nombre_lignes; i++)
                    328:            {
                    329:                if ((((real8 **) s_matrice_tampon_b.tableau)[i] =
                    330:                        malloc(sizeof(real8))) == NULL)
                    331:                {
                    332:                    (*s_etat_processus).erreur_systeme =
                    333:                            d_es_allocation_memoire;
                    334:                    return;
                    335:                }
                    336: 
                    337:                ((real8 **) s_matrice_tampon_b.tableau)[i][0] =
                    338:                        ((real8 *) (*((struct_vecteur *)
                    339:                        (*s_objet_argument_2).objet)).tableau)[i];
                    340:            }
                    341:        }
                    342: 
                    343:        moindres_carres(s_etat_processus,
                    344:                (struct_matrice *) (*s_objet_argument_1).objet,
                    345:                &s_matrice_tampon_b, &s_matrice_tampon_x);
                    346: 
                    347:        if ((*s_objet_argument_2).type == VIN)
                    348:        {
                    349:            for(i = 0; i < s_matrice_tampon_b.nombre_lignes; i++)
                    350:            {
                    351:                free(((integer8 **) s_matrice_tampon_b.tableau)[i]);
                    352:            }
                    353:        }
                    354:        else
                    355:        {
                    356:            for(i = 0; i < s_matrice_tampon_b.nombre_lignes; i++)
                    357:            {
                    358:                free(((real8 **) s_matrice_tampon_b.tableau)[i]);
                    359:            }
                    360:        }
                    361: 
                    362:        free(s_matrice_tampon_b.tableau);
                    363: 
                    364:        if ((*s_etat_processus).erreur_systeme != d_es)
                    365:        {
                    366:            return;
                    367:        }
                    368: 
                    369:        if (((*s_etat_processus).exception != d_ep) ||
                    370:                ((*s_etat_processus).erreur_execution != d_ex))
                    371:        {
                    372:            liberation(s_etat_processus, s_objet_argument_1);
                    373:            liberation(s_etat_processus, s_objet_argument_2);
                    374:            return;
                    375:        }
                    376: 
                    377:        if ((s_objet_resultat = allocation(s_etat_processus, VRL)) == NULL)
                    378:        {
                    379:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    380:            return;
                    381:        }
                    382: 
                    383:        (*((struct_vecteur *) (*s_objet_resultat).objet)).taille =
                    384:                s_matrice_tampon_x.nombre_lignes;
                    385: 
                    386:        if (((*((struct_vecteur *) (*s_objet_resultat).objet)).tableau =
                    387:                malloc((*((struct_vecteur *) (*s_objet_resultat).objet)).taille
                    388:                * sizeof(real8))) == NULL)
                    389:        {
                    390:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    391:            return;
                    392:        }
                    393: 
                    394:        for(i = 0; i < (*((struct_vecteur *) (*s_objet_resultat).objet)).taille;
                    395:                i++)
                    396:        {
                    397:            ((real8 *) (*((struct_vecteur *) (*s_objet_resultat).objet))
                    398:                    .tableau)[i] = ((real8 **) s_matrice_tampon_x.tableau)
                    399:                    [i][0];
                    400:            free(((real8 **) s_matrice_tampon_x.tableau)[i]);
                    401:        }
                    402: 
                    403:        free(s_matrice_tampon_x.tableau);
                    404:    }
                    405: 
                    406:    /*
                    407:     * Résultat complexe
                    408:     */
                    409: 
                    410:    else if ((((*s_objet_argument_1).type == MCX) &&
                    411:            (((*s_objet_argument_2).type == VIN) ||
                    412:            ((*s_objet_argument_2).type == VRL) ||
                    413:            ((*s_objet_argument_2).type == VCX))) ||
                    414:            (((*s_objet_argument_2).type == VCX) &&
                    415:            (((*s_objet_argument_1).type == MIN) ||
                    416:            ((*s_objet_argument_1).type == MRL))))
                    417:    {
                    418:        if ((*((struct_vecteur *) (*s_objet_argument_2).objet)).taille !=
                    419:                (*((struct_matrice *) (*s_objet_argument_1).objet))
                    420:                .nombre_lignes)
                    421:        {
                    422:            liberation(s_etat_processus, s_objet_argument_1);
                    423:            liberation(s_etat_processus, s_objet_argument_2);
                    424: 
                    425:            (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
                    426:            return;
                    427:        }
                    428: 
                    429:        if ((*s_objet_argument_2).type == VIN)
                    430:        {
                    431:            s_matrice_tampon_b.type = 'I';
                    432:            s_matrice_tampon_b.nombre_lignes = (*((struct_vecteur *)
                    433:                    (*s_objet_argument_2).objet)).taille;
                    434:            s_matrice_tampon_b.nombre_colonnes = 1;
                    435: 
                    436:            if ((s_matrice_tampon_b.tableau = malloc(s_matrice_tampon_b
                    437:                    .nombre_lignes * sizeof(integer8 *))) == NULL)
                    438:            {
                    439:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    440:                return;
                    441:            }
                    442: 
                    443:            for(i = 0; i < s_matrice_tampon_b.nombre_lignes; i++)
                    444:            {
                    445:                if ((((integer8 **) s_matrice_tampon_b.tableau)[i] =
                    446:                        malloc(sizeof(integer8))) == NULL)
                    447:                {
                    448:                    (*s_etat_processus).erreur_systeme =
                    449:                            d_es_allocation_memoire;
                    450:                    return;
                    451:                }
                    452: 
                    453:                ((integer8 **) s_matrice_tampon_b.tableau)[i][0] =
                    454:                        ((integer8 *) (*((struct_vecteur *)
                    455:                        (*s_objet_argument_2).objet)).tableau)[i];
                    456:            }
                    457:        }
                    458:        else if ((*s_objet_argument_2).type == VRL)
                    459:        {
                    460:            s_matrice_tampon_b.type = 'R';
                    461:            s_matrice_tampon_b.nombre_lignes = (*((struct_vecteur *)
                    462:                    (*s_objet_argument_2).objet)).taille;
                    463:            s_matrice_tampon_b.nombre_colonnes = 1;
                    464: 
                    465:            if ((s_matrice_tampon_b.tableau = malloc(s_matrice_tampon_b
                    466:                    .nombre_lignes * sizeof(real8 *))) == NULL)
                    467:            {
                    468:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    469:                return;
                    470:            }
                    471: 
                    472:            for(i = 0; i < s_matrice_tampon_b.nombre_lignes; i++)
                    473:            {
                    474:                if ((((real8 **) s_matrice_tampon_b.tableau)[i] =
                    475:                        malloc(sizeof(real8))) == NULL)
                    476:                {
                    477:                    (*s_etat_processus).erreur_systeme =
                    478:                            d_es_allocation_memoire;
                    479:                    return;
                    480:                }
                    481: 
                    482:                ((real8 **) s_matrice_tampon_b.tableau)[i][0] =
                    483:                        ((real8 *) (*((struct_vecteur *)
                    484:                        (*s_objet_argument_2).objet)).tableau)[i];
                    485:            }
                    486:        }
                    487:        else
                    488:        {
                    489:            s_matrice_tampon_b.type = 'C';
                    490:            s_matrice_tampon_b.nombre_lignes = (*((struct_vecteur *)
                    491:                    (*s_objet_argument_2).objet)).taille;
                    492:            s_matrice_tampon_b.nombre_colonnes = 1;
                    493: 
                    494:            if ((s_matrice_tampon_b.tableau = malloc(s_matrice_tampon_b
                    495:                    .nombre_lignes * sizeof(struct_complexe16 *))) == NULL)
                    496:            {
                    497:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    498:                return;
                    499:            }
                    500: 
                    501:            for(i = 0; i < s_matrice_tampon_b.nombre_lignes; i++)
                    502:            {
                    503:                if ((((struct_complexe16 **) s_matrice_tampon_b.tableau)[i] =
                    504:                        malloc(sizeof(struct_complexe16))) == NULL)
                    505:                {
                    506:                    (*s_etat_processus).erreur_systeme =
                    507:                            d_es_allocation_memoire;
                    508:                    return;
                    509:                }
                    510: 
                    511:                ((struct_complexe16 **) s_matrice_tampon_b.tableau)[i][0]
                    512:                        .partie_reelle = ((struct_complexe16 *)
                    513:                        (*((struct_vecteur *) (*s_objet_argument_2).objet))
                    514:                        .tableau)[i].partie_reelle;
                    515:                ((struct_complexe16 **) s_matrice_tampon_b.tableau)[i][0]
                    516:                        .partie_imaginaire = ((struct_complexe16 *)
                    517:                        (*((struct_vecteur *) (*s_objet_argument_2).objet))
                    518:                        .tableau)[i].partie_imaginaire;
                    519:            }
                    520:        }
                    521: 
                    522:        moindres_carres(s_etat_processus,
                    523:                (struct_matrice *) (*s_objet_argument_1).objet,
                    524:                &s_matrice_tampon_b, &s_matrice_tampon_x);
                    525: 
                    526:        if ((*s_objet_argument_2).type == VIN)
                    527:        {
                    528:            for(i = 0; i < s_matrice_tampon_b.nombre_lignes; i++)
                    529:            {
                    530:                free(((integer8 **) s_matrice_tampon_b.tableau)[i]);
                    531:            }
                    532:        }
                    533:        else if ((*s_objet_argument_2).type == VRL)
                    534:        {
                    535:            for(i = 0; i < s_matrice_tampon_b.nombre_lignes; i++)
                    536:            {
                    537:                free(((real8 **) s_matrice_tampon_b.tableau)[i]);
                    538:            }
                    539:        }
                    540:        else
                    541:        {
                    542:            for(i = 0; i < s_matrice_tampon_b.nombre_lignes; i++)
                    543:            {
                    544:                free(((struct_complexe16 **) s_matrice_tampon_b.tableau)[i]);
                    545:            }
                    546:        }
                    547: 
                    548:        free(s_matrice_tampon_b.tableau);
                    549: 
                    550:        if ((*s_etat_processus).erreur_systeme != d_es)
                    551:        {
                    552:            return;
                    553:        }
                    554: 
                    555:        if (((*s_etat_processus).exception != d_ep) ||
                    556:                ((*s_etat_processus).erreur_execution != d_ex))
                    557:        {
                    558:            liberation(s_etat_processus, s_objet_argument_1);
                    559:            liberation(s_etat_processus, s_objet_argument_2);
                    560:            return;
                    561:        }
                    562: 
                    563:        if ((s_objet_resultat = allocation(s_etat_processus, VCX)) == NULL)
                    564:        {
                    565:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    566:            return;
                    567:        }
                    568: 
                    569:        (*((struct_vecteur *) (*s_objet_resultat).objet)).taille =
                    570:                s_matrice_tampon_x.nombre_lignes;
                    571: 
                    572:        if (((*((struct_vecteur *) (*s_objet_resultat).objet)).tableau =
                    573:                malloc((*((struct_vecteur *) (*s_objet_resultat).objet)).taille
                    574:                * sizeof(struct_complexe16))) == NULL)
                    575:        {
                    576:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    577:            return;
                    578:        }
                    579: 
                    580:        for(i = 0; i < (*((struct_vecteur *) (*s_objet_resultat).objet)).taille;
                    581:                i++)
                    582:        {
                    583:            ((struct_complexe16 *) (*((struct_vecteur *) (*s_objet_resultat)
                    584:                    .objet)).tableau)[i].partie_reelle = ((struct_complexe16 **)
                    585:                    s_matrice_tampon_x.tableau)[i][0].partie_reelle;
                    586:            ((struct_complexe16 *) (*((struct_vecteur *) (*s_objet_resultat)
                    587:                    .objet)).tableau)[i].partie_imaginaire =
                    588:                    ((struct_complexe16 **) s_matrice_tampon_x.tableau)[i][0]
                    589:                    .partie_imaginaire;
                    590:            free(((real8 **) s_matrice_tampon_x.tableau)[i]);
                    591:        }
                    592: 
                    593:        free(s_matrice_tampon_x.tableau);
                    594:    }
                    595: 
                    596: /*
                    597: --------------------------------------------------------------------------------
                    598:   Matrices
                    599: --------------------------------------------------------------------------------
                    600: */
                    601: 
                    602:    /*
                    603:     * Résultat réel
                    604:     */
                    605: 
                    606:    else if ((((*s_objet_argument_1).type == MIN) ||
                    607:            ((*s_objet_argument_1).type == MRL)) &&
                    608:            (((*s_objet_argument_2).type == MIN) ||
                    609:            ((*s_objet_argument_2).type == MRL)))
                    610:    {
                    611:        if ((*((struct_matrice *) (*s_objet_argument_2).objet)).nombre_lignes !=
                    612:                (*((struct_matrice *) (*s_objet_argument_1).objet))
                    613:                .nombre_lignes)
                    614:        {
                    615:            liberation(s_etat_processus, s_objet_argument_1);
                    616:            liberation(s_etat_processus, s_objet_argument_2);
                    617: 
                    618:            (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
                    619:            return;
                    620:        }
                    621: 
                    622:        moindres_carres(s_etat_processus,
                    623:                (struct_matrice *) (*s_objet_argument_1).objet,
                    624:                (struct_matrice *) (*s_objet_argument_2).objet,
                    625:                &s_matrice_tampon_x);
                    626: 
                    627:        if ((*s_etat_processus).erreur_systeme != d_es)
                    628:        {
                    629:            return;
                    630:        }
                    631: 
                    632:        if (((*s_etat_processus).exception != d_ep) ||
                    633:                ((*s_etat_processus).erreur_execution != d_ex))
                    634:        {
                    635:            liberation(s_etat_processus, s_objet_argument_1);
                    636:            liberation(s_etat_processus, s_objet_argument_2);
                    637:            return;
                    638:        }
                    639: 
                    640:        if ((s_objet_resultat = allocation(s_etat_processus, MRL)) == NULL)
                    641:        {
                    642:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    643:            return;
                    644:        }
                    645: 
                    646:        (*((struct_matrice *) (*s_objet_resultat).objet)).nombre_lignes =
                    647:                s_matrice_tampon_x.nombre_lignes;
                    648:        (*((struct_matrice *) (*s_objet_resultat).objet)).nombre_colonnes =
                    649:                s_matrice_tampon_x.nombre_colonnes;
                    650:        (*((struct_matrice *) (*s_objet_resultat).objet)).tableau =
                    651:                s_matrice_tampon_x.tableau;
                    652:    }
                    653: 
                    654:    /*
                    655:     * Résultat complexe
                    656:     */
                    657: 
                    658:    else if ((((*s_objet_argument_1).type == MCX) &&
                    659:            (((*s_objet_argument_2).type == MIN) ||
                    660:            ((*s_objet_argument_2).type == MRL) ||
                    661:            ((*s_objet_argument_2).type == MCX))) ||
                    662:            (((*s_objet_argument_2).type == MCX) &&
                    663:            (((*s_objet_argument_1).type == MIN) ||
                    664:            ((*s_objet_argument_1).type == MRL))))
                    665:    {
                    666:        if ((*((struct_matrice *) (*s_objet_argument_2).objet)).nombre_lignes !=
                    667:                (*((struct_matrice *) (*s_objet_argument_1).objet))
                    668:                .nombre_lignes)
                    669:        {
                    670:            liberation(s_etat_processus, s_objet_argument_1);
                    671:            liberation(s_etat_processus, s_objet_argument_2);
                    672: 
                    673:            (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
                    674:            return;
                    675:        }
                    676: 
                    677:        moindres_carres(s_etat_processus,
                    678:                (struct_matrice *) (*s_objet_argument_1).objet,
                    679:                (struct_matrice *) (*s_objet_argument_2).objet,
                    680:                &s_matrice_tampon_x);
                    681: 
                    682:        if ((*s_etat_processus).erreur_systeme != d_es)
                    683:        {
                    684:            return;
                    685:        }
                    686: 
                    687:        if (((*s_etat_processus).exception != d_ep) ||
                    688:                ((*s_etat_processus).erreur_execution != d_ex))
                    689:        {
                    690:            liberation(s_etat_processus, s_objet_argument_1);
                    691:            liberation(s_etat_processus, s_objet_argument_2);
                    692:            return;
                    693:        }
                    694: 
                    695:        if ((s_objet_resultat = allocation(s_etat_processus, MCX)) == NULL)
                    696:        {
                    697:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    698:            return;
                    699:        }
                    700: 
                    701:        (*((struct_matrice *) (*s_objet_resultat).objet)).nombre_lignes =
                    702:                s_matrice_tampon_x.nombre_lignes;
                    703:        (*((struct_matrice *) (*s_objet_resultat).objet)).nombre_colonnes =
                    704:                s_matrice_tampon_x.nombre_colonnes;
                    705:        (*((struct_matrice *) (*s_objet_resultat).objet)).tableau =
                    706:                s_matrice_tampon_x.tableau;
                    707:    }
                    708: 
                    709: /*
                    710: --------------------------------------------------------------------------------
                    711:   Types icompatibles avec la fonction LSQ
                    712: --------------------------------------------------------------------------------
                    713: */
                    714: 
                    715:    else
                    716:    {
                    717:        liberation(s_etat_processus, s_objet_argument_1);
                    718:        liberation(s_etat_processus, s_objet_argument_2);
                    719: 
                    720:        (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
                    721:        return;
                    722:    }
                    723: 
                    724:    liberation(s_etat_processus, s_objet_argument_1);
                    725:    liberation(s_etat_processus, s_objet_argument_2);
                    726: 
                    727:    if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
                    728:            s_objet_resultat) == d_erreur)
                    729:    {
                    730:        return;
                    731:    }
                    732: 
                    733:    return;
                    734: }
                    735: 
                    736: 
                    737: /*
                    738: ================================================================================
                    739:   Fonction 'logscale'
                    740: ================================================================================
                    741:   Entrées : pointeur sur une structure struct_processus
                    742: --------------------------------------------------------------------------------
                    743:   Sorties :
                    744: --------------------------------------------------------------------------------
                    745:   Effets de bord : néant
                    746: ================================================================================
                    747: */
                    748: 
                    749: void
                    750: instruction_logscale(struct_processus *s_etat_processus)
                    751: {
                    752:    logical1                        presence[3];
                    753:    logical1                        systeme_auxiliaire;
                    754:    logical1                        systeme_principal;
                    755: 
                    756:    struct_liste_chainee            *l_element_courant;
                    757: 
                    758:    struct_objet                    *s_objet;
                    759: 
                    760:    unsigned char                   *tampon;
                    761: 
                    762:    (*s_etat_processus).erreur_execution = d_ex;
                    763: 
                    764:    if ((*s_etat_processus).affichage_arguments == 'Y')
                    765:    {
                    766:        printf("\n  LOGSCALE ");
                    767: 
                    768:        if ((*s_etat_processus).langue == 'F')
                    769:        {
                    770:            printf("(définition des axes)\n\n");
                    771:        }
                    772:        else
                    773:        {
                    774:            printf("(definitions of axes)\n\n");
                    775:        }
                    776: 
                    777:        printf("    1: %s\n\n", d_LST);
                    778: 
                    779:        printf("    1: %s\n", d_NOM);
                    780: 
                    781:        if ((*s_etat_processus).langue == 'F')
                    782:        {
                    783:            printf("  Utilisation :\n\n");
                    784:        }
                    785:        else
                    786:        {
                    787:            printf("  Usage:\n\n");
                    788:        }
                    789: 
                    790:        printf("    { X Z } LOGSCALE\n");
                    791:        printf("    'Y' LOGSCALE\n");
                    792: 
                    793:        return;
                    794:    }
                    795:    else if ((*s_etat_processus).test_instruction == 'Y')
                    796:    {
                    797:        (*s_etat_processus).nombre_arguments = -1;
                    798:        return;
                    799:    }
                    800: 
                    801:    if ((*s_etat_processus).l_base_pile == NULL)
                    802:    {
                    803:        (*s_etat_processus).erreur_execution = d_ex_manque_argument;
                    804:        return;
                    805:    }
                    806: 
                    807:    if (test_cfsf(s_etat_processus, 31) == d_vrai)
                    808:    {
                    809:        if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
                    810:        {
                    811:            return;
                    812:        }
                    813:    }
                    814: 
                    815:    if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
                    816:            &s_objet) == d_erreur)
                    817:    {
                    818:        (*s_etat_processus).erreur_execution = d_ex_manque_argument;
                    819:        return;
                    820:    }
                    821: 
                    822:    if ((*s_objet).type == NOM)
                    823:    {
                    824:        tampon = conversion_majuscule((*((struct_nom *) (*s_objet).objet)).nom);
                    825: 
                    826:        if (tampon == NULL)
                    827:        {
                    828:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    829:            return;
                    830:        }
                    831: 
                    832:        if ((strcmp(tampon, "X") != 0) && (strcmp(tampon, "Y") != 0) &&
                    833:                (strcmp(tampon, "Z") != 0))
                    834:        {
                    835:            liberation(s_etat_processus, s_objet);
                    836: 
                    837:            free(tampon);
                    838: 
                    839:            (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
                    840:            return;
                    841:        }
                    842: 
                    843:        if (tampon[0] == 'X')
                    844:        {
                    845:            (*s_etat_processus).echelle_log_x = d_vrai;
                    846:        }
                    847:        else if (tampon[0] == 'Y')
                    848:        {
                    849:            (*s_etat_processus).echelle_log_y = d_vrai;
                    850:        }
                    851:        else
                    852:        {
                    853:            (*s_etat_processus).echelle_log_z = d_vrai;
                    854:        }
                    855: 
                    856:        free(tampon);
                    857:    }
                    858:    else if ((*s_objet).type == LST)
                    859:    {
                    860:        if ((*s_etat_processus).systeme_axes == 0)
                    861:        {
                    862:            systeme_principal = d_vrai;
                    863:            systeme_auxiliaire = d_faux;
                    864:        }
                    865:        else
                    866:        {
                    867:            systeme_principal = d_faux;
                    868:            systeme_auxiliaire = d_vrai;
                    869:        }
                    870: 
                    871:        presence[0] = d_faux;
                    872:        presence[1] = d_faux;
                    873:        presence[2] = d_faux;
                    874: 
                    875:        l_element_courant = (struct_liste_chainee *) (*s_objet).objet;
                    876: 
                    877:        if (l_element_courant == NULL)
                    878:        {
                    879:            if (systeme_principal == d_vrai)
                    880:            {
                    881:                (*s_etat_processus).echelle_log_x = d_faux;
                    882:                (*s_etat_processus).echelle_log_y = d_faux;
                    883:                (*s_etat_processus).echelle_log_z = d_faux;
                    884:            }
                    885:            else
                    886:            {
                    887:                (*s_etat_processus).echelle_log_x2 = d_faux;
                    888:                (*s_etat_processus).echelle_log_y2 = d_faux;
                    889:                (*s_etat_processus).echelle_log_z2 = d_faux;
                    890:            }
                    891:        }
                    892:        else
                    893:        {
                    894:            while(l_element_courant != NULL)
                    895:            {
                    896:                if ((*(*l_element_courant).donnee).type != NOM)
                    897:                {
                    898:                    liberation(s_etat_processus, s_objet);
                    899: 
                    900:                    (*s_etat_processus).erreur_execution =
                    901:                            d_ex_argument_invalide;
                    902:                    return;
                    903:                }
                    904: 
                    905:                tampon = conversion_majuscule((*((struct_nom *)
                    906:                        (*(*l_element_courant).donnee).objet)).nom);
                    907: 
                    908:                if ((strcmp(tampon, "X") != 0) && (strcmp(tampon, "Y") != 0) &&
                    909:                        (strcmp(tampon, "Z") != 0))
                    910:                {
                    911:                    liberation(s_etat_processus, s_objet);
                    912:                    free(tampon);
                    913: 
                    914:                    (*s_etat_processus).erreur_execution =
                    915:                            d_ex_argument_invalide;
                    916:                    return;
                    917:                }
                    918: 
                    919:                if (tampon[0] == 'X')
                    920:                {
                    921:                    if (presence[0] == d_vrai)
                    922:                    {
                    923:                        liberation(s_etat_processus, s_objet);
                    924:                        free(tampon);
                    925: 
                    926:                        (*s_etat_processus).erreur_execution =
                    927:                                d_ex_argument_invalide;
                    928:                        return;
                    929:                    }
                    930: 
                    931:                    if (systeme_principal == d_vrai)
                    932:                    {
                    933:                        (*s_etat_processus).echelle_log_x = d_vrai;
                    934:                    }
                    935: 
                    936:                    if (systeme_auxiliaire == d_vrai)
                    937:                    {
                    938:                        (*s_etat_processus).echelle_log_x2 = d_vrai;
                    939:                    }
                    940: 
                    941:                    presence[0] = d_vrai;
                    942:                }
                    943:                else if (tampon[0] == 'Y')
                    944:                {
                    945:                    if (presence[1] == d_vrai)
                    946:                    {
                    947:                        liberation(s_etat_processus, s_objet);
                    948:                        free(tampon);
                    949: 
                    950:                        (*s_etat_processus).erreur_execution =
                    951:                                d_ex_argument_invalide;
                    952:                        return;
                    953:                    }
                    954: 
                    955:                    if (systeme_principal == d_vrai)
                    956:                    {
                    957:                        (*s_etat_processus).echelle_log_y = d_vrai;
                    958:                    }
                    959: 
                    960:                    if (systeme_auxiliaire == d_vrai)
                    961:                    {
                    962:                        (*s_etat_processus).echelle_log_y2 = d_vrai;
                    963:                    }
                    964: 
                    965:                    presence[1] = d_vrai;
                    966:                }
                    967:                else
                    968:                {
                    969:                    if (presence[2] == d_vrai)
                    970:                    {
                    971:                        liberation(s_etat_processus, s_objet);
                    972:                        free(tampon);
                    973: 
                    974:                        (*s_etat_processus).erreur_execution =
                    975:                                d_ex_argument_invalide;
                    976:                        return;
                    977:                    }
                    978: 
                    979:                    if (systeme_principal == d_vrai)
                    980:                    {
                    981:                        (*s_etat_processus).echelle_log_z = d_vrai;
                    982:                    }
                    983: 
                    984:                    if (systeme_auxiliaire == d_vrai)
                    985:                    {
                    986:                        (*s_etat_processus).echelle_log_z2 = d_vrai;
                    987:                    }
                    988: 
                    989:                    presence[2] = d_vrai;
                    990:                }
                    991: 
                    992:                l_element_courant = (*l_element_courant).suivant;
                    993:                free(tampon);
                    994:            }
                    995:        }
                    996:    }
                    997:    else
                    998:    {
                    999:        liberation(s_etat_processus, s_objet);
                   1000: 
                   1001:        (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
                   1002:        return;
                   1003:    }
                   1004: 
                   1005:    liberation(s_etat_processus, s_objet);
                   1006: 
                   1007:    if (test_cfsf(s_etat_processus, 52) == d_faux)
                   1008:    {
                   1009:        if ((*s_etat_processus).fichiers_graphiques != NULL)
                   1010:        {
                   1011:            appel_gnuplot(s_etat_processus, 'N');
                   1012:        }
                   1013:    }
                   1014: 
                   1015:    return;
                   1016: }
                   1017: 
                   1018: // vim: ts=4

CVSweb interface <joel.bertrand@systella.fr>