-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_distance.c
38 lines (32 loc) · 1.08 KB
/
test_distance.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
https://powcoder.com
代写代考加微信 powcoder
Assignment Project Exam Help
Add WeChat powcoder
https://powcoder.com
代写代考加微信 powcoder
Assignment Project Exam Help
Add WeChat powcoder
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "knn.h"
/* A simple program to test the cosine distance function
* On teach.cs, the following call produces the results below
* ./test_distance /u/csc209h/winter/pub/datasets/a2_datasets/testing_data.bin
* Cosine distance = 0.900966
* Euclidean distance = 3205.300298
*/
int main(int argc, char **argv) {
if(argc != 2) {
fprintf(stderr, "Usage: %s filename\n", argv[0]);
exit(1);
}
Dataset *data = load_dataset(argv[1]);
// Compute the distance between the first two images in the data set
double cos_distance = distance_cosine(&data->images[0], &data->images[1]);
double euc_distance = distance_euclidean(&data->images[0], &data->images[1]);
printf("Cosine distance = %f\n", cos_distance);
printf("Euclidean distance = %f\n", euc_distance);
return 0;
}