Re: [eigen] eigen sqrt compilation error |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] eigen sqrt compilation error
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Fri, 19 Jun 2009 12:44:21 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=RogMBN67D/+yRJq9afLJF3YG8izN5F+VkeE0Gfcy+sc=; b=OOeW7xXwQdpPr455RIR8The1E1mtUEEo0qKqxPpS8/gczEFVIo6wG8F+GzZnDjaGju zu4Tn7cKULjDtInvF3Uko0xdB4C3u/LoNZGSuTqnpUEc/R8TL4VcjuG+r9F2e7GFP1ep HXhpPUJ1qcln3y2qb3tbIJlblyCbJF6atxD1M=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=WVQXTW8RXOWEIKAhoJYtqWXFS+KZys4YlqKjLIK7giEEjH5/XBqZjNVnwXiahJauFa LDm9PmAVSvrBgZokr4N8HrlFERoYxyq88dNK7WGpL0C+TP/G+nLNWOHA25kX6hh7XWf2 MAs3liMflhePBmlGrYlBH9M+ujwlAfICuRpWk=
On Fri, Jun 19, 2009 at 12:29 PM, Patrick Mihelich
<patrick.mihelich@xxxxxxxxx> wrote:
>
> On Fri, Jun 19, 2009 at 12:37 AM, Moritz Lenz <mlenz@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>>
>> Considering the number of times people make this error (forgetting to include it), what about including it by default? Is there a very good reason not to do it?
>
> I wonder this too. I ran into this error when I started using Eigen, and it seems to pop up regularly on the list. What exactly is the cost of including <Eigen/Array> in the core? How much does it increase compile times?
on my high end computer with gcc 4.3.2 -O2 -DNDEBUG, much less time
than to compile: Vector3f a, b; cout << a+b;, so something around 0.02
sec.
>
> Documentation is good, but it is still too easy to use the Eigen API incorrectly like this, and the error messages are no help.
>
> Awhile back I suggested a trick based on default arguments, which is a little ugly but does massively improve the error messages. Here it is again:
>
> // Changes to MatrixBase
> template<typename Derived> class MatrixBase
> {
> private:
> struct ERROR_YOU_MUST_INCLUDE_Eigen_Array {};
>
> public:
> const PartialRedux<Derived, Horizontal> rowwise(ERROR_YOU_MUST_INCLUDE_Eigen_Array) const;
> };
>
> // Changes to implementation in Array module
> // Defining the default argument here changes the function signature, allowing matrix.rowwise()
> template<typename Derived>
> const PartialRedux<Derived,Horizontal> MatrixBase<Derived>::rowwise(ERROR_YOU_MUST_INCLUDE_Eigen_Array = ERROR_YOU_MUST_INCLUDE_Eigen_Array()) const
> {
> /* implementation */
> }
>
> Then when the user includes <Eigen/Array>, he effectively gets the expected zero-arg version of rowwise. If he forgets to include it, no zero-arg version exists, so mat.rowwise() should produce a compiler error along the lines of:
>
> error: no matching function for call to 'MatrixBase<Derived>::rowwise()'
> note: candidates are: const PartialRedux<Derived, 0> MatrixBase<Derived>::rowwise(MatrixBase<Derived>::ERROR_YOU_MUST_INCLUDE_Eigen_Array) const
>
> As usual you can wrap the dummy argument in a macro to selectively hide it from doxygen.
>
> Cheers,
> Patrick