mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Adds -= operator
An elementwise -= operator is added to the autodiff class.
This commit is contained in:
@@ -194,6 +194,28 @@ namespace Opm
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Elementwise operator -=
|
||||
AutoDiffBlock& operator-=(const AutoDiffBlock& rhs)
|
||||
{
|
||||
if (jac_.empty()) {
|
||||
jac_ = rhs.jac_;
|
||||
} else if (!rhs.jac_.empty()) {
|
||||
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;
|
||||
}
|
||||
|
||||
/// Elementwise operator +
|
||||
AutoDiffBlock operator+(const AutoDiffBlock& rhs) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user