File tree Expand file tree Collapse file tree 1 file changed +5
-11
lines changed
Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Original file line number Diff line number Diff line change @@ -84,17 +84,11 @@ void System::EvalJacobian() {
8484 mat.A .num .setZero ();
8585 mat.A .num .resize (mat.m , mat.n );
8686
87- std::vector<Eigen::Triplet<double >> values (mat.A .sym .size ());
88- // Not using range-for to achieve (old) OpenMP compatibility:
89- // worth it because this profiles as taking a lot of time.
90- // Must be signed integer for MSVC.
91- const int n = (int )mat.A .sym .size ();
92- #pragma omp parallel for
93- for (int i = 0 ; i < n; ++i) {
94- const auto &exprTriplet = mat.A .sym [i];
95- double value = exprTriplet.value ()->Eval ();
96- // assigning rather than emplace_back so we don't have to stick a critical pragma in here for openmp.
97- values[i] = {exprTriplet.row (), exprTriplet.col (), value};
87+ std::vector<Eigen::Triplet<double >> values;
88+ values.reserve (mat.A .sym .size ());
89+ for (const auto &exprTriplet : mat.A .sym ) {
90+ double value = exprTriplet.value ()->Eval ();
91+ values.emplace_back (exprTriplet.row (), exprTriplet.col (), value);
9892 }
9993 mat.A .num .setFromTriplets (values.begin (), values.end ());
10094}
You can’t perform that action at this time.
0 commit comments