📄 buildvptree.c
字号:
/* * buildvptree.c * * VP-tree Program - Building VPTree * * By Philip Fu * * Fri Jan 12 22:58:44 EST 2001 * */#include <stdio.h>#include <stdlib.h>#include <math.h>#include <sys/resource.h>#include <sys/times.h>#include "vptree.h"#include "standard.h"intmain(int argc, char **argv){ DataSet *ds; VPTree *vpTree; int n; float userTime, sysTime; struct rusage startTime, stopTime; ///////////////////////////////////////////////////////// getrusage(RUSAGE_SELF,&startTime); ///////////////////////////////////////////////////////// // (1) Sanity check printf("\n"); if (argc != 5) { printf("Usage : %s <n> <dim> <data file> <vptree file>\n\n",argv[0]); return; } n = atoi(argv[1]); ///////////////////////////////////////////////////////// // (2) Read dataset printf("Reading the dataset ........ "); fflush(stdout); ds = readDataSet(n, atoi(argv[2]), argv[3]); if (ds == NULL) { printf("Oh! No memory left for me...\n\n"); return; } // testing //ds->nPoints = 15; //n = ds->nPoints; printf("done [%d points, %d dimension]\n",n,ds->dimension); ///////////////////////////////////////////////////////// // (3) Build the VP-tree printf("Building the VP-tree ....... "); fflush(stdout); vpTree = buildVPTree(ds,3); printf("done\n"); ///////////////////////////////////////////////////////// // (4) Output the vpTree to file printf("Output VP-Tree to file ..... "); fflush(stdout); n = writeVPTree(argv[4],vpTree); printf("done [%d points written]\n",n); /* for testing { VPTree *vpTree2 = readVPTree(argv[4],&n); printf("done [%d points read]\n",n); n = writeVPTree("data.vptree2",vpTree2); printf("done [%d points written]\n",n); freeVPTree(vpTree2); } */ ///////////////////////////////////////////////////////// getrusage(RUSAGE_SELF,&stopTime); ///////////////////////////////////////////////////////// // (5) Report execution time for building tree userTime = ((float) (stopTime.ru_utime.tv_sec - startTime.ru_utime.tv_sec)) + ((float) (stopTime.ru_utime.tv_usec - startTime.ru_utime.tv_usec)) * 1e-6; sysTime = ((float) (stopTime.ru_stime.tv_sec - startTime.ru_stime.tv_sec)) + ((float) (stopTime.ru_stime.tv_usec - startTime.ru_stime.tv_usec)) * 1e-6; printf("\n"); printf("User time : %f seconds\n",userTime); printf("System time : %f seconds\n\n",sysTime); ///////////////////////////////////////////////////////// // (6) Done freeVPTree(vpTree); freeDataSet(ds); printf("\n");}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -