24 #include <boost/format.hpp> 25 #include <boost/assign/std/vector.hpp> 34 using namespace gtsam;
38 int main(
int argc,
char* argv[]) {
41 ofstream
os(
"dsf-timing.csv");
42 os <<
"images,points,matches,Base,Map,BTree" << endl;
46 ms += 10, 20, 30, 40, 50, 100, 200, 300, 400, 500, 1000;
50 volatile size_t n = 500;
51 volatile size_t N =
m *
n;
53 volatile double fm = 0.1;
54 volatile size_t np = fm *
m *
m / 2;
55 volatile double fpm = 0.5;
56 volatile size_t nm = fpm * n *
np;
58 cout << format(
"\nTesting with %1% images, %2% points, %3% matches\n")
60 cout <<
"Generating " << nm <<
" matches" << endl;
62 std::uniform_int_distribution<> rn(0, N - 1);
64 typedef pair<size_t, size_t> Match;
67 for (
size_t k = 0; k < nm; k++)
68 matches.push_back(Match(rn(rng), rn(rng)));
70 os << format(
"%1%,%2%,%3%,") % (
int)
m % (
int)N % (
int)nm;
77 for(
const Match&
m: matches)
81 dsftime = dsftimeNode->secs();
83 cout << format(
"DSFBase: %1% s") % dsftime << endl;
92 for(
const Match&
m: matches)
96 dsftime = dsftimeNode->secs();
97 os << dsftime << endl;
98 cout << format(
"DSFMap: %1% s") % dsftime << endl;
107 for (
size_t j = 0;
j <
N;
j++)
109 for(
const Match&
m: matches)
113 dsftime = dsftimeNode->secs();
114 os << dsftime << endl;
115 cout << format(
"DSF functional: %1% s") % dsftime << endl;
124 for (
size_t j = 0;
j <
N;
j++)
126 for(
const Match&
m: matches)
130 dsftime = dsftimeNode->secs();
131 os << dsftime <<
",";
132 cout << format(
"DSF in-place: %1% s") % dsftime << endl;
#define tictoc_getNode(variable, label)
void merge(const KEY &x, const KEY &y)
Merge two sets.
void makeSetInPlace(const KEY &key)
Self makeSet(const KEY &key) const
A faster implementation for DSF, which uses vector rather than btree.
void makeUnionInPlace(const KEY &key1, const KEY &key2)
An implementation of Disjoint set forests (see CLR page 446 and up)
int main(int argc, char *argv[])
ofstream os("timeSchurFactors.csv")
void merge(const size_t &i1, const size_t &i2)
Merge the sets containing i1 and i2. Does nothing if i1 and i2 are already in the same set...
Allow for arbitrary type in DSF.
Self makeUnion(const KEY &key1, const KEY &key2) const