Slight refactor/reformatting
parent
61d6ba8a57
commit
0c29215018
|
@ -32,7 +32,7 @@ namespace gtsam {
|
|||
template<class T>
|
||||
class ExpressionFactor: public NoiseModelFactor {
|
||||
|
||||
protected:
|
||||
protected:
|
||||
|
||||
typedef ExpressionFactor<T> This;
|
||||
|
||||
|
@ -42,7 +42,7 @@ class ExpressionFactor: public NoiseModelFactor {
|
|||
|
||||
static const int Dim = traits<T>::dimension;
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
typedef boost::shared_ptr<ExpressionFactor<T> > shared_ptr;
|
||||
|
||||
|
@ -83,13 +83,16 @@ class ExpressionFactor: public NoiseModelFactor {
|
|||
if (!active(x))
|
||||
return boost::shared_ptr<JacobianFactor>();
|
||||
|
||||
// Create a writeable JacobianFactor in advance
|
||||
// In case noise model is constrained, we need to provide a noise model
|
||||
bool constrained = noiseModel_->isConstrained();
|
||||
SharedDiagonal noiseModel;
|
||||
if (noiseModel_->isConstrained()) {
|
||||
noiseModel = boost::static_pointer_cast<noiseModel::Constrained>(
|
||||
noiseModel_)->unit();
|
||||
}
|
||||
|
||||
// Create a writeable JacobianFactor in advance
|
||||
boost::shared_ptr<JacobianFactor> factor(
|
||||
constrained ? new JacobianFactor(keys_, dims_, Dim,
|
||||
boost::static_pointer_cast<noiseModel::Constrained>(noiseModel_)->unit()) :
|
||||
new JacobianFactor(keys_, dims_, Dim));
|
||||
new JacobianFactor(keys_, dims_, Dim, noiseModel));
|
||||
|
||||
// Wrap keys and VerticalBlockMatrix into structure passed to expression_
|
||||
VerticalBlockMatrix& Ab = factor->matrixObject();
|
||||
|
@ -114,7 +117,8 @@ class ExpressionFactor: public NoiseModelFactor {
|
|||
/// @return a deep copy of this factor
|
||||
virtual gtsam::NonlinearFactor::shared_ptr clone() const {
|
||||
return boost::static_pointer_cast<gtsam::NonlinearFactor>(
|
||||
gtsam::NonlinearFactor::shared_ptr(new This(*this))); }
|
||||
gtsam::NonlinearFactor::shared_ptr(new This(*this)));
|
||||
}
|
||||
};
|
||||
// ExpressionFactor
|
||||
|
||||
|
|
|
@ -31,19 +31,18 @@ namespace internal {
|
|||
// The JacobianMap provides a mapping from keys to the underlying blocks.
|
||||
class JacobianMap {
|
||||
private:
|
||||
typedef FastVector<Key> Keys;
|
||||
const FastVector<Key>& keys_;
|
||||
const KeyVector& keys_;
|
||||
VerticalBlockMatrix& Ab_;
|
||||
|
||||
public:
|
||||
/// Construct a JacobianMap for writing into a VerticalBlockMatrix Ab
|
||||
JacobianMap(const Keys& keys, VerticalBlockMatrix& Ab) :
|
||||
JacobianMap(const KeyVector& keys, VerticalBlockMatrix& Ab) :
|
||||
keys_(keys), Ab_(Ab) {
|
||||
}
|
||||
|
||||
/// Access blocks of via key
|
||||
VerticalBlockMatrix::Block operator()(Key key) {
|
||||
Keys::const_iterator it = std::find(keys_.begin(), keys_.end(), key);
|
||||
KeyVector::const_iterator it = std::find(keys_.begin(), keys_.end(), key);
|
||||
DenseIndex block = it - keys_.begin();
|
||||
return Ab_(block);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue