Re: [eigen] Generic conservativeResize() for both matrices and vectors? |

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

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] Generic conservativeResize() for both matrices and vectors?*From*: Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>*Date*: Fri, 26 Nov 2010 19:45:43 +0100*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; bh=GUI5/LeKz7QnROPV3rRWNFOQyf8M+NO+Yl1OnM40LKo=; b=vayulMbIuvNNi3z+mTMOuSbZ3tA99tziFh6Q+VBMafRaS6XDnPTzQbjrsVYoUnkP/A AsbrxMcEup//1opKBJdPw13iIjhU/U04QecqDgJo+8qwLCnBeZRVRQEAa4caE2T5QaNV 4kQFord25npcLUQjhfCif42O6vHEer6nfBGRo=*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; b=RQc02ynO3Vjvy0ukZiS+YZ19nYK9/RDH+g5rOQGhFV3Xk4xAgdK7D8oLN8n28n+Jt1 MomRn6TDhZxA+9EsC19BkrvCLcmBpehhXjBX/Tc0vXOWlXs9JYlrkElOj26K4MIsDyer 1Opuis8mEppNXpzBi5oNIKkfo8wuXkQw3dSOA=

Hi Jose, This behavior exists on purpose. The conservative_resize_like_impl helper struct provides run(...) with two indices only for matrices and not for vectors. The functionality you desire requires additional error checks to be completely safe to guard against parameters deviating from 1 when working with row vectors. Your approach is the only workaround. I would change the templates a bit and declare MatOrVecResizer as template<typename Derived, int R = Derived::RowsAtCompileTime, int C = Derived::ColsAtCompileTime> struct MatOrVecResizer; thus you have to write less when actually calling the helper as below detail::MatOrVecResizer<Derived>::doit(m,nRows,nCols); I don't consider your solution as ugly but what I would be worried about is the fact that Matrix<double,1,Dynamic> M; foo(M,1000,4); // this foo(M,1,4); // and this do the same things without letting you know. One alternative - which would be working for Matrices only is to overload foo() for dynamic matrices as well as row and column vectors. You would loose the compatibility with expressions templates but on the other hand side resizing does not make much sense on general expressions - pretty much no sense at all. You could define them as template <class Scalar> void foo( Eigen::Matrix<Scalar,Dynamic,Dynamic> &m, int nRows, int nCols ); template <class Scalar> void foo( Eigen::Matrix<Scalar,Dynamic,1> &m, int nRows, int nCols ); template <class Scalar> void foo( Eigen::Matrix<Scalar,1,Dynamic> &m, int nRows, int nCols ); Kind regards, Hauke

**Follow-Ups**:**Re: [eigen] Generic conservativeResize() for both matrices and vectors?***From:*Jose Luis Blanco

**References**:**[eigen] Generic conservativeResize() for both matrices and vectors?***From:*Jose Luis Blanco

**Messages sorted by:**[ date | thread ]- Prev by Date:
**[eigen] Generic conservativeResize() for both matrices and vectors?** - Next by Date:
**Re: [eigen] Generic conservativeResize() for both matrices and vectors?** - Previous by thread:
**[eigen] Generic conservativeResize() for both matrices and vectors?** - Next by thread:
**Re: [eigen] Generic conservativeResize() for both matrices and vectors?**

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