Mercurial > hg > audiostuff
annotate spandsp-0.0.6pre17/tests/vector_int_tests.c @ 6:22a74b01a099 default tip
implement more meaningful test program
author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
---|---|
date | Fri, 25 Jun 2010 16:14:50 +0200 |
parents | 26cd8f1ef0b1 |
children |
rev | line source |
---|---|
4
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
1 /* |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
2 * SpanDSP - a series of DSP components for telephony |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
3 * |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
4 * complex_vector_int_tests.c |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
5 * |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
6 * Written by Steve Underwood <steveu@coppice.org> |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
7 * |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
8 * Copyright (C) 2006 Steve Underwood |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
9 * |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
10 * All rights reserved. |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
11 * |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
12 * This program is free software; you can redistribute it and/or modify |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
13 * it under the terms of the GNU General Public License version 2, as |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
14 * published by the Free Software Foundation. |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
15 * |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
16 * This program is distributed in the hope that it will be useful, |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
19 * GNU General Public License for more details. |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
20 * |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
21 * You should have received a copy of the GNU General Public License |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
22 * along with this program; if not, write to the Free Software |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
24 * |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
25 * $Id: vector_int_tests.c,v 1.11 2009/04/26 07:00:39 steveu Exp $ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
26 */ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
27 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
28 #if defined(HAVE_CONFIG_H) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
29 #include "config.h" |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
30 #endif |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
31 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
32 #include <stdlib.h> |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
33 #include <stdio.h> |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
34 #include <fcntl.h> |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
35 #include <string.h> |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
36 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
37 #include "spandsp.h" |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
38 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
39 static int32_t vec_dot_prodi16_dumb(const int16_t x[], const int16_t y[], int n) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
40 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
41 int32_t z; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
42 int i; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
43 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
44 z = 0; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
45 for (i = 0; i < n; i++) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
46 z += (int32_t) x[i]*(int32_t) y[i]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
47 return z; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
48 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
49 /*- End of function --------------------------------------------------------*/ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
50 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
51 static int test_vec_dot_prodi16(void) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
52 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
53 int i; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
54 int32_t za; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
55 int32_t zb; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
56 int16_t x[99]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
57 int16_t y[99]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
58 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
59 for (i = 0; i < 99; i++) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
60 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
61 x[i] = rand(); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
62 y[i] = rand(); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
63 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
64 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
65 for (i = 1; i < 99; i++) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
66 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
67 za = vec_dot_prodi16(x, y, i); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
68 zb = vec_dot_prodi16_dumb(x, y, i); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
69 if (za != zb) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
70 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
71 printf("Tests failed\n"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
72 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
73 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
74 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
75 return 0; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
76 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
77 /*- End of function --------------------------------------------------------*/ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
78 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
79 static int32_t vec_min_maxi16_dumb(const int16_t x[], int n, int16_t out[]) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
80 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
81 int i; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
82 int16_t min; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
83 int16_t max; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
84 int16_t temp; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
85 int32_t z; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
86 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
87 max = INT16_MIN; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
88 min = INT16_MAX; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
89 for (i = 0; i < n; i++) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
90 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
91 temp = x[i]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
92 if (temp > max) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
93 max = temp; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
94 /*endif*/ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
95 if (temp < min) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
96 min = temp; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
97 /*endif*/ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
98 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
99 /*endfor*/ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
100 out[0] = max; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
101 out[1] = min; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
102 z = abs(min); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
103 if (z > max) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
104 return z; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
105 return max; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
106 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
107 /*- End of function --------------------------------------------------------*/ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
108 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
109 static int test_vec_min_maxi16(void) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
110 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
111 int i; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
112 int32_t za; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
113 int32_t zb; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
114 int16_t x[99]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
115 int16_t y[99]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
116 int16_t outa[2]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
117 int16_t outb[2]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
118 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
119 for (i = 0; i < 99; i++) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
120 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
121 x[i] = rand(); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
122 y[i] = rand(); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
123 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
124 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
125 x[42] = -32768; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
126 za = vec_min_maxi16_dumb(x, 99, outa); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
127 zb = vec_min_maxi16(x, 99, outb); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
128 if (za != zb |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
129 || |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
130 outa[0] != outb[0] |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
131 || |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
132 outa[1] != outb[1]) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
133 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
134 printf("Tests failed\n"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
135 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
136 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
137 return 0; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
138 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
139 /*- End of function --------------------------------------------------------*/ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
140 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
141 static int test_vec_circular_dot_prodi16(void) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
142 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
143 int i; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
144 int j; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
145 int pos; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
146 int len; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
147 int32_t za; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
148 int32_t zb; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
149 int16_t x[99]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
150 int16_t y[99]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
151 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
152 /* Verify that we can do circular sample buffer "dot" linear coefficient buffer |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
153 operations properly, by doing two sub-dot products. */ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
154 for (i = 0; i < 99; i++) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
155 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
156 x[i] = rand(); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
157 y[i] = rand(); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
158 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
159 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
160 len = 95; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
161 for (pos = 0; pos < len; pos++) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
162 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
163 za = vec_circular_dot_prodi16(x, y, len, pos); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
164 zb = 0; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
165 for (i = 0; i < len; i++) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
166 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
167 j = (pos + i) % len; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
168 zb += (int32_t) x[j]*(int32_t) y[i]; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
169 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
170 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
171 if (za != zb) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
172 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
173 printf("Tests failed\n"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
174 exit(2); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
175 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
176 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
177 return 0; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
178 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
179 /*- End of function --------------------------------------------------------*/ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
180 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
181 int main(int argc, char *argv[]) |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
182 { |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
183 test_vec_dot_prodi16(); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
184 test_vec_min_maxi16(); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
185 test_vec_circular_dot_prodi16(); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
186 |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
187 printf("Tests passed.\n"); |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
188 return 0; |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
189 } |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
190 /*- End of function --------------------------------------------------------*/ |
26cd8f1ef0b1
import spandsp-0.0.6pre17
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff
changeset
|
191 /*- End of file ------------------------------------------------------------*/ |