|Re: [eigen] Question about the class hierarchy|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Question about the class hierarchy
- From: Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>
- Date: Wed, 30 Jun 2010 10:28:04 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=MrgoLpA7IdKeURCx04/PVp3guuOJYForKe9gvXvwTCA=; b=DGsc6OoGpXGzT/RoW0Q+TbzG1rBBZKSzGjWbo2Y56VB0TkkzyEXMl2iDEomKj1VXhp V6f2wwz5TkFG1scJG+Y1kv3c3J6Kg1b6rhKj2NiJ3q+vWUmWSA1t3+9Ac+iNTdSK7+mg BE3OknHNw3ERlcW1pNjsvgjVm8onyylcXryWw=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=SN764KQQcqYIRd+GgVCEq3k1ygSRpf4QY+I4hKZ/BqsflV3366DlzXyxnfjBWbrV2D e5xiMyE0ufeeGClSw+PCZRHWPIZIfjDC3KhPLZdr1jc33fDeDIHMY3WnAnkiZpzrpG/k XEm/MqnyLSd0IxxQ5GZRozDtIXikmSMwtdhDk=
On Wed, Jun 30, 2010 at 6:07 AM, Manoj Rajagopalan <rmanoj@xxxxxxxxx> wrote:
> 1. Aren't Array and Matrix independent *concepts*? Therefore, a dense matrix
> expression, which shares traits with an array expression should inherit both
> an Array base class and a Matrix base class simultaneously using multiple
> inheritance as opposed to the linearized inheritance in Eigen.
We try hard to prevent multiple-inheritance since we have encountered
examples where MSVC fails to perform empty base class optimization
which is crucial for our fixed size types.
We really want that
sizeof( Matrix<double,2,2> ) = 4*sizeof(double)
> 2. Other matrices should inherit this Matrix base class. Then all matrices
> can be handled with matrix semantics using one base class without having to
> worry about intervening array semantics - this is what makes me most
> uncomfortable. For example, take solve() methods which accept const
> matrix-expressions as arguments. Therefore, they should accept
> DiagonalMatrix/Wrapper, SparseMatrix etc. If the solve() prototype is
> declared with MatrixBase<OtherDerived> const& as arg then we rule out this
> possibility. On the other hand, if we declare it with EigenBase<...> const&
> as arg, then it also allows Array expressions to be passed. the latter is not
> a problem if we allow it and warn the user to guard against this caveat but
> still conceptually Arrays are distinct from Vectors/Matrices ...
Maybe, looking at this document helps you a bit:
What used to be called in this document AnyMatrixBase is now our EigenBase.
> 3. If the Array base and Matrix base must inherit EigenBase then this
> inheritance must be virtual so that there is exactly one copy of EigenBase in
> the derived object. virtual inheritance works with templates at least with
> gcc 4.2 on my linux machine.
I don't quite understand this? The EigenBase has zero size. No
members, no virtual functions. Having even a single virtual function
in EigenBase is not an option because of the sizeof constraint I told
you about before.
> 4. EigenBase seems to contain member functions that internal documentation
> warns against using. Equivalent code seems to be present in eponymous member
> function definitions of the derived classes. Then, if this makes the
> EigenBase member definitions redundant and we can remove them, this leaves
> very little in EigenBase itself - just a few methods like rows(), cols(),
> size() etc. Are we keeping these redundant definitions just so that we can
> avoid re-declaring all of these methods in the derived classes?
Yes, IIRC that is the reason. We would like to absolutely minimize
code redundancy and it comes at no cost since the compiler will
anyways perform EBO.