Slight refactor

release/4.3a0
dellaert 2014-10-09 10:58:46 +02:00
parent a38a0ae9e1
commit 7e069191e5
2 changed files with 11 additions and 6 deletions

View File

@ -50,14 +50,9 @@ public:
boost::optional<std::vector<Matrix>&> H = boost::none) const {
if (H) {
assert(H->size()==size());
typedef std::map<Key, Matrix> MapType;
MapType terms;
Augmented<T> augmented = expression_.augmented(x);
// move terms to H, which is pre-allocated to correct size
size_t j = 0;
MapType::iterator it = augmented.jacobians().begin();
for (; it != augmented.jacobians().end(); ++it)
it->second.swap((*H)[j++]);
augmented.move(*H);
return measurement_.localCoordinates(augmented.value());
} else {
const T& value = expression_.value(x);

View File

@ -244,6 +244,16 @@ public:
<< "x" << term.second.cols() << ") ";
std::cout << std::endl;
}
/// Move terms to array, destroys content
void move(std::vector<Matrix>& H) {
assert(H.size()==jacobains.size());
size_t j = 0;
JacobianMap::iterator it = jacobians_.begin();
for (; it != jacobians_.end(); ++it)
it->second.swap(H[j++]);
}
};
//-----------------------------------------------------------------------------