This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 1754 - sparseView returns invalid sparse matrix
Summary: sparseView returns invalid sparse matrix
Status: NEW
Alias: None
Product: Eigen
Classification: Unclassified
Component: Sparse (show other bugs)
Version: 3.3 (current stable)
Hardware: x86 - general Windows
: Normal Wrong Result
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-09 04:01 UTC by Xinya Zhang
Modified: 2019-12-04 18:49 UTC (History)
2 users (show)



Attachments
Package of code, build script (under Visual Studio Developer Command Prompt), and built x64 binaries (175.64 KB, application/x-zip-compressed)
2019-10-09 04:01 UTC, Xinya Zhang
no flags Details

Description Xinya Zhang 2019-10-09 04:01:00 UTC
Created attachment 955 [details]
Package of code, build script (under Visual Studio Developer Command Prompt), and built x64 binaries

The following code fails on VS 2017/2019, Eigen 3.3.7/TIP (323c052e1731/70e55a287bfe), x86/x64
Expected behavior: exit without showing anything.
Actual behavior: Assertion failed: it.row() < xm, file test_case.cc, line 17
Note: cannot reproduce on Linux. GCC works fine.

#include "assert.h"
#include <vector>

#include <Eigen/Core>
#include <Eigen/SparseCore>

constexpr int K = 4;
typedef Eigen::Triplet<double> Tri;

void iter(const Eigen::SparseMatrix<double>& X)
{
	int xm = X.rows();
	int xn = X.cols();
	for (int k = 0; k < X.outerSize(); ++k) {
		for (typename Eigen::SparseMatrix<double>::InnerIterator it(X, k); it; ++it) {
			assert(it.row() >= 0);
			assert(it.row() < xm);
			assert(it.col() >= 0);
			assert(it.col() < xn);
		}
	}
}

int main()
{
	Eigen::SparseMatrix<double> M(K, K);
	std::vector<Tri> tris;
	tris.reserve(K);
	for (int i = 0; i < K; i++)
		tris.emplace_back(i, i, 1.0);
	M.setFromTriplets(tris.begin(), tris.end());
	const Eigen::SparseMatrix<double> Aeq = M.diagonal().transpose().sparseView();
	iter(Aeq);

	return 0;
}
Comment 1 Nobody 2019-12-04 18:49:15 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/1754.

Note You need to log in before you can comment on or make changes to this bug.