Eigen::VectorXdhas Scalar operator()(Index i), which returns the coefficient in the index iin the vector. However, since it Eigen::VectorXdis a special type Eigen::Matrix, that is, a type Eigen::Matrix<Scalar, Eigen::Dynamic, 1>;also exists Scalar operator()(Index i, Index j).
Question:
Can it be considered safe (i.e., undefined behavior) to use the second version if I set it jto zero? In other words, is the code below OK?
Eigen::VectorXd v(4);
v << 1, 2, 3, 4;
std::cout << v(2, 0);
It seems that everything is in order, there are no failed statements or warnings when compiling in debug mode with all warnings, but I'm not 100% sure.
source
share