Reputation: 86276
Here is my code:
#include <iostream>
#include <Eigen/Sparse>
using namespace Eigen;
int main()
{
int n_rows=4, n_cols=3, nnz=5;
int outer_index[] = {0,1,3,5};
int inner_index[] = {0,2,3,1,2};
double values[] = {1,1,1,1,1};
MappedSparseMatrix<double> u2i(n_rows, n_cols, nnz, outer_index, inner_index, values);
std::cout << u2i << std::endl;
std::cout << u2i.col(1) << std::endl; // works fine
//std::cout << u2i.row(1) << std::endl; // fails
return 0;
}
This is the error message I get when I try std::cout << u2i.row(1) << std::endl;
my_exec: /usr/include/Eigen/src/Core/util/XprHelper.h:53: Eigen::internal::variable_if_dynamic::variable_if_dynamic(T) [with T = int; int Value = 1]: Assertion `v == T(Value)' failed. Aborted (core dumped)
It seems that the issue is calling .row()
on the ColMajor matrix; however, I don't see why this should cause an error, or then why is .row()
method is allowed at all?
If I am not missing anything in my implementation, what's going on here?
I am using Eigen 3.2.2.
Edit:
Apparently this also fails with SparseMatrix
as well.
#include <Eigen/Sparse>
#include <Eigen/Dense>
#include <iostream>
int main()
{
using namespace Eigen;
Matrix<int64_t, Dynamic, Dynamic> temp(6, 5);
temp << 0, 1, 0, 3, 4,
0, 1, 0, 0, 0,
0, 0, 0, 0, 0,
2, 1, 0, 0, 3,
0, 2, 0, 0, 1,
1, 0, 0, 1, 0;
SparseMatrix<int64_t> temp_sparse = temp.sparseView();
std::cout << temp_sparse.row(5) << std::endl;
return 0;
}
Error message (same):
test_calc_top_actions.exe: /usr/include/eigen3/Eigen/src/Core/util/XprHelper.h:53: Eigen::internal::variable_if_dynamic::variable_if_dynamic(T) [with T = int; int Value = 1]: Assertion `v == T(Value)' failed. Aborted
Upvotes: 2
Views: 531