Moved template and inline functions to header file

release/4.3a0
Richard Roberts 2010-11-03 21:47:49 +00:00
parent d9d2cb7dda
commit d7a51c896b
2 changed files with 26 additions and 26 deletions

View File

@ -17,36 +17,10 @@
#pragma once #pragma once
#include <boost/foreach.hpp>
#include <gtsam/inference/inference.h> #include <gtsam/inference/inference.h>
using namespace std; using namespace std;
namespace gtsam { namespace gtsam {
/* ************************************************************************* */
template<typename CONSTRAINED>
Permutation::shared_ptr Inference::PermutationCOLAMD(const VariableIndex& variableIndex, const CONSTRAINED& constrainLast) {
vector<int> cmember(variableIndex.size(), 0);
// If at least some variables are not constrained to be last, constrain the
// ones that should be constrained.
if(constrainLast.size() < variableIndex.size()) {
BOOST_FOREACH(Index var, constrainLast) {
assert(var < variableIndex.size());
cmember[var] = 1;
}
}
return PermutationCOLAMD_(variableIndex, cmember);
}
/* ************************************************************************* */
inline Permutation::shared_ptr Inference::PermutationCOLAMD(const VariableIndex& variableIndex) {
vector<int> cmember(variableIndex.size(), 0);
return PermutationCOLAMD_(variableIndex, cmember);
}
} // namespace gtsam } // namespace gtsam

View File

@ -24,6 +24,8 @@
#include <gtsam/inference/VariableIndex.h> #include <gtsam/inference/VariableIndex.h>
#include <gtsam/inference/Permutation.h> #include <gtsam/inference/Permutation.h>
#include <boost/foreach.hpp>
#include <vector> #include <vector>
#include <deque> #include <deque>
@ -52,4 +54,28 @@ namespace gtsam {
}; };
/* ************************************************************************* */
template<typename CONSTRAINED>
Permutation::shared_ptr Inference::PermutationCOLAMD(const VariableIndex& variableIndex, const CONSTRAINED& constrainLast) {
std::vector<int> cmember(variableIndex.size(), 0);
// If at least some variables are not constrained to be last, constrain the
// ones that should be constrained.
if(constrainLast.size() < variableIndex.size()) {
BOOST_FOREACH(Index var, constrainLast) {
assert(var < variableIndex.size());
cmember[var] = 1;
}
}
return PermutationCOLAMD_(variableIndex, cmember);
}
/* ************************************************************************* */
inline Permutation::shared_ptr Inference::PermutationCOLAMD(const VariableIndex& variableIndex) {
std::vector<int> cmember(variableIndex.size(), 0);
return PermutationCOLAMD_(variableIndex, cmember);
}
} /// namespace gtsam } /// namespace gtsam