Skip to content
Snippets Groups Projects
Commit 27987d1a authored by Boris Stefanovic's avatar Boris Stefanovic
Browse files

ADD: distance and argv usage

parent 7dc34631
No related branches found
No related tags found
No related merge requests found
...@@ -20,9 +20,7 @@ double distance_euclid_int(const vector_int_t* p1, const vector_int_t* p2) { ...@@ -20,9 +20,7 @@ double distance_euclid_int(const vector_int_t* p1, const vector_int_t* p2) {
return sqrt((double) acc); return sqrt((double) acc);
} }
inline int_t int_t abs_diff(const int_t a1, const int_t a2) {
abs_diff(const int_t a1, const int_t a2) {
int_t diff = a2 - a1; int_t diff = a2 - a1;
return diff >= 0 ? diff : -diff; return diff >= 0 ? diff : -diff;
} }
...@@ -39,5 +37,12 @@ double distance_manhattan_int(const vector_int_t* p1, const vector_int_t* p2) { ...@@ -39,5 +37,12 @@ double distance_manhattan_int(const vector_int_t* p1, const vector_int_t* p2) {
} }
double distance_chebyshev_int(const vector_int_t* p1, const vector_int_t* p2) { double distance_chebyshev_int(const vector_int_t* p1, const vector_int_t* p2) {
return ERROR; if (p1->dim != p2->dim)return ERROR;
int_t max = ERROR;
int_t item;
for (size_t i = 0; i < p1->dim; ++i) {
item = abs_diff(p1->data[i], p2->data[i]);
if (item > max) max = item;
}
return (double) max;
} }
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
int main(int argc, char **argv) { int main(int argc, char** argv) {
fprintf(stderr, "USAGE: %s <INPUT_FILE> <OUTPUT_FILE>\n", argv[0]);
char* ipath = "/dev/stdin";
char* opath = "/dev/stdout";
if (argc > 1) ipath = argv[1];
if (argc > 2) opath = argv[2];
// TODO
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment