-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
64 lines (50 loc) · 1.61 KB
/
main.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <stdio.h>
#include <stdint.h>
#include <conf.h>
#include <vptree.h>
#include <utils.h>
#include <sodium.h>
/* array of indices (to keep track of VP's original index */
uint32_t* DATASET_INDEX;
/// \brief Frees up all pointers allocated during the building process of the VP tree by recursively freeing subtrees.
/// \param vpTreePtr
void free_vpt( vptree* vpTreePtr )
{
// Free inner / outer subtrees
if ( NULL != vpTreePtr->inner )
free_vpt( vpTreePtr->inner );
if ( NULL != vpTreePtr->outer )
free_vpt( vpTreePtr->outer );
// Free pointers inside parent tree
free( vpTreePtr->vp );
// Free parent
free( vpTreePtr );
}
int main()
{
static double DATASET[DATASET_N][DATASET_D];
vptree *vpTree;
uint32_t i;
uint32_t j;
// Initialize Dataset
for ( i = 0; i < DATASET_N; i++ )
for ( j = 0; j < DATASET_D; j++ )
{
// DATASET[i][j] = ( randombytes_uniform( INT32_MAX ) / (double) INT32_MAX ) * ( randombytes_uniform( INT32_MAX ) / (double) INT32_MAX );
DATASET[i][j] = i;
fprintf( stdout, "DATASET[%u] = %lf\n", i, DATASET[i][j] );
}
// Initialize index
DATASET_INDEX = (uint32_t *) malloc(DATASET_N * sizeof( uint32_t ) );
for ( i = 0; i < DATASET_N; i++ )
DATASET_INDEX[i] = i;
// Construct VP Tree from dataset (SERIAL)
vpTree = buildvp( *DATASET, DATASET_N, DATASET_D );
fprintf( stdout, "\n\nfinished building tree...\n\n" );
// Inspect VP Tree
inspect_vpt( vpTree, 0 );
// Free memory
free_vpt( vpTree );
free( DATASET_INDEX );
return 0;
}