forked from parallella/pal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
p_conv.c
34 lines (32 loc) · 777 Bytes
/
p_conv.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <pal.h>
/**
* Computes the convolution of two vectors 'x' and 'h', and places the
* results in vector 'r'.
*
* @param x Pointer to input vector of size 'nr' elements
*
* @param h Pointer to 'nh' filter coefficients
*
* @param r Output vector of size 'nr+nh-1'
*
* @param nx The number of input samples
*
* @param nh The number of coefficients of the filter
*
* @return None
*
*/
void p_conv_f32(const float *x, const float *h, float *r, int nx, int nh)
{
float *rx = r;
int i,j ;
for ( i = 0; i < nx+nh-1; i++) { *(rx++) = 0; }
rx = r ;
for ( i = 0; i < nx; i++) {
float xv = *x++;
for (j = 0; j < nh; j++) {
*(rx + j) += xv * *(h + j);
}
rx++;
}
}