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 ]

*To*: eigen <eigen@xxxxxxxxxxxxxxxxxxx>*Subject*: Re: [eigen] Re: [Bitbucket] Pull request #80: Allow LevenbergMarquardt to work with non-standard types. (eigen/eigen)*From*: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>*Date*: Tue, 2 Sep 2014 11:13:51 +0200*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=NE19E8WJ44RvqnUoE5xwiDghL3AeC/KEDHJ0U1bEyyU=; b=SyRrinvbBIcSl425up8S+j1tRensy8pC/eNxyIq3a/j7WSbGjNgMMn5QPqoJSH99LD dhFmNr4YA/UNY+MbgdSePU1cuH7tseoY71ibm3lml4kd7PbO/U3+prPGScUFBt07ZXIB brp7Lyuq36yYggdqBh67DdVyuYs170Ca2imOHf9eBOQha3ark8b4k7zYGXCvaWG5b1xH GqUuEm8mW1cGkLVNrstwKd6W/V10LICdmqdNSLK3eFIS0kwICnOZDkPmq6y8yicxgF9H fvAOraWnPwITuPW05WRgBTteC5G37mRoYfOykpZeMzq0pq+/y5/XkkHO9BbPC1Xj5ZrN idVw==

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

**Follow-Ups**:

**Messages sorted by:**[ date | thread ]- Prev by Date:
**[eigen] Formulas in online docs not working** - Next by Date:
**Re: [eigen] EigenLab: C++ run-time matrix math ala MATLAB.** - Previous by thread:
**Re: [eigen] Formulas in online docs not working** - Next by thread:
**Re: [eigen] Re: [Bitbucket] Pull request #80: Allow LevenbergMarquardt to work with non-standard types. (eigen/eigen)**

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