Fixed unwhitenedError
parent
7b539fbb5c
commit
f38b0b0eed
|
@ -62,7 +62,7 @@ public:
|
||||||
JacobianMap(const FastVector<Key>& keys, VerticalBlockMatrix& Ab) :
|
JacobianMap(const FastVector<Key>& keys, VerticalBlockMatrix& Ab) :
|
||||||
keys_(keys), Ab_(Ab) {
|
keys_(keys), Ab_(Ab) {
|
||||||
}
|
}
|
||||||
/** Access a single block in the underlying matrix with read/write access */
|
/// Access via key
|
||||||
VerticalBlockMatrix::Block operator()(Key key) {
|
VerticalBlockMatrix::Block operator()(Key key) {
|
||||||
FastVector<Key>::const_iterator it = std::find(keys_.begin(),keys_.end(),key);
|
FastVector<Key>::const_iterator it = std::find(keys_.begin(),keys_.end(),key);
|
||||||
DenseIndex block = it - keys_.begin();
|
DenseIndex block = it - keys_.begin();
|
||||||
|
|
|
@ -75,41 +75,42 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Error function *without* the NoiseModel, \f$ z-h(x) \f$.
|
* Error function *without* the NoiseModel, \f$ h(x)-z \f$.
|
||||||
* We override this method to provide
|
* We override this method to provide
|
||||||
* both the function evaluation and its derivative(s) in H.
|
* both the function evaluation and its derivative(s) in H.
|
||||||
*/
|
*/
|
||||||
virtual Vector unwhitenedError(const Values& x,
|
virtual Vector unwhitenedError(const Values& x,
|
||||||
boost::optional<std::vector<Matrix>&> H = boost::none) const {
|
boost::optional<std::vector<Matrix>&> H = boost::none) const {
|
||||||
// if (H) {
|
if (H) {
|
||||||
// // H should be pre-allocated
|
// H should be pre-allocated
|
||||||
// assert(H->size()==size());
|
assert(H->size()==size());
|
||||||
//
|
|
||||||
// // Create and zero out blocks to be passed to expression_
|
VerticalBlockMatrix Ab(dimensions_, Dim);
|
||||||
// JacobianMap blocks;
|
|
||||||
// blocks.reserve(size());
|
// Wrap keys and VerticalBlockMatrix into structure passed to expression_
|
||||||
// for (DenseIndex i = 0; i < size(); i++) {
|
JacobianMap map(keys_, Ab);
|
||||||
// Matrix& Hi = H->at(i);
|
Ab.matrix().setZero();
|
||||||
// Hi.resize(Dim, dimensions_[i]);
|
|
||||||
// Hi.setZero(); // zero out
|
// Evaluate error to get Jacobians and RHS vector b
|
||||||
// Eigen::Block<Matrix> block = Hi.block(0, 0, Dim, dimensions_[i]);
|
T value = expression_.value(x, map); // <<< Reverse AD happens here !
|
||||||
// blocks.push_back(std::make_pair(keys_[i], block));
|
|
||||||
// }
|
// Copy blocks into the vector of jacobians passed in
|
||||||
//
|
for (DenseIndex i = 0; i < size(); i++)
|
||||||
// T value = expression_.value(x, blocks);
|
H->at(i) = Ab(i);
|
||||||
// return measurement_.localCoordinates(value);
|
|
||||||
// } else {
|
return measurement_.localCoordinates(value);
|
||||||
|
} else {
|
||||||
const T& value = expression_.value(x);
|
const T& value = expression_.value(x);
|
||||||
return measurement_.localCoordinates(value);
|
return measurement_.localCoordinates(value);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual boost::shared_ptr<GaussianFactor> linearize(const Values& x) const {
|
virtual boost::shared_ptr<GaussianFactor> linearize(const Values& x) const {
|
||||||
|
|
||||||
// This method has been heavily optimized for maximum performance.
|
// This method has been heavily optimized for maximum performance.
|
||||||
// We allocate a VerticalBlockMatrix on the stack first, and then create
|
// We allocate a VerticalBlockMatrix on the stack first, and then create
|
||||||
// Eigen::Block<Matrix> views on this piece of memory which is then passed
|
// a JacobianMap view onto it, which is then passed
|
||||||
// to [expression_.value] below, which writes directly into Ab_.
|
// to [expression_.value] to allow it to write directly into Ab_.
|
||||||
|
|
||||||
// Another malloc saved by creating a Matrix on the stack
|
// Another malloc saved by creating a Matrix on the stack
|
||||||
double memory[Dim * augmentedCols_];
|
double memory[Dim * augmentedCols_];
|
||||||
|
@ -121,7 +122,7 @@ public:
|
||||||
VerticalBlockMatrix Ab(dimensions_, matrix, true);
|
VerticalBlockMatrix Ab(dimensions_, matrix, true);
|
||||||
|
|
||||||
// Wrap keys and VerticalBlockMatrix into structure passed to expression_
|
// Wrap keys and VerticalBlockMatrix into structure passed to expression_
|
||||||
JacobianMap map(keys_,Ab);
|
JacobianMap map(keys_, Ab);
|
||||||
|
|
||||||
// Evaluate error to get Jacobians and RHS vector b
|
// Evaluate error to get Jacobians and RHS vector b
|
||||||
T value = expression_.value(x, map); // <<< Reverse AD happens here !
|
T value = expression_.value(x, map); // <<< Reverse AD happens here !
|
||||||
|
|
Loading…
Reference in New Issue