-
Notifications
You must be signed in to change notification settings - Fork 0
/
tester.c
50 lines (34 loc) · 1.1 KB
/
tester.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*!
\file tester.c
\brief Validate kNN ring implementation.
\author Dimitris Floros
\date 2019-11-13
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <assert.h>
#include "knnring.h"
#include "tester_helper.h"
int main()
{
int n=897; // corpus
int m=762; // query
int d=7; // dimensions
int k=13; // # neighbors
double * corpus = (double * ) malloc( n*d * sizeof(double) );
double * query = (double * ) malloc( m*d * sizeof(double) );
for (int i=0;i<n*d;i++)
corpus[i] = ( (double) (rand()) ) / (double) RAND_MAX;
for (int i=0;i<m*d;i++)
query[i] = ( (double) (rand()) ) / (double) RAND_MAX;
knnresult knnres = kNN( corpus, query, n, m, d, k );
int isValidC = validateResult( knnres, corpus, query, n, m, d, k, COLMAJOR );
int isValidR = validateResult( knnres, corpus, query, n, m, d, k, ROWMAJOR );
printf("Tester validation: %s NEIGHBORS\n",
STR_CORRECT_WRONG[isValidC||isValidR]);
free( corpus );
free( query );
return 0;
}