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.
This commit is contained in:
Bård Skaflestad 2013-05-22 11:26:49 +02:00
parent 04e51491ee
commit 6d0202d529

View File

@ -381,13 +381,11 @@ collapseJacs(const AutoDiff::ForwardBlock<double>& x)
int block_col_start = 0; int block_col_start = 0;
for (int block = 0; block < nb; ++block) { for (int block = 0; block < nb; ++block) {
const ADB::M& jac = x.derivative()[block]; const ADB::M& jac = x.derivative()[block];
// ADB::M is column major for (ADB::M::Index k = 0; k < jac.outerSize(); ++k) {
for (int col = 0; col < jac.cols(); ++col) { for (ADB::M::InnerIterator i(jac, k); i ; ++i) {
for (int elem = jac.outerIndexPtr()[col]; t.push_back(Tri(i.row(),
elem < jac.outerIndexPtr()[col + 1]; i.col() + block_col_start,
++elem) { i.value()));
const int row = jac.innerIndexPtr()[elem];
t.emplace_back(row, block_col_start + col, jac.valuePtr()[elem]);
} }
} }
block_col_start += jac.cols(); block_col_start += jac.cols();