PIPS
dscal_r.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "tools.h"
4 
5 void dscal_r(int n,float da,float dx[n])
6 {
7  int i;
8  for (i = 0; i < n; i++)
9  dx[i] = da*dx[i];
10 }
11 
12 int main(int argc, char * argv[])
13 {
14  int n;
15  float *dx;
16  int i;
17 
18  if (argc < 3)
19  {
20  fprintf(stderr, "Usage: %s size data_file\n", argv[0]);
21  return 1;
22  }
23  n = atoi(argv[1]);
24  dx = (float*) malloc(n*sizeof(float));
25  init_data_file(argv[2]);
26  init_data_float(dx, n);
28  dscal_r(n,42.,dx);
29  print_array_float("res", dx, n);
30  return 0;
31 }
32 
int main(int argc, char *argv[])
Definition: dscal_r.c:12
void dscal_r(int n, float da, float dx[n])
Definition: dscal_r.c:5
void * malloc(YYSIZE_T)
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