Re: [eigen] unpleasant surprise mit math functions

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


Hi,

then what about declaring the math functions - applicable to Matrix/Vector classes - as private!
Just an idea,
Helmut.

On 09/22/2012 10:21:11 PM, Gael Guennebaud wrote:
Hi,

there is indeed something very strange happening. I've no idea why
sin(t) with t a VectorXd does compile. It seems it manages to directly
found Eigen::internal::sin even though VectorXd is defined in the
Eigen namespace, not Eigen::internal. This can be shown more clearly
in the following test:

#include <Eigen/Core>

namespace A {

  struct Matrix { float x; };

  namespace internal {
    template<typename T> T bar(const T& x) { return x; }
  }

}

namespace Eigen {
  namespace internal {
    template<typename T> T foo(const T& x) { return x; }
  }
}

int main()
{
  A::Matrix m;
  bar(m); // does not compile (as expected)

  Eigen::MatrixXd b;
  foo(b); // does compile (does not make sense to me)
}


I tried with both g++ and clang++. I've no clue...


gael


On Wed, Sep 19, 2012 at 3:28 PM, Christoph Hertzberg
<chtz@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> On 18.09.2012 20:25, Helmut Jarausch wrote:
>>
>> int main() {
>>    int N= 5,  m= 2;
>>    VectorXd t(N);
>>    MatrixXd A(N,m);
>>
>>    A.col(0).fill(0);
>>    t << 10, 20, 30, 40, 50;
>>    double F = 8*atan(1.0)/50;
>>    A.col(1)= sin(F*t);
>>    cout << A << endl;
>> }
>
>
> IIRC, sin(t) is only supposed to work for array expressions, so
> sin(F*t.array()) should work. However, your example should give a
> compile-time error, so this seems to be a bug.
>
> Christoph
>
>
>
>
> --
> ----------------------------------------------
> Dipl.-Inf. 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/