2

这是我的代码:

#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/Eigen/src/Core/util/XprHelper.h:53: Eigen::internal::variable_if_dynamic::variable_if_dynamic(T) [with T = int; int Value = 1]:断言 `v == T(Value)' 失败。中止(核心转储)

似乎问题在于.row()ColMajor 矩阵;但是,我不明白为什么这会导致错误,或者为什么.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/eigen3/Eigen/src/Core/util/XprHelper.h:53: Eigen::internal::variable_if_dynamic::variable_if_dynamic(T) [with T = int; int Value = 1]:断言 `v == T(Value)' 失败。中止

4

1 回答 1

0

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

于 2015-04-06T14:50:31.117 回答