为什么对ColMajor MappedParseMatrix调用.row()方法失败

Why does calling .row() method on ColMajor MappedSparseMatrix fail?

本文关键字:方法 失败 row 调用 ColMajor MappedParseMatrix 为什么      更新时间:2023-10-16

这是我的代码:

#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;
}

这是我尝试std::cout << u2i.row(1) << std::endl; 时收到的错误消息

my_exec:/usr/include/Egengin/src/Core/util/XprHelper.h:53:特征::internal::variable_if_dynamic::variable_idf_dynomic(T)[withT=int;int Value=1]:断言"v==T(Value)"失败。中止(堆芯转储)

问题似乎是在ColMajor矩阵上调用.row();然而,我不明白为什么这会导致错误,或者为什么.row()方法是允许的?

如果我在实现中没有遗漏任何内容,那么这里发生了什么?

我使用的是特征3.2.2。

编辑:

显然,这在SparseMatrix中也失败了。

#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;
}

错误消息(相同):

test_calc_top_actions.exe:/usr/include/igen3/Eigen/src/Core/util/XprHelper.h:53:特征::internal::variable_if_dynamic::variable_idf_dynomic(T)[withT=int;int Value=1]:断言"v==T(Value)"失败。中止

此代码在最新版本(3.2.4)的运行时仍然失败。此处报告了错误,上游已经有修复程序(但尚未发布)。