This commit is contained in:
David Harris 2022-01-20 17:15:53 +00:00
parent ac28880cd9
commit d1162eeebf

View File

@ -3,7 +3,6 @@
// Finite Impulse Response Filter // Finite Impulse Response Filter
#include <stdio.h> // supports printf #include <stdio.h> // supports printf
#include <math.h>
#include "util.h" // supports verify #include "util.h" // supports verify
void fir(int N, int M, double X[], double c[], double Y[]) { void fir(int N, int M, double X[], double c[], double Y[]) {
@ -28,6 +27,7 @@ int main(void) {
setStats(1); setStats(1);
fir(15, 5, X, c, Y); fir(15, 5, X, c, Y);
setStats(0); setStats(0);
// library linked doesn't support printing doubles, so convert to integers to print
for (int i=0; i<15; i++) { for (int i=0; i<15; i++) {
int tmp = Y[i]; int tmp = Y[i];
printf("Y[%d] = %d\n", i, tmp); printf("Y[%d] = %d\n", i, tmp);
@ -35,7 +35,6 @@ int main(void) {
// verifyDouble doesn't work exaclty because of rounding, so check for almost equal // verifyDouble doesn't work exaclty because of rounding, so check for almost equal
for (int i=0; i<15; i++) { for (int i=0; i<15; i++) {
if (fabs(Y[i] - Yexpected[i]) > 1e-10) { if (fabs(Y[i] - Yexpected[i]) > 1e-10) {
//printf("bad case %d\n", i);
return 1; return 1;
} }
} }