summaryrefslogtreecommitdiff
path: root/match/test.c
diff options
context:
space:
mode:
Diffstat (limited to 'match/test.c')
-rw-r--r--match/test.c135
1 files changed, 0 insertions, 135 deletions
diff --git a/match/test.c b/match/test.c
deleted file mode 100644
index dabc083..0000000
--- a/match/test.c
+++ /dev/null
@@ -1,135 +0,0 @@
1/***************************************************************************
2 *
3 * Multitouch X driver
4 * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 **************************************************************************/
21
22#include <match.h>
23#include <xbypass.h>
24#include <stdio.h>
25#include <time.h>
26
27#define ITS 1000000
28
29static void test1()
30{
31 int A[] = {
32 1013,
33 3030660,
34 3559354,
35 12505925,
36 19008450,
37 6946421,
38 6118613,
39 698020,
40 3021800,
41 1017,
42 37573,
43 3242018,
44 8152794,
45 1266053,
46 942941,
47 462820,
48 };
49 int index[DIM_FINGER], i;
50 match_fingers(index, A, 4, 4);
51 for (i = 0; i < 4; i++)
52 printf("match[%d] = %d\n", i, index[i]);
53}
54
55static void test2()
56{
57 int A[] = {
58 0,
59 4534330,
60 22653552,
61 12252500,
62 685352,
63 4534330,
64 0,
65 9619317,
66 28409530,
67 6710170,
68 22653552,
69 9619317,
70 0,
71 47015292,
72 29788572,
73 2809040,
74 10428866,
75 38615920,
76 17732500,
77 719528,
78 12113945,
79 28196220,
80 46778656,
81 405,
82 14175493,
83 };
84 int index[DIM_FINGER], i;
85 match_fingers(index, A, 5, 5);
86 for (i = 0; i < 5; i++)
87 printf("match[%d] = %d\n", i, index[i]);
88}
89
90static void speed1()
91{
92 /* column-by-column matrix */
93 int A[DIM2_FINGER];
94 int x1[DIM_FINGER] = { 1, 5, 2, 3, 4, 5, 6, 7, 8 };
95 int y1[DIM_FINGER] = { 1, 5, 2, 3, 4, 6, 6, 7, 8 };
96 int x2[DIM_FINGER] = { 1.1, 3, 2, 4, 5, 6, 7, 8 };
97 int y2[DIM_FINGER] = { 1, 3, 2, 4, 5, 6, 7, 8 };
98 int index[DIM_FINGER];
99 int n1 = 4;
100 int n2 = 7;
101
102 int i, j;
103
104 for (i = 0; i < n1; i++) {
105 for (j = 0; j < n2; j++) {
106 A[i + n1 * j] =
107 (x1[i] - x2[j]) * (x1[i] - x2[j]) +
108 (y1[i] - y2[j]) * (y1[i] - y2[j]);
109 }
110 }
111
112 clock_t t1 = clock();
113 for (i = 0; i < ITS; i++)
114 match_fingers(index, A, n1, n2);
115 clock_t t2 = clock();
116
117 printf("%lf matches per second\n",
118 ITS * ((float)CLOCKS_PER_SEC / (t2 - t1)));
119
120 for (i = 0; i < n1; i++)
121 printf("match[%d] = %d\n", i, index[i]);
122
123}
124
125int main(int argc, char *argv[])
126{
127 printf("test1\n");
128 test1();
129 printf("test2\n");
130 test2();
131 printf("speed1\n");
132 speed1();
133 printf("done\n");
134 return 0;
135}