2017-06-06 42 views
0

我正在嘗試使用EIGEN庫。特別是我正在使用SVD。Eigen SVD雙鑄

我需要執行此操作的奇異值的計算之後:

svd.singularValues()/svd.singularValues().row(1) 

它是由一個標量跌的載體。

我的問題是:

1)爲什麼這種操作給我:

main.cpp:149:56: error: no match for ‘operator/’ (operand types are ‘const SingularValuesType {aka const Eigen::Matrix}’ and ‘Eigen::DenseBase >::ConstRowXpr {aka const Eigen::Block, 1, 1, false>}’)

2)我怎樣才能複製到包含在標準的 「雙」 變量svd.singularValues().row(1)值是多少?

回答

1

請注意,svd.singularValues().row(1)不是一個標量,而是一個1x1矩陣,這就是爲什麼你的代碼不能編譯。解決方案:

svd.singularValues()/svd.singularValues()(1) 

也注意到,在C/C++往常一樣,艾根的矩陣和向量是基於0的索引,所以如果你想用最大的奇異值恢復正常,你應該做的:

svd.singularValues()/svd.singularValues()(0)