Re: [eigen] Accepting different matrix type in the decompositions |

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

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] Accepting different matrix type in the decompositions*From*: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>*Date*: Tue, 20 Jul 2010 11:20:28 -0400*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.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=4pWAq/sBMLYZmvLhifwGfDSxB6/auLl3vllsVE8FXFw=; b=NVRqv8O0FPbevdqtWOuu+XlLN0GzeSSfjswNH5b2UIlZEPPkfuLTeRfHz9/ycpkrf7 6HEsHxnCEzK+AtEds9QY+yyLBkk3PDh4ZvM1Ye6pQsCcP6E8NcS9Kld+Uy/XbnkbHCTk eMdnSH+WahjRrPsfxAKNbO/iF8Gbpw787g36M=*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=l9jqPl2FNrpC/Uu4LWZP747Ah3Cob6LqhxLWCKI/DBj8UQeMwnOW3hQvrnrOUF++3G sXJcicy3ThN6EIAbBQP+tyV2aG7XJ8+RQ6Rsz5ooc2mTUPrgA/P3E//xtScNes2lAPgY k5NWk9U+YJJh5n9QXs9FvEtfdkpvXkmp0jCWw=

2010/7/20 Benoit Jacob <jacob.benoit.1@xxxxxxxxx>: > 2010/7/20 Gael Guennebaud <gael.guennebaud@xxxxxxxxx>: >> Hi, >> >> this makes sense to me. >> >> Note that we have to make sure the actual decomposition is not >> performed by the templated compute() method, but by an internal >> function (to reduce binary code duplication...). This is already the >> case for a few decs (typically the ones working per block), but not >> for all. Anyway, this is a simple change. > > I agree with Adrien's suggestion and with your remark :-) > > Benoit I also notice something very encouraging: in most or all of the suggestions we've recently received, even when they showed that internal changes were needed, the good thing is that they were internal and didn't require to break existing interface. A good sign that we're getting closer to a release! Benoit > >> >> gael >> >> On Tue, Jul 20, 2010 at 9:52 AM, ESCANDE Adrien 222264 >> <adrien.escande@xxxxxx> wrote: >>> >>> Hello again, >>> >>> the different decompositions (QR, LU...) I looked at are all templated by a type MatrixType and have, among others, a method compute(const MatrixType& matrix) with a line m_matrix = matrix, and a constructor >>> Decomposition(const MatrixType& matrix) calling compute. >>> I think it wouldn't hurt to template these two methods by a type InputMatrixName: >>> template<typename MatrixType> >>> template<typename InputMatrixType> >>> Decomposition<MatrixType>::Decomposition(const InputMatrixType& matrix) >>> >>> and >>> >>> template<typename MatrixType> >>> template<typename InputMatrixType> >>> Decomposition<MatrixType>::compute(const InputMatrixType& matrix) >>> >>> this way, when InputMatrixType is different from MatrixType, there is no need to create a temporary object for the conversion, and this conversion is only made at the line m_matrix = matrix. >>> >>> In the usual case where the user use the .decomposition() method of MatrixBase<Derived> (for example matrix.colPivHouseholderQR()), we have MatrixType = Derived::PlainObject and InputMatrixBase = Derived, and there's no need to call eval() within decomposition. >>> >>> And this simplify the writing in other cases. My use case (a complete orthogonal decomposition): >>> ColPivHouseholderQR<MatrixXd> LQ(M.transpose()); >>> HouseholderQR<MatrixXd> qr(LQ.matrixQR().topLeftCorner(LQ.rank(), LQ.cols()).triangularView<Upper>().transpose()); >>> I don't even want to imagine the MatrixType I should have wrote for the HouseholderQR... >>> By adding the InputMatrixType template, I avoid there two temporaries. >>> >>> I wanted to add a static assert to check for the compatibility of MatrixType and InputMatrixType, but ei_is_same_type<MatrixType, InputMatrixType::PlainObject>::ret seems to be a too strict condition. I just test the same scalar type for now. >>> >>> Adrien >>> >>> >>> >> >> >> >

**References**:**[eigen] Accepting different matrix type in the decompositions***From:*ESCANDE Adrien 222264

**Re: [eigen] Accepting different matrix type in the decompositions***From:*Gael Guennebaud

**Re: [eigen] Accepting different matrix type in the decompositions***From:*Benoit Jacob

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] An insistent plea for an input operator** - Next by Date:
**Re: [eigen] eigen3 replacement of start/segment/end** - Previous by thread:
**Re: [eigen] Accepting different matrix type in the decompositions** - Next by thread:
**[eigen] An insistent plea for an input operator**

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