printSparseMatrix(): Use InnerIterator rather than index

This way, we're (slightly) more agnostic to the inner storage scheme.
This commit is contained in:
Bård Skaflestad 2013-05-06 14:09:48 +02:00
parent c9d65f8c28
commit 0058e34aec

View File

@ -108,18 +108,15 @@ namespace {
{
typedef Eigen::SparseMatrix<double>::Index Index;
const Index* const p = A.outerIndexPtr();
const Index* const i = A.innerIndexPtr();
const double* const x = A.valuePtr();
const Index osize = A.outerSize();
const Index cols = A.outerSize();
assert (A.innerSize() == cols);
for (Index j = 0; j < cols; j++) {
for (Index k = p[j]; k < p[j + 1]; k++) {
for (Index k = 0; k < osize; ++k) {
for (Eigen::SparseMatrix<double>::InnerIterator
i(A, k); i ; ++i) {
std::fprintf(fp, "%lu %lu %26.18e\n",
static_cast<unsigned long>(i[k] + 1),
static_cast<unsigned long>(j + 1), x[k]);
static_cast<unsigned long>(i.row() + 1),
static_cast<unsigned long>(i.col() + 1),
i.value());
}
}
}