reapply a bug fix in isConstrained when no model exists

release/4.3a0
thduynguyen 2014-12-13 01:05:24 -05:00
parent 48b08bd58e
commit 2673e1664c
2 changed files with 3 additions and 5 deletions

View File

@ -580,10 +580,6 @@ void JacobianFactor::gradientAtZero(double* d) const {
/* ************************************************************************* */
Vector JacobianFactor::gradient(Key key, const VectorValues& x) const {
if (isConstrained()) { // Untested. But see the explanation in gradientAtZero()
Matrix A = getA(find(key));
return A.transpose()*ones(rows());
}
// TODO: optimize it for JacobianFactor without converting to a HessianFactor
HessianFactor hessian(*this);
return hessian.gradient(key, x);

View File

@ -230,7 +230,9 @@ namespace gtsam {
virtual bool empty() const { return size() == 0 /*|| rows() == 0*/; }
/** is noise model constrained ? */
bool isConstrained() const { return model_->isConstrained(); }
bool isConstrained() const {
return model_ && model_->isConstrained();
}
/** Return the dimension of the variable pointed to by the given key iterator
* todo: Remove this in favor of keeping track of dimensions with variables?