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

Go to the source code of this file.

Functions

void sum_f (unsigned int n, float *res, float *a, float *b)
 
int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 12 of file sum_f.c.

13 {
14  unsigned int n,i;
15  float *a,*b,*res;
16  if (argc < 2)
17  return 1;
18  n = atoi(argv[1]);
19  a = (float*)malloc(n*sizeof(float));
20  b = (float*)malloc(n*sizeof(float));
21  res = (float*)malloc(n*sizeof(float));
22 
23  for (i=0; i < n; i++)
24  {
25  a[i] = i;
26  b[i] = n-i;
27  }
28 
29  sum_f(n,res,a,b);
30  //print_array_float("a",a,n);
31  //print_array_float("b",b,n);
32  print_array_float("res",res,n);
33 
34  return 0;
35 }
void * malloc(YYSIZE_T)
void sum_f(unsigned int n, float *res, float *a, float *b)
Definition: sum_f.c:5
void print_array_float(const char *name, const float *arr, const unsigned int n)
Definition: tools.c:54

References malloc(), print_array_float(), and sum_f().

+ Here is the call graph for this function:

◆ sum_f()

void sum_f ( unsigned int  n,
float *  res,
float *  a,
float *  b 
)

Definition at line 5 of file sum_f.c.

6 {
7  unsigned int i;
8  for (i=0;i<n;i++)
9  res[i]=a[i]+b[i];
10 }

Referenced by main().

+ Here is the caller graph for this function: