Re: [eigen] Re: [Bitbucket] Pull request #80: Allow LevenbergMarquardt to work with non-standard types. (eigen/eigen)

[ Thread Index | Date Index | More Archives ]

On Fri, 29 Aug 2014, Christoph Hertzberg wrote:

Regarding the pull-request: Wouldn't it be better to define sqrt once in the Eigen::numext namespace, and always use that? I don't think we should define a sqrt_ function in every module that needs it.

I like the idea, though the discussion we had two years ago (starting with )
makes me rather nervous.

I am also not sure how to implement this. The straightforward attempt would be:

namespace numext {
  template <typename Scalar> Scalar sqrt(Scalar x) {
     using std::sqrt; return sqrt(x);

However, I think the sqrt inside the function body is ambiguous because of the presence of Eigen::numext::sqrt. Should we rename Eigen::numext::sqrt to e.g. sqrt_ (this is what the patch which I merged did)? Alternatively, perhaps we can exploit the overload rules to resolve this ambiguity but that seems rather fragile.


Mail converted by MHonArc 2.6.19+