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 ]
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/ |