Mercurial > hg > audiostuff
comparison spandsp-0.0.3/spandsp-0.0.3/tests/vector_float_tests.c @ 5:f762bf195c4b
import spandsp-0.0.3
author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
---|---|
date | Fri, 25 Jun 2010 16:00:21 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4:26cd8f1ef0b1 | 5:f762bf195c4b |
---|---|
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.4 2006/11/19 14:07:28 steveu Exp $ | |
26 */ | |
27 | |
28 #ifdef HAVE_CONFIG_H | |
29 #include "config.h" | |
30 #endif | |
31 | |
32 #include <inttypes.h> | |
33 #include <stdlib.h> | |
34 #include <stdio.h> | |
35 #include <fcntl.h> | |
36 #include <string.h> | |
37 #if defined(HAVE_TGMATH_H) | |
38 #include <tgmath.h> | |
39 #endif | |
40 #if defined(HAVE_MATH_H) | |
41 #include <math.h> | |
42 #endif | |
43 #include <assert.h> | |
44 #include <audiofile.h> | |
45 #include <tiffio.h> | |
46 | |
47 #include "spandsp.h" | |
48 | |
49 static double vec_dot_prod_dumb(const double x[], const double y[], int n) | |
50 { | |
51 int i; | |
52 double z; | |
53 | |
54 z = 0.0; | |
55 for (i = 0; i < n; i++) | |
56 z += x[i]*y[i]; | |
57 return z; | |
58 } | |
59 /*- End of function --------------------------------------------------------*/ | |
60 | |
61 int main(int argc, char *argv[]) | |
62 { | |
63 int i; | |
64 double x[100]; | |
65 double y[100]; | |
66 double zsa; | |
67 double zsb; | |
68 | |
69 for (i = 0; i < 99; i++) | |
70 { | |
71 x[i] = rand(); | |
72 y[i] = rand(); | |
73 } | |
74 zsa = vec_dot_prod(x, y, 99); | |
75 zsb = vec_dot_prod_dumb(x, y, 99); | |
76 if (zsa != zsb) | |
77 { | |
78 printf("Tests failed\n"); | |
79 exit(2); | |
80 } | |
81 | |
82 printf("Tests passed.\n"); | |
83 return 0; | |
84 } | |
85 /*- End of function --------------------------------------------------------*/ | |
86 /*- End of file ------------------------------------------------------------*/ |