mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-11-25 10:40:21 -06:00
variable(): Avoid memory overhead of identity constructor.
This commit is contained in:
parent
c276592ca5
commit
86eb29b4c3
@ -42,8 +42,10 @@ namespace AutoDiff
|
||||
static ForwardVec variable(const V& val)
|
||||
{
|
||||
ForwardVec ret(val);
|
||||
|
||||
ret.jac_.reserve(Eigen::VectorXi::Constant(val.size(), 1));
|
||||
for (typename M::Index row = 0; row < val.size(); ++row) {
|
||||
ret.jac_.insert(row, row) = 1.0;
|
||||
ret.jac_.insert(row, row) = Scalar(1.0);
|
||||
}
|
||||
ret.jac_.makeCompressed();
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user