Re: [eigen] unpleasant surprise mit math functions |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] unpleasant surprise mit math functions
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Sat, 22 Sep 2012 22:21:11 +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:content-transfer-encoding; bh=CJnKznROG9QEc41VfsN5zEffEpEqlqHU/K/qTRDoeos=; b=lfZhgry8Rv1Eu2Q8scNHqWqNbAe8ffdZhP7SFz72sBXuGSOA7/UO5K/jwuZwVvSoT9 9HAVJ1Sr71fIdaNlwGHN3SuK538p31b/v6g+qh3I+ItVXAIqR2Jwyfk8o4kwD3II3br6 Fv63r+BlDAODyZ+Y6/T/qMFqjmvbvFw4IjcHVDphHkvTZnuPPjK9rN1h4Cqk5Dy5Lqip 42E7rtLhDtO9rr1I4gftzvveJOP4+urlAPINry/PEyW5Otx59faz9USW0w+zd5ye9R1F e8iNZQVgiAhZYYAv3r02gbst1BZRtnBu1Ps8HBEgNYV4yIItIa4W2RAaHxrFN4xGupkW gZ8g==
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
> ----------------------------------------------
>
>