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

Go to the source code of this file.

Functions

void fir (size_t n, float in[n], float out[n], float kernel[n], size_t ksize)
 
int main (int argc, char *argv[])
 

Function Documentation

◆ fir()

void fir ( size_t  n,
float  in[n],
float  out[n],
float  kernel[n],
size_t  ksize 
)

Definition at line 5 of file fir.c.

7 {
8  size_t i, j;
9  for( i = 0; i < n - ksize + 1; ++i )
10  for( j = 0; j < ksize; ++j )
11  out[ i ] += in[ i + j ] * kernel[ j ];
12 }
static FILE * out
Definition: alias_check.c:128

References out.

Referenced by main().

+ Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 14 of file fir.c.

14  {
15  size_t i;
16  size_t n;
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  if (n<=100)
25  n=100;
26  {
27  float (*in)[n],(*out)[n],(*kernel)[n];
28  in=malloc(sizeof(float)*n);
29  out=calloc(n,sizeof(float));
30  kernel=malloc(sizeof(float)*n);
31  init_data_file(argv[2]);
32  init_data_float(in, n);
33  init_data_float(kernel, n);
35  fir(n,*in,*out,*kernel,n/8);
36  print_array_float("res", out, n);
37  free(out);
38  free(in);
39  free(kernel);
40  }
41  return 0;
42 }
void fir(size_t n, float in[n], float out[n], float kernel[n], size_t ksize)
Definition: fir.c:5
void * malloc(YYSIZE_T)
void free(void *)
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(), fir(), fprintf(), free(), init_data_file(), init_data_float(), malloc(), out, and print_array_float().

+ Here is the call graph for this function: