Renamed the main driver file

This commit is contained in:
Dongryeol Lee
2008-01-23 04:29:56 +00:00
parent bfe661b833
commit 01382ef582
4 changed files with 48 additions and 25 deletions
+7 -7
View File
@@ -1,17 +1,17 @@
librule(
name = "range_search", # this line can be safely omitted
sources = [], # files that must be compiled
name = "range_search",
sources = [],
headers = ["interval_tree.h",
"ortho_range_search.h",
"range_reader.h"], # include files part of the 'lib'
deplibs = ["fastlib:fastlib_int"] # dependency
"range_reader.h"],
deplibs = ["fastlib:fastlib_int"]
)
binrule(
name = "range_search_bin", # the executable name
sources = ["main.cc"], # compile multibody.cc
headers = [], # no extra headers
name = "range_search_bin",
sources = ["ortho_range_search_main.cc"],
headers = [],
deplibs = [":range_search",
"fastlib:fastlib_int"]
)
@@ -1,12 +1,18 @@
/** @file ortho_range_search.h
*
* This file contains an implementation of a tree-based and a naive
* algorithm for orthogonal range search.
*
* @author Dongryeol Lee (dongryel)
*/
#ifndef ORTHO_RANGE_SEARCH_H
#define ORTHO_RANGE_SEARCH_H
#include <values.h>
#include <sys/stat.h>
#include "range_reader.h"
#include "fastlib/fastlib_int.h"
#include "fastlib/fastlib.h"
/** Naive orthogonal range search class */
/** @brief Naive orthogonal range search class
*/
class NaiveOrthoRangeSearch {
FORBID_ACCIDENTAL_COPIES(NaiveOrthoRangeSearch);
@@ -37,14 +43,10 @@ class NaiveOrthoRangeSearch {
}
/** initialize the computation object */
void Init() {
const char *fname = fx_param_str(NULL, "data", "data.ds");
void Init(Matrix &data) {
// read in the dataset
Dataset dataset_;
dataset_.InitFromFile(fname);
data_.Own(&(dataset_.matrix()));
// copy the incoming data
data_.Copy(data);
// read the orthogonal query range text file
range_.Init(data_.n_rows());
@@ -1,12 +1,33 @@
/** @file ortho_range_search_main.cc
*
* A test driver for the orthogonal range search code.
*
* @author Dongryeol Lee (dongryel)
*/
#include "ortho_range_search.h"
int main(int argc, char *argv[]) {
// Always initialize FASTexec with main's inputs at the beggining of
// your program. This reads the command line, among other things.
fx_init(argc, argv);
////////// READING PARAMETERS AND LOADING DATA /////////////////////
// The reference data file is a required parameter.
const char* dataset_file_name = fx_param_str_req(NULL, "data");
// column-oriented dataset matrix.
Matrix dataset;
// data::Load inits a matrix with the contents of a .csv or .arff.
data::Load(dataset_file_name, &dataset);
// flag for determining whether we need to do naive algorithm.
bool do_naive = fx_param_exists(NULL, "do_naive");
// declare fast tree-based orthogonal range search algorithm object.
OrthoRangeSearch fast_search;
fast_search.Init();
fast_search.Compute();
@@ -19,7 +40,7 @@ int main(int argc, char *argv[]) {
// if naive option is specified, do naive algorithm
if(do_naive) {
NaiveOrthoRangeSearch search;
search.Init();
search.Init(dataset);
search.Compute();
ArrayList<bool> naive_search_results = search.get_results();
bool flag = true;
@@ -1,7 +1,7 @@
#ifndef RANGE_READER_H
#define RANGE_READER_H
#include "fastlib/fastlib_int.h"
#include "fastlib/fastlib.h"
// text parser class for handling -INFINITY and INFINITY tokens
class RangeReader {
@@ -24,11 +24,11 @@ class RangeReader {
!isdigit((tokenizer.Current().c_str())[1])) {
tokenizer.Gobble();
if(strncmp(tokenizer.Current().c_str(), "INFINITY", 8) == 0) {
range[i].lo = -MAXDOUBLE;
range[i].lo = -DBL_MAX;
}
}
else if(strncmp(tokenizer.Current().c_str(), "INFINITY", 8) == 0) {
range[i].lo = MAXDOUBLE;
range[i].lo = DBL_MAX;
}
else {
range[i].lo = atof(tokenizer.Current().c_str());
@@ -40,11 +40,11 @@ class RangeReader {
!isdigit((tokenizer.Current().c_str())[1])) {
tokenizer.Gobble();
if(strncmp(tokenizer.Current().c_str(), "INFINITY", 8) == 0) {
range[i].hi = -MAXDOUBLE;
range[i].hi = -DBL_MAX;
}
}
else if(strncmp(tokenizer.Current().c_str(), "INFINITY", 8) == 0) {
range[i].hi = MAXDOUBLE;
range[i].hi = DBL_MAX;
}
else {
range[i].hi = atof(tokenizer.Current().c_str());