连续修剪的产品崩溃EIGEN
Successive pruned product crashing EIGEN
我有一个错误,我在使用Eigen和SparseMatrix以及Visual Studio Pro 2013时无法理解
连续修剪的产品在 DEBUG 模式下完美运行,但它们很长。我想切换到 RELEASE,而不更改代码中的任何内容,但程序在这种模式下崩溃。
我遇到了访问冲突错误c0000005
(法语VS,对此感到抱歉(:
Message de résultat : Code de l'exception : C0000005
StackTrace de résultat :
à Eigen::internal::sparse_sparse_product_with_pruning_impl<Eigen::SparseMatrix<short,0,int>,Eigen::SparseMatrix<short,0,int>,Eigen::SparseMatrix<short,0,int> >() dans [..]eigensrcsparsecoresparsesparseproductwithpruning.h:ligne 61
à Eigen::internal::sparse_sparse_product_with_pruning_selector<Eigen::SparseMatrix<short,1,int>,Eigen::SparseMatrix<short,1,int>,Eigen::SparseMatrix<short,0,int>,1,1,0>::run() dans [..]eigensrcsparsecoresparsesparseproductwithpruning.h:ligne 143
à Eigen::internal::unary_evaluator<Eigen::SparseView<Eigen::Product<Eigen::SparseMatrix<short,1,int>,Eigen::SparseMatrix<short,1,int>,2> >,Eigen::internal::IteratorBased,short>::unary_evaluator<Eigen::SparseView<Eigen::Product<Eigen::SparseMatrix<short,1,int>,Eigen::SparseMatrix<short,1,int>,2> >,Eigen::internal::IteratorBased,short>() dans [..]eigensrcsparsecoresparseproduct.h:ligne 158
à Eigen::SparseMatrix<short,1,int>::operator=<Eigen::SparseView<Eigen::Product<Eigen::SparseMatrix<short,1,int>,Eigen::SparseMatrix<short,1,int>,2> > >() dans [..]eigensrcsparsecoresparsematrix.h:ligne 1080
à IncMethod_Tester::EigenMatrix_Tests::NullMultiplication() dans [...]integrity_tests.cpp:ligne 856
integrity_test测试的代码如下:
SparseMatrix<short, RowMajor> A(0, 1);
SparseMatrix<short, RowMajor> B(1, 5);
SparseMatrix<short, RowMajor> C(5, 4);
std::vector<Triplet<short>> values;
values.push_back(Triplet<short>(0, 4, 1));
values.push_back(Triplet<short>(0, 3, 1));
values.push_back(Triplet<short>(0, 2, 1));
B.setFromTriplets(values.begin(), values.end());
std::vector<Triplet<short>> values2;
values2.push_back(Triplet<short>(0, 0, 1));
values2.push_back(Triplet<short>(1, 1, 1));
values2.push_back(Triplet<short>(2, 2, -1));
values2.push_back(Triplet<short>(2, 3, -1));
values2.push_back(Triplet<short>(3, 2, 1));
values2.push_back(Triplet<short>(4, 3, 1));
C.setFromTriplets(values2.begin(), values2.end());
std::fstream f("NULLMULTIPLICATION", std::fstream::out);
f << "A MATRIX (" << A.rows() << "," << A.cols() << ")" <<std::endl << A << std::endl;
f << "B MATRIX (" << B.rows() << "," << B.cols() << ")" <<std::endl<< B << std::endl;
f << "C MATRIX (" << C.rows() << "," << C.cols() << ")" << std::endl << C << std::endl;
B = (A*B).pruned();
f << "AB MATRIX (" << B.rows() << "," << B.cols() << ")" << std::endl << A << std::endl;
B = (B*C).pruned();
f << "B MATRIX (" << B.rows() << "," << B.cols() << ")" << std::endl << B << std::endl;
NULLMULTIPLICATION
文件中的输出是:
A MATRIX (0,1)
B MATRIX (1,5)
0 0 1 1 1
C MATRIX (5,4)
1 0 0 0
0 1 0 0
0 0 -1 -1
0 0 1 0
0 0 0 1
AB MATRIX (0,5)
这意味着程序运行到:
B = (A*B).pruned();
B = (B*C).pruned();
我在这里做错了什么吗?我尝试创建临时变量,但它仍然崩溃:
SparseMatrix<short, RowMajor> D = (A*B).pruned();
SparseMatrix<short, RowMajor> E = (D*C).pruned();
对此产品有什么建议吗?我可能在多个稀疏产品的语法上是错误的?
提前谢谢。
好的,
我找到了导致错误的原因。这是由于修剪产品中的维度为 0,我只是通过在产品之前测试所涉及的任何矩阵是否具有空维度来解决它,如果是这样,只需在不修剪的情况下做一个普通产品。
相关文章:
- 当回溯以零开始时,如何调试崩溃
- Eigen如何在容器循环中干净地附加矩阵
- 当在带有Eigen的C++中使用GDB时,我如何才能看到更多的大矩阵
- 内联映射初始化的动态atexit析构函数崩溃
- 执行函数时导致崩溃的变量
- 程序崩溃并显示"std::out_of_range"错误
- CoInitialize()在单独的线程上崩溃而不返回
- 使用调试/崩溃报告将应用程序部署到客户端
- 使用Pybind11向Python公开Eigen::张量
- 为什么所有C++编译器都会崩溃或挂起此代码
- 为什么lambda在clang上崩溃而不是在gcc上崩溃
- 为什么我的多线程作业队列崩溃
- ExtractIconEx:可以工作,但偶尔会崩溃
- 如何在没有数据拷贝的情况下从指针创建一个Eigen VectorXd对象
- 为什么引用传递会导致此崩溃(C++)
- 试图创建流或fopen时程序崩溃
- Eigen:调用lpNorm()的正确方法
- 类对象数组的问题会导致崩溃
- 连续修剪的产品崩溃EIGEN
- Visual Studio 2013 崩溃时我试图编译 Eigen