--- rpl/src/algebre_lineaire4.c 2010/05/24 10:58:28 1.9 +++ rpl/src/algebre_lineaire4.c 2015/06/08 14:11:28 1.53 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.0.16 - Copyright (C) 1989-2010 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.22 + Copyright (C) 1989-2015 Dr. BERTRAND Joël This file is part of RPL/2. @@ -20,7 +20,7 @@ */ -#include "rpl.conv.h" +#include "rpl-conv.h" /* @@ -74,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); @@ -123,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); @@ -173,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; @@ -185,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; @@ -196,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; @@ -207,7 +211,7 @@ 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]; } } @@ -228,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; @@ -260,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; @@ -322,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; @@ -367,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; @@ -378,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]; } } @@ -393,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; @@ -406,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 = @@ -416,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; @@ -435,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; @@ -476,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; @@ -487,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 = @@ -513,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; @@ -524,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 = @@ -554,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; @@ -580,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; @@ -593,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 = @@ -603,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; @@ -622,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; @@ -663,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; @@ -674,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 = @@ -700,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; @@ -711,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 = @@ -741,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; @@ -767,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; @@ -780,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 = @@ -790,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; @@ -803,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; @@ -817,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; @@ -859,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; @@ -870,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 = @@ -896,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; @@ -907,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 =