2

In the eigen documentation, which is generally pretty good, I see references to a rows() method of MatrixBase. I am currently trying to find a way to get the number of rows in a matrix without knowing the orientation (Row/Column-major) of the matrix so it would be really convenient to simply call rows().

But I can't find this documented anywhere. What is this method? What does it do? Does it just return Eigen::Dynamic for dynamic matrices, or does it know the number of rows?

Looking at the reference page for MatrixBase, I see several mentions of MatrixBase::rows() but no link... Any ideas?

4

2 回答 2

2

The rows() method does indeed return the numbers of rows. It is defined in the class EigenBase, of which MatrixBase is a subclass. Its documentation is at http://eigen.tuxfamily.org/dox/structEigen_1_1EigenBase.html#a5552abd83dbd03c85cea6d61fd8875a5 . One way to find it is to type "rows" in the search field in the upper right of the Eigen documentation and then to click "rows" in the popup that appears; that opens a list of rows() methods defined in the library, including EigenBase::rows().

The documentation does not say this explicitly, but the rows() method does return the actual number of rows, determined at run-time. The constant RowsAtCompileTime returns Dynamic for dynamic-size matrices and the number of rows for static-size matrices.

The mentions to MatrixBase::rows() in the documentation is a remnant of the past that needs to be eliminated. Thanks for your compliments about the documentation, but we know it can be improved.

于 2014-06-30T08:49:18.043 回答
1

好吧,MatrixBase是从DenseBase哪个派生而来的,而后者又是从DenseCoeffBase(使用模板参数等)派生而来的。row() 函数在那里定义:http ://eigen.tuxfamily.org/dox/structEigen_1_1EigenBase.html#a5552abd83dbd03c85cea6d61fd8875a5

Doxygen 说该函数返回“行数”。

于 2014-06-30T08:43:39.190 回答