PIPS
matrix_add_const.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_add_const(size_t N, float C[N][N], float A[N][N], float val) {
7  size_t i,j;
8  for (i=0; i<N; i++) {
9  for (j=0; j<N; j++) {
10  C[i][j]=A[i][j] + val;
11  }
12  }
13 }
14 
15 int main(int argc, char ** argv) {
16  int i,j,n;
17  float *a,*b;
18 
19  if (argc < 3)
20  {
21  fprintf(stderr, "Usage: %s size data_file\n", argv[0]);
22  return 1;
23  }
24  n = atoi(argv[1]);
25  a=malloc(sizeof(float)*n*n);
26  b=malloc(sizeof(float)*n*n);
27  init_data_file(argv[2]);
28  init_data_float(a, n*n);
30  matrix_add_const(n,b,a,(float)n);
31  print_array_float("b",b,n*n);
32  free(a);
33  free(b);
34  return 0;
35 }
void * malloc(YYSIZE_T)
void free(void *)
int main(int argc, char **argv)
void matrix_add_const(size_t N, float C[N][N], float A[N][N], float val)
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