1 /*
2  * SpanDSP - a series of DSP components for telephony
3  *
4  * vector_float_tests.c
5  *
6  * Written by Steve Underwood <steveu@coppice.org>
7  *
8  * Copyright (C) 2006 Steve Underwood
9  *
10  * All rights reserved.
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License version 2, as
14  * published by the Free Software Foundation.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  *
25  * $Id: vector_float_tests.c,v 1.9 2008/05/13 13:17:27 steveu Exp $
26  */
27 
28 #if defined(HAVE_CONFIG_H)
29 #include "config.h"
30 #endif
31 
32 #include <stdlib.h>
33 #include <stdio.h>
34 #include <fcntl.h>
35 #include <string.h>
36 #include <audiofile.h>
37 
38 #include "spandsp.h"
39 
vec_dot_prod_dumb(const double x[],const double y[],int n)40 static double vec_dot_prod_dumb(const double x[], const double y[], int n)
41 {
42     int i;
43     double z;
44 
45     z = 0.0;
46     for (i = 0;  i < n;  i++)
47         z += x[i]*y[i];
48     return z;
49 }
50 /*- End of function --------------------------------------------------------*/
51 
main(int argc,char * argv[])52 int main(int argc, char *argv[])
53 {
54     int i;
55     double x[100];
56     double y[100];
57     double zsa;
58     double zsb;
59 
60     for (i = 0;  i < 99;  i++)
61     {
62         x[i] = rand();
63         y[i] = rand();
64     }
65     zsa = vec_dot_prod(x, y, 99);
66     zsb = vec_dot_prod_dumb(x, y, 99);
67     if (zsa != zsb)
68     {
69         printf("Tests failed\n");
70         exit(2);
71     }
72 
73     printf("Tests passed.\n");
74     return 0;
75 }
76 /*- End of function --------------------------------------------------------*/
77 /*- End of file ------------------------------------------------------------*/
78