Return set partitions from DFSMap
parent
9de0cacc27
commit
5e29bc5b67
32
.cproject
32
.cproject
|
@ -1,17 +1,11 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<?fileVersion 4.0.0?>
|
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||||
|
|
||||||
<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
|
||||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||||
<cconfiguration id="cdt.managedbuild.toolchain.gnu.macosx.base.1359703544">
|
<cconfiguration id="0.1697601156">
|
||||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.macosx.base.1359703544" moduleId="org.eclipse.cdt.core.settings" name="MacOSX GCC">
|
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.1697601156" moduleId="org.eclipse.cdt.core.settings" name="Default">
|
||||||
<externalSettings/>
|
<externalSettings/>
|
||||||
<extensions>
|
<extensions>
|
||||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
<extension id="org.eclipse.cdt.core.MachO64" point="org.eclipse.cdt.core.BinaryParser"/>
|
|
||||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
|
||||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
|
||||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
|
||||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
</extensions>
|
</extensions>
|
||||||
|
@ -122,9 +116,6 @@
|
||||||
<extension id="org.eclipse.cdt.core.MachO64" point="org.eclipse.cdt.core.BinaryParser"/>
|
<extension id="org.eclipse.cdt.core.MachO64" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
|
||||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
|
||||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
|
||||||
</extensions>
|
</extensions>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||||
|
@ -171,23 +162,10 @@
|
||||||
</configuration>
|
</configuration>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||||
<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
|
|
||||||
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
|
|
||||||
</cconfiguration>
|
</cconfiguration>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||||
<project id="gtsam.null.1344331286" name="gtsam"/>
|
<project id="gtsam.null.954446405" name="gtsam"/>
|
||||||
</storageModule>
|
|
||||||
<storageModule moduleId="refreshScope" versionNumber="2">
|
|
||||||
<configuration configurationName="Timing">
|
|
||||||
<resource resourceType="PROJECT" workspacePath="/gtsam"/>
|
|
||||||
</configuration>
|
|
||||||
<configuration configurationName="fast">
|
|
||||||
<resource resourceType="PROJECT" workspacePath="/gtsam"/>
|
|
||||||
</configuration>
|
|
||||||
<configuration configurationName="MacOSX GCC">
|
|
||||||
<resource resourceType="PROJECT" workspacePath="/gtsam"/>
|
|
||||||
</configuration>
|
|
||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
|
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
|
||||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <set>
|
||||||
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
|
@ -32,6 +35,8 @@ class DSFMap {
|
||||||
|
|
||||||
/// We store the forest in an STL map
|
/// We store the forest in an STL map
|
||||||
typedef std::map<KEY, KEY> Map;
|
typedef std::map<KEY, KEY> Map;
|
||||||
|
typedef std::set<KEY> Set;
|
||||||
|
typedef std::pair<KEY, KEY> key_pair;
|
||||||
mutable Map parent_;
|
mutable Map parent_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -60,6 +65,14 @@ public:
|
||||||
parent_[find(i2)] = find(i1);
|
parent_[find(i2)] = find(i1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// return all sets, i.e. a partition of all elements
|
||||||
|
std::map<KEY, Set> sets() const {
|
||||||
|
std::map<KEY, Set> sets;
|
||||||
|
BOOST_FOREACH(const key_pair& pair, parent_)
|
||||||
|
sets[find(pair.second)].insert(pair.first);
|
||||||
|
return sets;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,12 @@
|
||||||
|
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
#include <boost/assign/std/list.hpp>
|
#include <boost/assign/std/list.hpp>
|
||||||
//#include <boost/assign/std/set.hpp>
|
#include <boost/assign/std/set.hpp>
|
||||||
using namespace boost::assign;
|
using namespace boost::assign;
|
||||||
//
|
//
|
||||||
#include <CppUnitLite/TestHarness.h>
|
#include <CppUnitLite/TestHarness.h>
|
||||||
//
|
//
|
||||||
//#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace gtsam;
|
using namespace gtsam;
|
||||||
|
@ -115,7 +115,34 @@ TEST(DSFMap, mergePairwiseMatches2) {
|
||||||
EXPECT(dsf.find(m25)==m14);
|
EXPECT(dsf.find(m25)==m14);
|
||||||
EXPECT(dsf.find(m26)==m14);
|
EXPECT(dsf.find(m26)==m14);
|
||||||
}
|
}
|
||||||
|
/* ************************************************************************* */
|
||||||
|
TEST(DSFMap, sets){
|
||||||
|
// Create some "matches"
|
||||||
|
typedef pair<size_t,size_t> Match;
|
||||||
|
typedef pair<size_t, set<size_t> > key_pair;
|
||||||
|
list<Match> matches;
|
||||||
|
matches += Match(1,2), Match(2,3), Match(4,5), Match(4,6);
|
||||||
|
|
||||||
|
// Merge matches
|
||||||
|
DSFMap<size_t> dsf;
|
||||||
|
BOOST_FOREACH(const Match& m, matches)
|
||||||
|
dsf.merge(m.first,m.second);
|
||||||
|
|
||||||
|
map<size_t, set<size_t> > sets = dsf.sets();
|
||||||
|
set<size_t> s1, s2;
|
||||||
|
s1 += 1,2,3;
|
||||||
|
s2 += 4,5,6;
|
||||||
|
|
||||||
|
/*BOOST_FOREACH(key_pair st, sets){
|
||||||
|
cout << "Set " << st.first << " :{";
|
||||||
|
BOOST_FOREACH(const size_t s, st.second)
|
||||||
|
cout << s << ", ";
|
||||||
|
cout << "}" << endl;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
EXPECT(s1 == sets[1]);
|
||||||
|
EXPECT(s2 == sets[4]);
|
||||||
|
}
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
int main() { TestResult tr; return TestRegistry::runAllTests(tr);}
|
int main() { TestResult tr; return TestRegistry::runAllTests(tr);}
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "Module.h"
|
#include "Module.h"
|
||||||
#include "FileWriter.h"
|
#include "FileWriter.h"
|
||||||
#include "TypeAttributesTable.h"
|
#include "TypeAttributesTable.h"
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
|
|
||||||
//#define BOOST_SPIRIT_DEBUG
|
//#define BOOST_SPIRIT_DEBUG
|
||||||
#include "spirit_actors.h"
|
#include "spirit_actors.h"
|
||||||
|
@ -457,6 +457,10 @@ void Module::generateIncludes(FileWriter& file) const {
|
||||||
file.oss << "#include <" << *it << ">" << endl;
|
file.oss << "#include <" << *it << ">" << endl;
|
||||||
file.oss << "\n";
|
file.oss << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ************************************************************************* */
|
||||||
|
void Module::python_code(const string& toolboxPath, const string& headerPath) const {
|
||||||
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
void Module::matlab_code(const string& toolboxPath, const string& headerPath) const {
|
void Module::matlab_code(const string& toolboxPath, const string& headerPath) const {
|
||||||
|
|
|
@ -61,6 +61,11 @@ struct Module {
|
||||||
const std::string& path,
|
const std::string& path,
|
||||||
const std::string& headerPath) const; // FIXME: headerPath not actually used?
|
const std::string& headerPath) const; // FIXME: headerPath not actually used?
|
||||||
|
|
||||||
|
/// Python code generation:
|
||||||
|
void python_code(
|
||||||
|
const std::string& path,
|
||||||
|
const std::string& headerPath) const; // FIXME: headerPath not actually used?
|
||||||
|
|
||||||
void finish_wrapper(FileWriter& file, const std::vector<std::string>& functionNames) const;
|
void finish_wrapper(FileWriter& file, const std::vector<std::string>& functionNames) const;
|
||||||
|
|
||||||
void generateIncludes(FileWriter& file) const;
|
void generateIncludes(FileWriter& file) const;
|
||||||
|
|
Loading…
Reference in New Issue