Re: [eigen] Forcing a conversion to ColMajor |

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

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] Forcing a conversion to ColMajor*From*: Douglas Bates <bates@xxxxxxxxxxxxx>*Date*: Mon, 30 Jul 2012 15:29:10 -0500*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=2suYRq89wKUJOylypcKYZzjU66j4yKvtr9PbAzNcwOc=; b=lEIQK+cAdCzjUmi09Ypf2ukmgy76iLGGqrekcLiO6YDeJm07URiaXWQLBJXd+LMhPh h+K8rvCtt9EbwNqgP9ztG9Aq3BtXZleJAqBY6Zkrl7SraBI4J4MNbrEk26jXgFzGzvDO sHuHEmf3bJfoerR0ZT0JU58Cbl1Yk8jj2VgdM9akSrr9m6LUwVwFgOoChu55LC5BLmfz JW2Ahffjt9IvMVBDUYqLuiy6jD72RGEq8S03kg6oBCbVTjE1jntT/TIw0N1oFS/2mTrB V0nq9jy7Vf5pGya0jweKnvBUfRYyGiIbMM56YxOR3R3ABYxMuw9pkvLFUejo0VEByCeh 8k/w==

On Mon, Jul 30, 2012 at 3:00 AM, Gael Guennebaud <gael.guennebaud@xxxxxxxxx> wrote: > hi, > > I think you can simply drop the explicit ColMajor: > > typename Eigen::internal::conditional<T::IsRowMajor, > Eigen::Matrix<typename T::Scalar, > T::RowsAtCompileTime,T::ColsAtCompileTime>, > const T&>::type objCopy(obj); That works, thanks. > On Sat, Jul 28, 2012 at 8:12 PM, Douglas Bates <bates@xxxxxxxxxxxxx> wrote: >> On Sat, Jul 28, 2012 at 12:40 PM, Douglas Bates <bates@xxxxxxxxxxxxx> wrote: >>> On Sat, Jul 28, 2012 at 12:11 PM, Douglas Bates <bates@xxxxxxxxxxxxx> wrote: >>>> On Sat, Jul 28, 2012 at 2:52 AM, Gael Guennebaud >>>> <gael.guennebaud@xxxxxxxxx> wrote: >>>>> Hi, >>>>> >>>>> you could do something like: >>>>> >>>>> typename Eigen::internal::conditional<T::IsRowMajor, >>>>> Eigen::Matrix<typename T::Scalar, >>>>> T::RowsAtCompileTime,T::ColsAtCompileTime,ColMajor>, >>>>> const T&>::type objCopy(obj); >>>>> >>>>> and then use objCopy instead. If T is column major, then objCopy will >>>>> just be an alias (const ref). >>>> >>>> Thanks for the suggestion. That version fails with an >>>> INVALID_MATRIX_TEMPLATE_PARAMETERS error when trying to do the objCopy >>>> on a row-major object. >>>> >>>> ./include/Eigen/src/Core/Matrix.h:280:13: note: in instantiation of >>>> member function >>>> 'Eigen::PlainObjectBase<Eigen::Matrix<std::complex<double>, 1, -1, 0, >>>> 1, -1> >::_check_template_params' requested here >>>> Base::_check_template_params(); >>>> ^ >>>> ./include/RcppEigenWrap.h:89:31: note: in instantiation of function >>>> template specialization 'Eigen::Matrix<std::complex<double>, 1, -1, 0, >>>> 1, -1>::Matrix<Eigen::Matrix<std::complex<double>, 1, -1, 1, 1, -1> >' >>>> requested here >>>> const T&>::type objCopy(obj); >>>> >>>> I think this is triggered by an object of the form >>>> >>>> Eigen::RowVectorXcd::Zero(5) >>>> >>>> and my guess is that the condition failing is >>>> >>>> EIGEN_IMPLIES(MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1, >>>> (Options&RowMajor)==RowMajor) >>> >>> Probably I should just trap the case of MaxRowsAtCompileTime == 1 >>> because there really is no difference between row-major and >>> column-major in terms of the object returned to R. >> >> The last part of that sentence was for the case of >> MaxRowsAtCompileTime == 1. Of course I have since found out that I >> need to catch that case at compile time, not run time, for which I >> will need to do more template metaprogramming than I have done in the >> past. >> >> > >

**References**:**[eigen] Forcing a conversion to ColMajor***From:*Douglas Bates

**Re: [eigen] Forcing a conversion to ColMajor***From:*Gael Guennebaud

**Re: [eigen] Forcing a conversion to ColMajor***From:*Douglas Bates

**Re: [eigen] Forcing a conversion to ColMajor***From:*Douglas Bates

**Re: [eigen] Forcing a conversion to ColMajor***From:*Douglas Bates

**Re: [eigen] Forcing a conversion to ColMajor***From:*Gael Guennebaud

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] Forcing a conversion to ColMajor** - Previous by thread:
**Re: [eigen] Forcing a conversion to ColMajor** - Next by thread:
**[eigen] Example in Tutorial page 9 - Sparse Matrices**

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