PIPS
matrix_add_const.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include "tools.h"
+ Include dependency graph for matrix_add_const.c:

Go to the source code of this file.

Functions

void matrix_add_const (size_t N, float C[N][N], float A[N][N], float val)
 
int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 15 of file matrix_add_const.c.

15  {
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 *)
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 ...
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

References close_data_file(), fprintf(), free(), init_data_file(), init_data_float(), malloc(), matrix_add_const(), and print_array_float().

+ Here is the call graph for this function:

◆ matrix_add_const()

void matrix_add_const ( size_t  N,
float  C[N][N],
float  A[N][N],
float  val 
)

Definition at line 6 of file matrix_add_const.c.

6  {
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 }
Definition: pip__tab.h:25

Referenced by main().

+ Here is the caller graph for this function: