Allow starting with empty VectorValues in JF::transposeMultiplyAdd
parent
7ad8c15028
commit
223f89d931
|
|
@ -423,11 +423,18 @@ namespace gtsam {
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
void JacobianFactorUnordered::transposeMultiplyAdd(double alpha, const Vector& e,
|
void JacobianFactorUnordered::transposeMultiplyAdd(double alpha, const Vector& e,
|
||||||
VectorValuesUnordered& x) const {
|
VectorValuesUnordered& x) const
|
||||||
|
{
|
||||||
Vector E = alpha * model_->whiten(e);
|
Vector E = alpha * model_->whiten(e);
|
||||||
// Just iterate over all A matrices and insert Ai^e into VectorValues
|
// Just iterate over all A matrices and insert Ai^e into VectorValues
|
||||||
for(size_t pos=0; pos<size(); ++pos)
|
for(size_t pos=0; pos<size(); ++pos)
|
||||||
gtsam::transposeMultiplyAdd(1.0, Ab_(pos), E, x[keys_[pos]]);
|
{
|
||||||
|
// Create the value as a zero vector if it does not exist.
|
||||||
|
pair<VectorValuesUnordered::iterator, bool> xi = x.tryInsert(keys_[pos], Vector());
|
||||||
|
if(xi.second)
|
||||||
|
xi.first->second = Vector::Zero(getDim(begin() + pos));
|
||||||
|
gtsam::transposeMultiplyAdd(1.0, Ab_(pos), E, xi.first->second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
|
|
|
||||||
|
|
@ -245,7 +245,8 @@ namespace gtsam {
|
||||||
/** Return A*x */
|
/** Return A*x */
|
||||||
Vector operator*(const VectorValuesUnordered& x) const;
|
Vector operator*(const VectorValuesUnordered& x) const;
|
||||||
|
|
||||||
/** x += A'*e */
|
/** x += A'*e. If x is initially missing any values, they are created and assumed to start as
|
||||||
|
* zero vectors. */
|
||||||
void transposeMultiplyAdd(double alpha, const Vector& e, VectorValuesUnordered& x) const;
|
void transposeMultiplyAdd(double alpha, const Vector& e, VectorValuesUnordered& x) const;
|
||||||
|
|
||||||
/** Return a whitened version of the factor, i.e. with unit diagonal noise model. */
|
/** Return a whitened version of the factor, i.e. with unit diagonal noise model. */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue