0
votes

I'm trying to use the EIGEN libs. In particular I'm using the SVD.

After the calculation of the singular values I need to perform this operation:

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

which is a vector dived by a scalar.

My questions are:

1) Why this operation gives me:

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) How can i copy the values contained into svd.singularValues().row(1) in standard "double" variable?

1

1 Answers

1
votes

Note that svd.singularValues().row(1) is not a scalar but a 1x1 matrix, which is why your code does not compile. Solution:

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

and also note that as usual in C/C++, Eigen's matrices and vectors are 0-based indexed, so if you want to normalize by the largest singular values you should do:

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