removed iterator_range calls
parent
4b40e6e346
commit
755da00e51
|
@ -129,9 +129,9 @@ struct HybridConstructorTraversalData {
|
||||||
// Check if we should merge the i^th child
|
// Check if we should merge the i^th child
|
||||||
if (nrParents + nrFrontals == childConditionals[i]->nrParents()) {
|
if (nrParents + nrFrontals == childConditionals[i]->nrParents()) {
|
||||||
const bool myType =
|
const bool myType =
|
||||||
data.discreteKeys.exists(conditional->frontals()[0]);
|
data.discreteKeys.exists(conditional->frontals().front());
|
||||||
const bool theirType =
|
const bool theirType =
|
||||||
data.discreteKeys.exists(childConditionals[i]->frontals()[0]);
|
data.discreteKeys.exists(childConditionals[i]->frontals().front());
|
||||||
|
|
||||||
if (myType == theirType) {
|
if (myType == theirType) {
|
||||||
// Increment number of frontal variables
|
// Increment number of frontal variables
|
||||||
|
|
|
@ -70,12 +70,33 @@ namespace gtsam {
|
||||||
/// Typedef to this class
|
/// Typedef to this class
|
||||||
typedef Conditional<FACTOR,DERIVEDCONDITIONAL> This;
|
typedef Conditional<FACTOR,DERIVEDCONDITIONAL> This;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/** A mini implementation of an iterator range, to share const
|
||||||
|
* views of frontals and parents. */
|
||||||
|
typedef std::pair<typename FACTOR::const_iterator, typename FACTOR::const_iterator> ConstFactorRange;
|
||||||
|
struct ConstFactorRangeIterator {
|
||||||
|
ConstFactorRange range_;
|
||||||
|
// Delete default constructor
|
||||||
|
ConstFactorRangeIterator() = delete;
|
||||||
|
ConstFactorRangeIterator(ConstFactorRange const& x) : range_(x) {}
|
||||||
|
// Implement begin and end for iteration
|
||||||
|
typename FACTOR::const_iterator begin() const { return range_.first; }
|
||||||
|
typename FACTOR::const_iterator end() const { return range_.second; }
|
||||||
|
size_t size() const { return std::distance(range_.first, range_.second); }
|
||||||
|
const auto& front() const { return *begin(); }
|
||||||
|
// == operator overload for comparison with another iterator
|
||||||
|
template<class OTHER>
|
||||||
|
bool operator==(const OTHER& rhs) const {
|
||||||
|
return std::equal(begin(), end(), rhs.begin());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/** View of the frontal keys (call frontals()) */
|
/** View of the frontal keys (call frontals()) */
|
||||||
typedef boost::iterator_range<typename FACTOR::const_iterator> Frontals;
|
typedef ConstFactorRangeIterator Frontals;
|
||||||
|
|
||||||
/** View of the separator keys (call parents()) */
|
/** View of the separator keys (call parents()) */
|
||||||
typedef boost::iterator_range<typename FACTOR::const_iterator> Parents;
|
typedef ConstFactorRangeIterator Parents;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// @name Standard Constructors
|
/// @name Standard Constructors
|
||||||
|
@ -121,10 +142,10 @@ namespace gtsam {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** return a view of the frontal keys */
|
/** return a view of the frontal keys */
|
||||||
Frontals frontals() const { return boost::make_iterator_range(beginFrontals(), endFrontals()); }
|
Frontals frontals() const { return ConstFactorRangeIterator({beginFrontals(), endFrontals()});}
|
||||||
|
|
||||||
/** return a view of the parent keys */
|
/** return a view of the parent keys */
|
||||||
Parents parents() const { return boost::make_iterator_range(beginParents(), endParents()); }
|
Parents parents() const { return ConstFactorRangeIterator({beginParents(), endParents()}); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All conditional types need to implement a `logProbability` function, for which
|
* All conditional types need to implement a `logProbability` function, for which
|
||||||
|
|
|
@ -55,7 +55,7 @@ TEST(JacobianFactor, constructors_and_accessors)
|
||||||
{
|
{
|
||||||
// b vector only constructor
|
// b vector only constructor
|
||||||
JacobianFactor expected(
|
JacobianFactor expected(
|
||||||
boost::make_iterator_range(terms.begin(), terms.begin()), b);
|
std::vector(terms.begin(), terms.begin()), b);
|
||||||
JacobianFactor actual(b);
|
JacobianFactor actual(b);
|
||||||
EXPECT(assert_equal(expected, actual));
|
EXPECT(assert_equal(expected, actual));
|
||||||
EXPECT(assert_equal(b, expected.getb()));
|
EXPECT(assert_equal(b, expected.getb()));
|
||||||
|
@ -66,7 +66,7 @@ TEST(JacobianFactor, constructors_and_accessors)
|
||||||
{
|
{
|
||||||
// One term constructor
|
// One term constructor
|
||||||
JacobianFactor expected(
|
JacobianFactor expected(
|
||||||
boost::make_iterator_range(terms.begin(), terms.begin() + 1), b, noise);
|
std::vector(terms.begin(), terms.begin() + 1), b, noise);
|
||||||
JacobianFactor actual(terms[0].first, terms[0].second, b, noise);
|
JacobianFactor actual(terms[0].first, terms[0].second, b, noise);
|
||||||
EXPECT(assert_equal(expected, actual));
|
EXPECT(assert_equal(expected, actual));
|
||||||
LONGS_EQUAL((long)terms[0].first, (long)actual.keys().back());
|
LONGS_EQUAL((long)terms[0].first, (long)actual.keys().back());
|
||||||
|
@ -79,7 +79,7 @@ TEST(JacobianFactor, constructors_and_accessors)
|
||||||
{
|
{
|
||||||
// Two term constructor
|
// Two term constructor
|
||||||
JacobianFactor expected(
|
JacobianFactor expected(
|
||||||
boost::make_iterator_range(terms.begin(), terms.begin() + 2), b, noise);
|
std::vector(terms.begin(), terms.begin() + 2), b, noise);
|
||||||
JacobianFactor actual(terms[0].first, terms[0].second,
|
JacobianFactor actual(terms[0].first, terms[0].second,
|
||||||
terms[1].first, terms[1].second, b, noise);
|
terms[1].first, terms[1].second, b, noise);
|
||||||
EXPECT(assert_equal(expected, actual));
|
EXPECT(assert_equal(expected, actual));
|
||||||
|
@ -93,7 +93,7 @@ TEST(JacobianFactor, constructors_and_accessors)
|
||||||
{
|
{
|
||||||
// Three term constructor
|
// Three term constructor
|
||||||
JacobianFactor expected(
|
JacobianFactor expected(
|
||||||
boost::make_iterator_range(terms.begin(), terms.begin() + 3), b, noise);
|
std::vector(terms.begin(), terms.begin() + 3), b, noise);
|
||||||
JacobianFactor actual(terms[0].first, terms[0].second,
|
JacobianFactor actual(terms[0].first, terms[0].second,
|
||||||
terms[1].first, terms[1].second, terms[2].first, terms[2].second, b, noise);
|
terms[1].first, terms[1].second, terms[2].first, terms[2].second, b, noise);
|
||||||
EXPECT(assert_equal(expected, actual));
|
EXPECT(assert_equal(expected, actual));
|
||||||
|
@ -107,7 +107,7 @@ TEST(JacobianFactor, constructors_and_accessors)
|
||||||
{
|
{
|
||||||
// Test three-term constructor with std::map
|
// Test three-term constructor with std::map
|
||||||
JacobianFactor expected(
|
JacobianFactor expected(
|
||||||
boost::make_iterator_range(terms.begin(), terms.begin() + 3), b, noise);
|
std::vector(terms.begin(), terms.begin() + 3), b, noise);
|
||||||
map<Key,Matrix> mapTerms;
|
map<Key,Matrix> mapTerms;
|
||||||
// note order of insertion plays no role: order will be determined by keys
|
// note order of insertion plays no role: order will be determined by keys
|
||||||
mapTerms.insert(terms[2]);
|
mapTerms.insert(terms[2]);
|
||||||
|
@ -125,7 +125,7 @@ TEST(JacobianFactor, constructors_and_accessors)
|
||||||
{
|
{
|
||||||
// VerticalBlockMatrix constructor
|
// VerticalBlockMatrix constructor
|
||||||
JacobianFactor expected(
|
JacobianFactor expected(
|
||||||
boost::make_iterator_range(terms.begin(), terms.begin() + 3), b, noise);
|
std::vector(terms.begin(), terms.begin() + 3), b, noise);
|
||||||
VerticalBlockMatrix blockMatrix(Dims{3, 3, 3, 1}, 3);
|
VerticalBlockMatrix blockMatrix(Dims{3, 3, 3, 1}, 3);
|
||||||
blockMatrix(0) = terms[0].second;
|
blockMatrix(0) = terms[0].second;
|
||||||
blockMatrix(1) = terms[1].second;
|
blockMatrix(1) = terms[1].second;
|
||||||
|
|
|
@ -46,7 +46,7 @@ TEST(LinearEquality, constructors_and_accessors) {
|
||||||
{
|
{
|
||||||
// One term constructor
|
// One term constructor
|
||||||
LinearEquality expected(
|
LinearEquality expected(
|
||||||
boost::make_iterator_range(terms.begin(), terms.begin() + 1), b, 0);
|
std::vector(terms.begin(), terms.begin() + 1), b, 0);
|
||||||
LinearEquality actual(terms[0].first, terms[0].second, b, 0);
|
LinearEquality actual(terms[0].first, terms[0].second, b, 0);
|
||||||
EXPECT(assert_equal(expected, actual));
|
EXPECT(assert_equal(expected, actual));
|
||||||
LONGS_EQUAL((long)terms[0].first, (long)actual.keys().back());
|
LONGS_EQUAL((long)terms[0].first, (long)actual.keys().back());
|
||||||
|
@ -58,7 +58,7 @@ TEST(LinearEquality, constructors_and_accessors) {
|
||||||
{
|
{
|
||||||
// Two term constructor
|
// Two term constructor
|
||||||
LinearEquality expected(
|
LinearEquality expected(
|
||||||
boost::make_iterator_range(terms.begin(), terms.begin() + 2), b, 0);
|
std::vector(terms.begin(), terms.begin() + 2), b, 0);
|
||||||
LinearEquality actual(terms[0].first, terms[0].second, terms[1].first,
|
LinearEquality actual(terms[0].first, terms[0].second, terms[1].first,
|
||||||
terms[1].second, b, 0);
|
terms[1].second, b, 0);
|
||||||
EXPECT(assert_equal(expected, actual));
|
EXPECT(assert_equal(expected, actual));
|
||||||
|
@ -71,7 +71,7 @@ TEST(LinearEquality, constructors_and_accessors) {
|
||||||
{
|
{
|
||||||
// Three term constructor
|
// Three term constructor
|
||||||
LinearEquality expected(
|
LinearEquality expected(
|
||||||
boost::make_iterator_range(terms.begin(), terms.begin() + 3), b, 0);
|
std::vector(terms.begin(), terms.begin() + 3), b, 0);
|
||||||
LinearEquality actual(terms[0].first, terms[0].second, terms[1].first,
|
LinearEquality actual(terms[0].first, terms[0].second, terms[1].first,
|
||||||
terms[1].second, terms[2].first, terms[2].second, b,
|
terms[1].second, terms[2].first, terms[2].second, b,
|
||||||
0);
|
0);
|
||||||
|
|
Loading…
Reference in New Issue