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 29.08.2014 17:55, Thomas Capricelli wrote:
Il 28/08/2014 22:31, Jitse Niesen ha scritto:Sorry, I should probably have waited for your feedback instead of jumping the gun and merging it.No, it's ok, you did well.static Scalar sqrt_(const Scalar& x) { using std::sqrt; return sqrt(x); } If Scalar is a custom type like mpreal which is defined in its own namespace, then this function also looks for sqrt in that namespace (I think it's called argument-dependent lookup). For standard types there is no difference.You mean that { using std::sqrt; return sqrt(x); } will use std::sqrt() only when sqrt(someothertype) is not previously defined ?
If Scalar is defined in namespace X and X::sqrt exists, it will use X::sqrt, otherwise, or if Scalar is not in any namespace, it will (try to) fall back to std::sqrt (I never, really understood every detail, which rule overrules which; especially, what happens if a conflicting definition exists in global scope.)
wikipedia has an article about ADL (maybe the links show more details): http://en.wikipedia.org/wiki/Argument-dependent_name_lookupRegarding 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.
Christoph -- ---------------------------------------------- Dipl.-Inf., Dipl.-Math. Christoph Hertzberg Cartesium 0.049 Universität Bremen Enrique-Schmidt-Straße 5 28359 Bremen Tel: +49 (421) 218-64252 ----------------------------------------------
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |