Bonjour,

Voici mon code qui provoque à l'exécution le message d'erreur suivant :
sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.
Abandon


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <string.h>
 
double **creerMat(int l, int c)
{
  double **m=malloc(l*sizeof(double*));
  for (int i=0 ; i<l ;i++) 
    { 
      m[i]=malloc(c*sizeof(double));
    }
  return m;
}
 
void libererMat(double **m, int l)
{
  for(int i=0 ; i<l ; i++)
    free(m[i]);
  free(m);
} 
 
double **trMat(double **m, int l, int c)
{
  double **tr_m=creerMat(c,l);
  for (int i=0; i<l; i++)
    for (int j=0; j<c; j++)
      tr_m[j][i]=m[i][j];
  return tr_m;
}
 
double **prodMat(double **A, int l, int c, double **B, int t)
{
  double **pr=creerMat(l,t);
  for (int i=0 ; i<l ; i++)
    for (int j=0 ; j<c ; j++)
      {
	pr[i][j] = 0;
	for (int k=0 ; k<c; k++)
	  pr[i][j] += A[i][k] * B[k][j];
      }
  return pr; 
}
 
double **absMat(double **m, int l, int c)
{
  double **abs_m=creerMat(l,c);
  for (int i=0 ; i<l ; i++)
    for (int j=0 ; j<c ; j++)
      abs_m[i][j]=fabs(m[i][j]);
  return abs_m; 
}
 
double **test(double **A, int l, int c, double **s)
{
  double **tr_s; double **m; double **abs_m;
  tr_s=trMat(s,1,c);
  m=prodMat(A,l,c,tr_s,1);
  libererMat(tr_s,l);
  abs_m=absMat(m,l,1);
  libererMat(m,l);
 
  return abs_m;
}
 
int main()
{
  double **A=creerMat(3,2);
  double **s=creerMat(1,2); 
  int l=3 ; int c=2;
 
  A[0][0]=4; A[0][1]=2;
  A[1][0]=7; A[1][1]=1;
  A[2][0]=3; A[2][1]=5;
 
  s[0][0]=1; s[0][1]=6;
 
  double **res=test(A, l, c, s);
 
  libererMat(A,l);
  libererMat(s,1);
  libererMat(res,l);
 
  return EXIT_SUCCESS;
}
Merci d'avance pour votre aide.