Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
test-convexhull-time.C
Go to the documentation of this file.
1
2/* Aleph-w
3
4 / \ | | ___ _ __ | |__ __ __
5 / _ \ | |/ _ \ '_ \| '_ \ ____\ \ /\ / / Data structures & Algorithms
6 / ___ \| | __/ |_) | | | |_____\ V V / version 1.9c
7 /_/ \_\_|\___| .__/|_| |_| \_/\_/ https://github.com/lrleon/Aleph-w
8 |_|
9
10 This file is part of Aleph-w library
11
12 Copyright (c) 2002-2018 Leandro Rabindranath Leon
13
14 Permission is hereby granted, free of charge, to any person obtaining a copy
15 of this software and associated documentation files (the "Software"), to deal
16 in the Software without restriction, including without limitation the rights
17 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18 copies of the Software, and to permit persons to whom the Software is
19 furnished to do so, subject to the following conditions:
20
21 The above copyright notice and this permission notice shall be included in all
22 copies or substantial portions of the Software.
23
24 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 SOFTWARE.
31*/
32# include <iostream>
33
34# include <gsl/gsl_rng.h>
35
36# include <geom_algorithms.H>
37# include <ahNow.H>
38
39using namespace std;
40
42
44{
45 Points ret;
46
47 for (size_t i = 0; i < n; ++i)
49
50 return ret;
51}
52
53int main()
54{
55 constexpr size_t num_exp = 6;
56 constexpr size_t num_test = 12;
57 size_t sample_size = 128;
58
60 gsl_rng_set(rng, time(nullptr));
61
62 double sz[num_exp];
63 double bf[num_exp];
64 double gw[num_exp];
65 double qh[num_exp];
66
67 for (size_t i = 0; i < num_exp; ++i)
68 {
69 cout << "Testing sample size: " << sample_size << endl;
70
71 sz[i] = sample_size;
72
73 bf[i] = gw[i] = qh[i] = 0.0;
74
75 for (size_t j = 0; j < num_test; ++j)
76 {
77 Points points = generate_points(sample_size, rng);
78
79 Now now;
80 now.start();
81 QuickHull()(points);
82 qh[i] += now.elapsed();
83
84 now.start();
85 GiftWrappingConvexHull()(points);
86 gw[i] += now.elapsed();
87
88 now.start();
89 BruteForceConvexHull()(points);
90 bf[i] += now.elapsed();
91 }
92
93 sample_size = sample_size << 1;
94 }
95
96 cout << "Sample size\tQuick hull\tGift wrapping\tBrute force\n"
97 << "===========\t===========\t=============\t==========\n";
98
99 for (size_t i = 0; i < num_exp; ++i)
100 cout << sz[i] << '\t' << qh[i]/num_test << '\t' << gw[i]/num_test
101 << '\t' << bf[i]/num_test << endl;
102
104
105 return 0;
106}
107
High-resolution timer and benchmarking utilities.
Brute force convex hull algorithm.
Doubly-linked list (defined in tpl_dynList.H).
Definition htlist.H:1155
T & append(const T &item)
Definition htlist.H:1271
Gift wrapping (Jarvis march) convex hull algorithm.
Class Now is a practical class for timing based in a high resolution clock.
Definition ahNow.H:79
TimePointType start()
Sets internally the current time point.
Definition ahNow.H:195
Represents a point with rectangular coordinates in a 2D plane.
Definition point.H:221
QuickHull convex hull algorithm.
static mt19937 rng
Computational geometry algorithms.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Definition Blossom.H:466
STL namespace.
Points generate_points(size_t n, gsl_rng *&rng)
int main()