I have read the documentation on Writing Functions Taking Eigen Types as Parameters, and since all my Eigen containers are Arrays I decided to create a function prototype like this:
template <typename Derived>
void Threshold(Eigen::DenseBase<Derived>& params)
// I tried void Threshold(Eigen::ArrayBase<Derived>& params) as well, same outcome
{
params = (params >= 0.0f).template cast<float>();
}
The problem is, when I call this function like this:
Eigen::Array<float, Eigen::Dynamic, Eigen::Dynamic> arr;
// fill it with stuff
Threshold(arr.col(0)); // error!
I get the following error:
no known conversion for argument 1 from ‘Eigen::DenseBase<Eigen::Array<float, -1, -1>
>::ColXpr {aka Eigen::Block<Eigen::Array<float, -1, -1>, -1, 1, true>}’ to
‘Eigen::DenseBase<Eigen::Block<Eigen::Array<float, -1, -1>, -1, 1, true> >&’
Is my function template wrong? How do I pass the output of the .col()
method of an Eigen::Array
object to a function?