--- rpl/src/algebre_lineaire4.c 2010/02/10 10:14:18 1.3 +++ rpl/src/algebre_lineaire4.c 2020/01/10 11:15:38 1.66 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.0.11 - Copyright (C) 1989-2010 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.32 + Copyright (C) 1989-2020 Dr. BERTRAND Joël This file is part of RPL/2. @@ -20,7 +20,7 @@ */ -#include "rpl.conv.h" +#include "rpl-conv.h" /* @@ -38,8 +38,7 @@ static integer4 calcul_cond(struct_processus *s_etat_processus, void *matrice_f77, integer4 nombre_lignes_a, integer4 nombre_colonnes_a, - integer4 *pivot, integer4 dimension_vecteur_pivot, - unsigned char type, real8 *cond) + integer4 *pivot, unsigned char type, real8 *cond) { integer4 erreur; integer4 *iwork; @@ -75,13 +74,15 @@ calcul_cond(struct_processus *s_etat_pro return(-1); } - if ((iwork = malloc(nombre_colonnes_a * sizeof(integer4))) == NULL) + if ((iwork = malloc(((size_t) nombre_colonnes_a) * + sizeof(integer4))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return(-1); } - if ((work = malloc(4 * nombre_colonnes_a * sizeof(real8))) == NULL) + if ((work = malloc(4 * ((size_t) nombre_colonnes_a) * + sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return(-1); @@ -124,13 +125,15 @@ calcul_cond(struct_processus *s_etat_pro return(-1); } - if ((rwork = malloc(2 * nombre_colonnes_a * sizeof(real8))) == NULL) + if ((rwork = malloc(2 * ((size_t) nombre_colonnes_a) * sizeof(real8))) + == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return(-1); } - if ((work = malloc(2 * nombre_colonnes_a * sizeof(complex16))) == NULL) + if ((work = malloc(2 * ((size_t) nombre_colonnes_a) * + sizeof(complex16))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return(-1); @@ -174,9 +177,9 @@ cond(struct_processus *s_etat_processus, real8 cond; - unsigned long i; - unsigned long j; - unsigned long k; + integer8 i; + integer8 j; + integer8 k; void *matrice_f77; @@ -186,7 +189,7 @@ cond(struct_processus *s_etat_processus, ? nombre_lignes_a : nombre_colonnes_a; taille_matrice_f77 = nombre_lignes_a * nombre_colonnes_a; - if ((pivot = (integer4 *) malloc(dimension_vecteur_pivot * + if ((pivot = (integer4 *) malloc(((size_t) dimension_vecteur_pivot) * sizeof(integer4))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -197,7 +200,7 @@ cond(struct_processus *s_etat_processus, { case 'I' : { - if ((matrice_f77 = (void *) malloc(taille_matrice_f77 * + if ((matrice_f77 = malloc(((size_t) taille_matrice_f77) * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -208,14 +211,14 @@ cond(struct_processus *s_etat_processus, { for(j = 0; j < (*s_matrice).nombre_lignes; j++) { - ((real8 *) matrice_f77)[k++] = ((integer8 **) + ((real8 *) matrice_f77)[k++] = (real8) ((integer8 **) (*s_matrice).tableau)[j][i]; } } if ((rang = calcul_cond(s_etat_processus, matrice_f77, nombre_lignes_a, nombre_colonnes_a, pivot, - dimension_vecteur_pivot, 'R', &cond)) < 0) + 'R', &cond)) < 0) { free(pivot); free(matrice_f77); @@ -229,7 +232,7 @@ cond(struct_processus *s_etat_processus, case 'R' : { - if ((matrice_f77 = (void *) malloc(taille_matrice_f77 * + if ((matrice_f77 = malloc(((size_t) taille_matrice_f77) * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -247,7 +250,7 @@ cond(struct_processus *s_etat_processus, if ((rang = calcul_cond(s_etat_processus, matrice_f77, nombre_lignes_a, nombre_colonnes_a, pivot, - dimension_vecteur_pivot, 'R', &cond)) < 0) + 'R', &cond)) < 0) { free(pivot); free(matrice_f77); @@ -261,7 +264,7 @@ cond(struct_processus *s_etat_processus, case 'C' : { - if ((matrice_f77 = (void *) malloc(taille_matrice_f77 * + if ((matrice_f77 = malloc(((size_t) taille_matrice_f77) * sizeof(complex16))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -279,7 +282,7 @@ cond(struct_processus *s_etat_processus, if ((rang = calcul_cond(s_etat_processus, matrice_f77, nombre_lignes_a, nombre_colonnes_a, pivot, - dimension_vecteur_pivot, 'C', &cond)) < 0) + 'C', &cond)) < 0) { free(pivot); free(matrice_f77); @@ -323,15 +326,15 @@ void valeurs_singulieres(struct_processu integer4 nombre_valeurs_singulieres; integer4 taille_matrice_f77; + integer8 i; + integer8 j; + integer8 k; + real8 *rwork; unsigned char jobu; unsigned char jobvh; - unsigned long i; - unsigned long j; - unsigned long k; - void *matrice_f77; void *matrice_f77_u; void *matrice_f77_vh; @@ -368,7 +371,7 @@ void valeurs_singulieres(struct_processu { case 'I' : { - if ((matrice_f77 = (void *) malloc(taille_matrice_f77 * + if ((matrice_f77 = malloc(((size_t) taille_matrice_f77) * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -379,7 +382,7 @@ void valeurs_singulieres(struct_processu { for(j = 0; j < (*s_matrice).nombre_lignes; j++) { - ((real8 *) matrice_f77)[k++] = ((integer8 **) + ((real8 *) matrice_f77)[k++] = (real8) ((integer8 **) (*s_matrice).tableau)[j][i]; } } @@ -394,8 +397,8 @@ void valeurs_singulieres(struct_processu if (matrice_u != NULL) { - if ((matrice_f77_u = malloc(nombre_lignes_a * nombre_lignes_a * - sizeof(real8))) == NULL) + if ((matrice_f77_u = malloc(((size_t) (nombre_lignes_a * + nombre_lignes_a)) * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -407,7 +410,7 @@ void valeurs_singulieres(struct_processu matrice_f77_u = NULL; } - if ((vecteur_f77_s = malloc(nombre_valeurs_singulieres * + if ((vecteur_f77_s = malloc(((size_t) nombre_valeurs_singulieres) * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = @@ -417,8 +420,8 @@ void valeurs_singulieres(struct_processu if (matrice_vh != NULL) { - if ((matrice_f77_vh = malloc(nombre_colonnes_a - * nombre_colonnes_a * sizeof(real8))) == NULL) + if ((matrice_f77_vh = malloc(((size_t) (nombre_colonnes_a + * nombre_colonnes_a)) * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -436,10 +439,10 @@ void valeurs_singulieres(struct_processu matrice_f77_vh, &nombre_colonnes_a, work, &lwork, &erreur, longueur, longueur); - lwork = ((real8 *) work)[0]; + lwork = (integer4) ((real8 *) work)[0]; free(work); - if ((work = malloc(lwork * sizeof(real8))) == NULL) + if ((work = malloc(((size_t) lwork) * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; @@ -477,8 +480,8 @@ void valeurs_singulieres(struct_processu (*matrice_u).nombre_lignes = nombre_lignes_a; (*matrice_u).nombre_colonnes = nombre_lignes_a; - if (((*matrice_u).tableau = malloc((*matrice_u).nombre_lignes * - sizeof(real8 *))) == NULL) + if (((*matrice_u).tableau = malloc(((size_t) + (*matrice_u).nombre_lignes) * sizeof(real8 *))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -488,7 +491,7 @@ void valeurs_singulieres(struct_processu for(i = 0; i < (*matrice_u).nombre_lignes; i++) { if ((((real8 **) (*matrice_u).tableau)[i] = - malloc((*matrice_u).nombre_colonnes * + malloc(((size_t) (*matrice_u).nombre_colonnes) * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = @@ -514,8 +517,8 @@ void valeurs_singulieres(struct_processu (*matrice_vh).nombre_lignes = nombre_colonnes_a; (*matrice_vh).nombre_colonnes = nombre_colonnes_a; - if (((*matrice_vh).tableau = malloc((*matrice_vh) - .nombre_lignes * sizeof(real8 *))) == NULL) + if (((*matrice_vh).tableau = malloc(((size_t) (*matrice_vh) + .nombre_lignes) * sizeof(real8 *))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -525,7 +528,7 @@ void valeurs_singulieres(struct_processu for(i = 0; i < (*matrice_vh).nombre_lignes; i++) { if ((((real8 **) (*matrice_vh).tableau)[i] = - malloc((*matrice_vh).nombre_colonnes * + malloc(((size_t) (*matrice_vh).nombre_colonnes) * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = @@ -555,7 +558,7 @@ void valeurs_singulieres(struct_processu case 'R' : { - if ((matrice_f77 = (void *) malloc(taille_matrice_f77 * + if ((matrice_f77 = malloc(((size_t) taille_matrice_f77) * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -581,8 +584,8 @@ void valeurs_singulieres(struct_processu if (matrice_u != NULL) { - if ((matrice_f77_u = malloc(nombre_lignes_a * nombre_lignes_a * - sizeof(real8))) == NULL) + if ((matrice_f77_u = malloc(((size_t) (nombre_lignes_a * + nombre_lignes_a)) * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -594,7 +597,7 @@ void valeurs_singulieres(struct_processu matrice_f77_u = NULL; } - if ((vecteur_f77_s = malloc(nombre_valeurs_singulieres * + if ((vecteur_f77_s = malloc(((size_t) nombre_valeurs_singulieres) * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = @@ -604,8 +607,8 @@ void valeurs_singulieres(struct_processu if (matrice_vh != NULL) { - if ((matrice_f77_vh = malloc(nombre_colonnes_a - * nombre_colonnes_a * sizeof(real8))) == NULL) + if ((matrice_f77_vh = malloc(((size_t) (nombre_colonnes_a + * nombre_colonnes_a)) * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -623,10 +626,10 @@ void valeurs_singulieres(struct_processu matrice_f77_vh, &nombre_colonnes_a, work, &lwork, &erreur, longueur, longueur); - lwork = ((real8 *) work)[0]; + lwork = (integer4) ((real8 *) work)[0]; free(work); - if ((work = malloc(lwork * sizeof(real8))) == NULL) + if ((work = malloc(((size_t) lwork) * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; @@ -664,8 +667,8 @@ void valeurs_singulieres(struct_processu (*matrice_u).nombre_lignes = nombre_lignes_a; (*matrice_u).nombre_colonnes = nombre_lignes_a; - if (((*matrice_u).tableau = malloc((*matrice_u).nombre_lignes * - sizeof(real8 *))) == NULL) + if (((*matrice_u).tableau = malloc(((size_t) + (*matrice_u).nombre_lignes) * sizeof(real8 *))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -675,7 +678,7 @@ void valeurs_singulieres(struct_processu for(i = 0; i < (*matrice_u).nombre_lignes; i++) { if ((((real8 **) (*matrice_u).tableau)[i] = - malloc((*matrice_u).nombre_colonnes * + malloc(((size_t) (*matrice_u).nombre_colonnes) * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = @@ -701,8 +704,8 @@ void valeurs_singulieres(struct_processu (*matrice_vh).nombre_lignes = nombre_colonnes_a; (*matrice_vh).nombre_colonnes = nombre_colonnes_a; - if (((*matrice_vh).tableau = malloc((*matrice_vh) - .nombre_lignes * sizeof(real8 *))) == NULL) + if (((*matrice_vh).tableau = malloc(((size_t) (*matrice_vh) + .nombre_lignes) * sizeof(real8 *))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -712,7 +715,7 @@ void valeurs_singulieres(struct_processu for(i = 0; i < (*matrice_vh).nombre_lignes; i++) { if ((((real8 **) (*matrice_vh).tableau)[i] = - malloc((*matrice_vh).nombre_colonnes * + malloc(((size_t) (*matrice_vh).nombre_colonnes) * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = @@ -742,7 +745,7 @@ void valeurs_singulieres(struct_processu case 'C' : { - if ((matrice_f77 = (void *) malloc(taille_matrice_f77 * + if ((matrice_f77 = malloc(((size_t) taille_matrice_f77) * sizeof(complex16))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -768,8 +771,8 @@ void valeurs_singulieres(struct_processu if (matrice_u != NULL) { - if ((matrice_f77_u = malloc(nombre_lignes_a * nombre_lignes_a * - sizeof(complex16))) == NULL) + if ((matrice_f77_u = malloc(((size_t) (nombre_lignes_a * + nombre_lignes_a)) * sizeof(complex16))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -781,7 +784,7 @@ void valeurs_singulieres(struct_processu matrice_f77_u = NULL; } - if ((vecteur_f77_s = malloc(nombre_valeurs_singulieres * + if ((vecteur_f77_s = malloc(((size_t) nombre_valeurs_singulieres) * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = @@ -791,8 +794,8 @@ void valeurs_singulieres(struct_processu if (matrice_vh != NULL) { - if ((matrice_f77_vh = malloc(nombre_colonnes_a - * nombre_colonnes_a * sizeof(complex16))) == NULL) + if ((matrice_f77_vh = malloc(((size_t) (nombre_colonnes_a + * nombre_colonnes_a)) * sizeof(complex16))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -804,8 +807,8 @@ void valeurs_singulieres(struct_processu matrice_f77_vh = NULL; } - if ((rwork = malloc(5 * nombre_valeurs_singulieres * sizeof(real8))) - == NULL) + if ((rwork = malloc(5 * ((size_t) nombre_valeurs_singulieres) + * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -818,10 +821,10 @@ void valeurs_singulieres(struct_processu matrice_f77_vh, &nombre_colonnes_a, work, &lwork, rwork, &erreur, longueur, longueur); - lwork = ((real8 *) work)[0]; + lwork = (integer4) ((real8 *) work)[0]; free(work); - if ((work = malloc(lwork * sizeof(real8))) == NULL) + if ((work = malloc(((size_t) lwork) * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; @@ -860,8 +863,9 @@ void valeurs_singulieres(struct_processu (*matrice_u).nombre_lignes = nombre_lignes_a; (*matrice_u).nombre_colonnes = nombre_lignes_a; - if (((*matrice_u).tableau = malloc((*matrice_u).nombre_lignes * - sizeof(complex16 *))) == NULL) + if (((*matrice_u).tableau = malloc(((size_t) + (*matrice_u).nombre_lignes) * sizeof(complex16 *))) + == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -871,7 +875,7 @@ void valeurs_singulieres(struct_processu for(i = 0; i < (*matrice_u).nombre_lignes; i++) { if ((((complex16 **) (*matrice_u).tableau)[i] = - malloc((*matrice_u).nombre_colonnes * + malloc(((size_t) (*matrice_u).nombre_colonnes) * sizeof(complex16))) == NULL) { (*s_etat_processus).erreur_systeme = @@ -897,8 +901,8 @@ void valeurs_singulieres(struct_processu (*matrice_vh).nombre_lignes = nombre_colonnes_a; (*matrice_vh).nombre_colonnes = nombre_colonnes_a; - if (((*matrice_vh).tableau = malloc((*matrice_vh) - .nombre_lignes * sizeof(complex16 *))) == NULL) + if (((*matrice_vh).tableau = malloc(((size_t) (*matrice_vh) + .nombre_lignes) * sizeof(complex16 *))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -908,7 +912,7 @@ void valeurs_singulieres(struct_processu for(i = 0; i < (*matrice_vh).nombre_lignes; i++) { if ((((complex16 **) (*matrice_vh).tableau)[i] = - malloc((*matrice_vh).nombre_colonnes * + malloc(((size_t) (*matrice_vh).nombre_colonnes) * sizeof(complex16))) == NULL) { (*s_etat_processus).erreur_systeme =