mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-11-29 04:23:48 -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)
|
static ForwardVec variable(const V& val)
|
||||||
{
|
{
|
||||||
ForwardVec ret(val);
|
ForwardVec ret(val);
|
||||||
|
|
||||||
|
ret.jac_.reserve(Eigen::VectorXi::Constant(val.size(), 1));
|
||||||
for (typename M::Index row = 0; row < val.size(); ++row) {
|
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();
|
ret.jac_.makeCompressed();
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user