Re: [eigen] feature request: implement hybrid matrix class template |

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

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] feature request: implement hybrid matrix class template*From*: Adrien Escande <adrien.escande@xxxxxxxxx>*Date*: Tue, 2 Jan 2018 23:56:25 +0900*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=DS2hNpJeoB+hAs7wDcRQlJL5R/c3YsaKboS1Rjo/KC0=; b=L9TuVevF+Aucg3qkdaRvjRDtVKhYBdIdxOyJx5zXjbMzaddzvs5hwFQUOtvdgSEDuy /VC+uO+zBiT7cQwzpl8cUNdauYZp8ohnQM3D7HWVG+5rt38maAwZPXKr2Rf2PZaHD9Hg jJx2WxL3SsSbRmwbS5PXHvmunx83IHw+m0zZwpxoYgAP0STrAqFqM1Q2IlOAboNC4BwU Uc65iYrlaD6uUaeoVmpVihGI/dbJrFvvET04R/Z9FMCLc0JDv7l7xhIH9cDRnV4/Ij2K 9BQoASDdAKc/KXlqhCucZ8dykxo6/HOOUeoeHkfUmX4lR4gs6753cEwxMhWjKxc5Vnke CUaw==

Hi Vincent, Andre,

> I think Hybrid Matrix is better name because it means fix size on stack and dynamic matrix size.

*template<typename Scalar, int r, int c>*

using HybridMatrix = Matrix<Scalar, Dynamic, Dynamic, 0, r, c>;

*HybridMatrix<int, 6, 8> A(3,4);*

*template<typename Type, int M, int N, int SO = RowMajor>*

using HybridMatrix = Matrix<Type, Dynamic, Dynamic, SO, M, N>;

Names are quite subjective. Presumably you are used to blaze terminology where static and dynamic matrix are implemented in distinct classes, so that the term hybrid makes sense. Before this conversation, I would have been clueless as to what a HybridMatrix could be.

Anyway, if you are using c++11 or later, you can declare the following, **in the Eigen namespace**:

using HybridMatrix = Matrix<Scalar, Dynamic, Dynamic, 0, r, c>;

and use HybridMatrix the same way as in blaze:

You can even declare the following to get as close as possible to the blaze object

using HybridMatrix = Matrix<Type, Dynamic, Dynamic, SO, M, N>;

however there are not so many cases where the storage order matters, and I would make the (educated?) guess that Eigen is better optimized for column-major matrices.

> or maybe a different term called "Dynamic_on_stack" to make it clearer ?

I can't speak for the devs, but the Eigen philosophy seems to be that all dense matrices are (specialized) instances of the Matrix class, irrespective of the storage scheme, to avoid burdening casual users with the distinction between static and dynamic storage. The distinction between fix- and dynamic-size matrices is easy enough to grasp and use. As for the "hybrid" case, it is more meant for power users, and for very specific cases where the upper bounds on the number of rows and column can be known at compile time and are small enough (be careful that Eigen defines a limit on the size of a buffer allocated on the stack - 128kb by default - with EIGEN_STACK_ALLOCATION_LIMIT). I do agree that *Matrix<double, Dynamic, Dynamic, 0, 6, 4>* is not very clear but I would argue that the power user writing that should use aliases with application-meaningful names.

Best regards,

Adrien

**References**:**[eigen] feature request: implement hybrid matrix class template***From:*Vincent Hui

**Re: [eigen] feature request: implement hybrid matrix class template***From:*Adrien Escande

**Re: [eigen] feature request: implement hybrid matrix class template***From:*Vincent Hui

**Re: [eigen] feature request: implement hybrid matrix class template***From:*Andre Krause

**Re: [eigen] feature request: implement hybrid matrix class template***From:*Vincent Hui

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] feature request: implement hybrid matrix class template** - Next by Date:
**[eigen] alignment c++17** - Previous by thread:
**Re: [eigen] feature request: implement hybrid matrix class template** - Next by thread:
**[eigen] alignment c++17**

Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |