Make more use of move semantics in AD code.

This makes some API changes to AutoDiffBlock.
 - Add overload for the constant() constructor taking rvalue ref.
 - Add overload for the variable() constructor taking rvalue ref.
 - Make the function() constructor *require* rvalue refs.
 - Add a swap() function.

The remaining changes in this commit are follow-ups especially
to the third change (adding std::move in many places), and
some removal of unnecessary block pattern arguments from calls to
the constant() static method.
This commit is contained in:
Atgeirr Flø Rasmussen
2015-03-10 12:36:14 +01:00
parent 635f3db814
commit 04b255a03f
9 changed files with 100 additions and 64 deletions

View File

@@ -403,7 +403,8 @@ collapseJacs(const AutoDiffBlock<double>& x)
// Build final jacobian.
std::vector<ADB::M> jacs(1);
collapseJacs( x, jacs[ 0 ] );
return ADB::function(x.value(), jacs);
ADB::V val = x.value();
return ADB::function(std::move(val), std::move(jacs));
}