Re: [eigen] conservative resize ... |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] conservative resize ...
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Tue, 8 Sep 2009 09:11:39 -0400
- 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=xmqj3njcej5a1ebhN8e+NAJt2Te/Dknr9b6mgvEQpFU=; b=vny8g93Xes83ifj+nwN9/JumAryL2x+vWHu/TaaQ4mJ6enWkmpEE2Mwz5f65Y394Rv lwvBPQOXYXOwnME7A+hiSyv8JnihvXRv6mmbm+a7LSCqFWLZ2hZ/5tq8RLnN7Mj9cFXx +qXAy0RC2uTd7uxwNZaKM6/Yz/rg0lwNTyYiU=
- 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=ZoeNWyzHjDTcdBZ46HoNG4RpMcjEOwnp/aYlt9yzAJAAFFc6x0U3ixUvC1rL6lU5me BclbfRXpEYZuPvMXfjTLWqM+0LpbfhtUtseKjQRUh5XpPZMvY9wj/WfNMwzvzl6/mtl0 U/SzQBPgw1CX1Jb5hOum0HYD4IQ3prBZX6k08=
I had a look: the code still is quite small, not yet too big to stay
in Matrix.h.
The forward-decl of ei_conservative_resize_like_impl is a little ugly,
true, what you could do is to defer the body of conservativeResizeLike
until after the class Matrix definition, so you don't need to
forward-declare ei_conservative_resize_like_impl.
Benoit
2009/9/8 Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>:
> Sorry again for the gcc bugs.... they should be fixed by now.
>
> I am still confused, whether it is a good idea to start polluting the
> Matrix.h with expressions and forward declarations.
>
> - Hauke
>
> On Mon, Sep 7, 2009 at 5:50 PM, Hauke Heibel<hauke.heibel@xxxxxxxxxxxxxx> wrote:
>> ok, it's in.
>>
>> On Mon, Sep 7, 2009 at 4:47 PM, Benoit Jacob<jacob.benoit.1@xxxxxxxxx> wrote:
>>> Ah, the meta-selector to choose between the two paths for that function..
>>>
>>> Since that's specific to that function, it shouldn't go in
>>> XprHelpers.h, instead it should go in the same file where (the rest
>>> of) that function is implemented.
>>>
>>> The way we usually do it is rather:
>>>
>>> template <typename Derived, typename OtherDerived, int IsVector =
>>> Derived::IsVectorAtCompileTime>
>>> struct resize_helper
>>> {
>>> static void run(const Eigen::MatrixBase<Derived>& _this, const
>>> Eigen::MatrixBase<OtherDerived>& other)
>>> {
>>> std::cout << "Matrix assignment" << std::endl;
>>> }
>>> };
>>>
>>> template <typename Derived, typename OtherDerived>
>>> struct resize_helper<Derived, OtherDerived,true>
>>> {
>>> template <typename Derived, typename OtherDerived>
>>> static void run(const Eigen::MatrixBase<Derived>& _this, const
>>> Eigen::MatrixBase<Derived>& other)
>>> {
>>> std::cout << "Vector assignment" << std::endl;
>>> }
>>> };
>>>
>>> Then you can call it like resize_helper(a,b) and let all the template
>>> parameters be resolved implicitly. This is less error-prone than
>>> having to manually specify IsVector. Also note how we usually don't
>>> put "xpr" in names since otherwise we'd have "xpr" about everywhere.
>>>
>>> Benoit
>>>
>>> 2009/9/7 Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>:
>>>> On Mon, Sep 7, 2009 at 4:28 PM, Benoit Jacob<jacob.benoit.1@xxxxxxxxx> wrote:
>>>>> There already is: MatrixBase<T>::IsVectorAtCompileTime.
>>>>
>>>> yes, i know.
>>>>
>>>> i was thinking about something like this...
>>>>
>>>> template <int IsVector>
>>>> struct resize_xpr_helper
>>>> {
>>>> template <typename Derived, typename OtherDerived>
>>>> static void run(const Eigen::MatrixBase<Derived>& _this, const
>>>> Eigen::MatrixBase<OtherDerived>& other)
>>>> {
>>>> std::cout << "Matrix assignment" << std::endl;
>>>> }
>>>> };
>>>>
>>>> template <>
>>>> struct resize_xpr_helper<1>
>>>> {
>>>> template <typename Derived, typename OtherDerived>
>>>> static void run(const Eigen::MatrixBase<Derived>& _this, const
>>>> Eigen::MatrixBase<Derived>& other)
>>>> {
>>>> std::cout << "Vector assignment" << std::endl;
>>>> }
>>>> };
>>>>
>>>> - hauke
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>
>
>