PIPS
matrix_mul_matrix.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <stdlib.h>
3 
4 #include "tools.h"
5 
6 void matrix_mul_matrix(size_t N, float C[N][N], float A[N][N], float B[N][N]) {
7  size_t i,j,k;
8  for (i=0; i<N; i++) {
9  for (j=0; j<N; j++) {
10  for(k=0;k<N;k++)
11  C[i][j]+=A[i][k] * B[k][j];
12  }
13  }
14 }
15 int main(int argc, char ** argv) {
16 
17  int i,j,n;
18  float *a,*b,*c;
19 
20  if (argc < 3)
21  {
22  fprintf(stderr, "Usage: %s size data_file\n", argv[0]);
23  return 1;
24  }
25  n = atoi(argv[1]);
26  a=malloc(sizeof(float)*4*n*4*n);
27  b=malloc(sizeof(float)*n*4*n*4);
28  c=calloc(n*4*n*4,sizeof(float));
29  init_data_file(argv[2]);
30  init_data_float(a, 4*4*n*n);
31  init_data_float(b, 4*4*n*n);
33 
34  matrix_mul_matrix(n,c,a,b);
35 
36  print_array_float("c",c,n*n);
37 
38  return 0;
39 }
void * malloc(YYSIZE_T)
#define B(A)
Definition: iabrev.h:61
int main(int argc, char **argv)
void matrix_mul_matrix(size_t N, float C[N][N], float A[N][N], float B[N][N])
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
Definition: pip__tab.h:25
void close_data_file()
Definition: tools.c:48
void print_array_float(const char *name, const float *arr, const unsigned int n)
Definition: tools.c:54
int init_data_float(float *ptr, const unsigned int n)
Definition: tools.c:125
void init_data_file(const char *data_file)
Definition: tools.c:36