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

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]



I would simply put "using std::sqrt;" in every functions making use of sqrt, as we currently do everywhere else in Eigen, and remove this locally defined sqrt_. This approach is future proof, simple, nothing is hidden.

gael


On Sun, Aug 31, 2014 at 1:06 AM, Jitse Niesen <jitseniesen@xxxxxxxxx> wrote:
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 http://listengine.tuxfamily.org/lists.tuxfamily.org/eigen/2012/09/msg00026.html )
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.


Jitse





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/