2014-09-19 36 views
2

這裏是我的代碼:爲什麼在ColMajor MappedSparseMatrix上調用.row()方法失敗?

#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: Eigen :: internal :: variable_if_dynamic :: variable_if_dynamic(T) [with T = int; int Value = 1]:斷言`v == T(Value)'失敗。 中止(核心轉儲)

看來這個問題呼籲.row()在ColMajor矩陣;但是,我不明白爲什麼這應該導致錯誤,或者爲什麼.row()方法是允許的呢?

如果我在執行過程中沒有丟失任何東西,這裏發生了什麼?

我正在使用Eigen 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: 本徵::內部:: variable_if_dynamic :: variable_if_dynamic(T) [with T = int; int Value = 1]:斷言`v == T(Value)'失敗。 Aborted

+0

不足以成爲答案,但發佈的代碼只有'outer_index'中的四個元素,與'nnz = 5'和'inner_index'和'values'中的每個元素中的五個元素進行比較。 – 2014-09-19 18:03:07

+0

@DavidHammen,這是存儲如何與MappedSparseMatrx格式;它與'SparseMatrix'不同。 – Akavall 2014-09-19 18:14:47

+0

'MappedSparseMatrix'是'壓縮稀疏列'類型的稀疏矩陣,如果它是ColMajor。 – Akavall 2014-09-19 18:23:31

回答

0

此代碼在運行時仍然無法使用最新版本(3.2.4)。該錯誤報告爲here,並且上游已有修復程序(但尚未發佈)。

相關問題