From 6d0202d5299cd7d91d80d1e9fbc59020c30a80d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Wed, 22 May 2013 11:26:49 +0200 Subject: [PATCH] collapseJacs(): Don't assume column-major ordering The 'InnerIterator' is ordering agnostic, so there is no need to assume that the Jacobians are stored in a particular ordering. --- opm/autodiff/AutoDiffHelpers.hpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/opm/autodiff/AutoDiffHelpers.hpp b/opm/autodiff/AutoDiffHelpers.hpp index bbe305cdf..08787088d 100644 --- a/opm/autodiff/AutoDiffHelpers.hpp +++ b/opm/autodiff/AutoDiffHelpers.hpp @@ -381,13 +381,11 @@ collapseJacs(const AutoDiff::ForwardBlock& x) int block_col_start = 0; for (int block = 0; block < nb; ++block) { const ADB::M& jac = x.derivative()[block]; - // ADB::M is column major - for (int col = 0; col < jac.cols(); ++col) { - for (int elem = jac.outerIndexPtr()[col]; - elem < jac.outerIndexPtr()[col + 1]; - ++elem) { - const int row = jac.innerIndexPtr()[elem]; - t.emplace_back(row, block_col_start + col, jac.valuePtr()[elem]); + for (ADB::M::Index k = 0; k < jac.outerSize(); ++k) { + for (ADB::M::InnerIterator i(jac, k); i ; ++i) { + t.push_back(Tri(i.row(), + i.col() + block_col_start, + i.value())); } } block_col_start += jac.cols();