当前位置: 首页>>代码示例>>C++>>正文


C++ UserInterface::getArgs方法代码示例

本文整理汇总了C++中UserInterface::getArgs方法的典型用法代码示例。如果您正苦于以下问题:C++ UserInterface::getArgs方法的具体用法?C++ UserInterface::getArgs怎么用?C++ UserInterface::getArgs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserInterface的用法示例。


在下文中一共展示了UserInterface::getArgs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

// Driver program
int main(int argc, char **argv)
{
	int					num_points = 0;			// Actual number of data points
	ANNpointArray		data_points;			// Data points
	ANNpoint			query_point;			// Query point
	ANNidxArray			near_neighbor_idx;		// Near neighbor indices
	ANNdistArray		near_neighbor_distances;// Near neighbor distances
	ANNkd_tree *		kd_tree_adt;			// ADT search structure

	UserInterface UI;

	// Read command-line arguments
	UI.getArgs(argc, argv);						

	// Allocate query point
	query_point = annAllocPt(UI.dimension);

	// Allocate data points
	data_points = annAllocPts(UI.max_points, UI.dimension);

	// Allocate near neighbor indices
	near_neighbor_idx = new ANNidx[UI.k];

	// Allocate near neighbor distances
	near_neighbor_distances = new ANNdist[UI.k];														

	// Echo data points
	cout << "Data Points: \n";

	if (UI.results_out != NULL)
		*(UI.results_out) << "Data points: \n";

	while (num_points < UI.max_points && UI.readPoint(*(UI.data_in), data_points[num_points])) 
	{
		UI.printPoint(cout, data_points[num_points], num_points);

		if (UI.results_out != NULL)
		{
			UI.printPoint(*(UI.results_out), data_points[num_points], num_points);
		}

		num_points++;
	}

	// Construct k-d tree abstract data type search structure
	// Params: data points, number of points, dimension of space
	kd_tree_adt = new ANNkd_tree(data_points, num_points, UI.dimension);						

	// Echo query point(s)
	cout << "\n\nQuery points: \n";

	if (UI.results_out != NULL)
		*(UI.results_out) << "\n\nQuery points: \n";

	// Read query points
	while (UI.readPoint(*(UI.query_in), query_point)) 
	{		
		UI.printPoint(cout, query_point, UI.dimension);

		if (UI.results_out != NULL)
		{
			UI.printPoint(*(UI.results_out), query_point, UI.dimension);
		}

		// Perform the search
		// Params: query point, number of near neighbors, nearest neighbors (returned), distance (returned), error bound
		kd_tree_adt->annkSearch(query_point, UI.k, near_neighbor_idx, near_neighbor_distances, UI.eps);

		UI.printSummary(cout, &near_neighbor_idx, &near_neighbor_distances);

		if (UI.results_out != NULL)
			UI.printSummary(*(UI.results_out), &near_neighbor_idx, &near_neighbor_distances);
	}

	// Perform house cleaning tasks
	delete kd_tree_adt;
    delete [] near_neighbor_idx;							
    delete [] near_neighbor_distances;

	annClose();

	cin.get();

	return EXIT_SUCCESS;
}
开发者ID:MikhailJacques,项目名称:NNP,代码行数:86,代码来源:nns.cpp


注:本文中的UserInterface::getArgs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。