Re: [eigen] min(Arr1,Arr2) is it supposed to work? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] min(Arr1,Arr2) is it supposed to work?
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Mon, 4 Apr 2011 16:23:54 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type:content-transfer-encoding; bh=tYTGddg63ZfFdFeHKu663r4kaMUDQzDj2PvOPxgLapk=; b=QeMqFff1iCUoQtmjyUnNaSrP8gAFvLWglv1kbVK0mp91OR+V9CAqQqOpKShKfCB4Za 49OL3/a7rx8ZqHj1dQEOH7RT+CmKyk8ZvhYZo9OKcoGRBO7XsY1vVA+1BiNkNsgGx9Zl JKTDUZ1QgCfah0UZbaWnuHh/mSUD1QpAWMj+4=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=Yhk6H9acLPotRSWTLn3JLARF4z4Ncuek844F/v5W30BmP7DXH/lNneMyqIhISBHa2A 4ZMldPq9MIujOPi6ZLKxQW7aVijoHlcmQCVhZke4ieuiQahGLjaLRDI50HnSAX8+ewK2 3OGxA0mQGPsD6u56i7TAOS6DL5CwSA5UX2nw8=
oops, indeed the quick ref guide is again in advance with Eigen
development. Actually, it seems to be impossible for us to support
std::min(array1,array2) because std::min is implemented in a generic
way as:
template<typename _Tp> inline const _Tp& min(const _Tp& __a,
const _Tp& __b)
{
if (__b < __a)
return __b;
return __a;
}
therefore we cannot overload std::min for min(const
ArrayBase<T>&,const ArrayBase<T>&). To do so we would need overloads
for every expressions (Array<>, CwiseUnaryOp, CwiseBinaryOp, etc.).
I'm fixing the doc.
gael
On Fri, Apr 1, 2011 at 9:23 AM, Helmut Jarausch
<jarausch@xxxxxxxxxxxxxxxxxxx> wrote:
> Hi,
>
> is the following assumed to work (I saw it in the Quick Reference
> Guide)
>
> #include <Eigen/Core>
> #include <cmath>
> given
> Eigen::Array3f V1, V2, V3;
> V1 << 1,2,3;
> V2 << 2,1,5;
> V3= V1.min(V2); // this works
> V3= std::pow(V1,2); // this works, as well
>
> V3= std::min(V1,V2); // but this fails, see below
> cout << V3 << endl;
> }
>
> Tmin.C:14:21: instantiated from here
> /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/include/g++-v4/bits/
> stl_algobase.h:191:7: error: could not convert '((const
> Eigen::ArrayBase<Eigen::Array<float, 3, 1> >*)((const
> Eigen::Array<float, 3, 1>*)__b))->Eigen::ArrayBase<Derived>::operator<
> [with OtherDerived = Eigen::Array<float, 3, 1>, Derived =
> Eigen::Array<float, 3, 1>, typename Eigen::internal::traits<T>::Scalar
> = float](((const Eigen::ArrayBase<Eigen::Array<float, 3, 1> >&)((const
> Eigen::ArrayBase<Eigen::Array<float, 3, 1> >*)((const
> Eigen::Array<float, 3, 1>*)__a))))' to 'bool'
>
>
> Thanks for some info,
> Helmut.
>
>
>