Add operator+=

This simplifies updating residuals.
This commit is contained in:
Bård Skaflestad 2013-05-23 18:24:37 +02:00
parent e2b5586b31
commit 2621283f1d

View File

@ -98,6 +98,24 @@ namespace AutoDiff
return vars;
}
/// Operator +=
ForwardBlock& operator+=(const ForwardBlock& rhs)
{
assert (numBlocks() == rhs.numBlocks());
assert (value().size() == rhs.value().size());
const int num_blocks = numBlocks();
for (int block = 0; block < num_blocks; ++block) {
assert(jac_[block].rows() == rhs.jac_[block].rows());
assert(jac_[block].cols() == rhs.jac_[block].cols());
jac_[block] += rhs.jac_[block];
}
val_ += rhs.val_;
return *this;
}
/// Operator +
ForwardBlock operator+(const ForwardBlock& rhs) const
{