Re: [eigen] Reshape function |

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

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] Reshape function*From*: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>*Date*: Sat, 21 Feb 2009 09:42:35 +0100*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=UPgDDcQ2YXWJEehuLHvby28Tmv09jbbGgSrVIxdlugY=; b=t0998FFajQJLfFu0kQjM6E5LLrJ4JrQo6LhF2imxGHGv6AddpSb2yF3+MYoaGz9mCW VH0+j5X76zS7q5XGgp1z7HqNbJoVwjw6DNQu7DRrM+YTJdvqQVFrIHbCXOMIt1Qy+HWb HDonsrNWbtS6AQ288cwTaTsNil514U2qTN1qY=*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=fv4xyR7gBLrP/m2cphIdWYYpMTYb3l+MKi1240hibPe3c3Z10pVdJUSInk3y3oXSmH MdBPqgYeBkxmJ0oUA9f25pNLtdnKVNUKAnb7JhDDVLKYAflSBrNbT8Xlt/bnBpIrL0fe AWubOF9v7J80qoBfE7d/nL2efM2ycTOX3rD6Q=

yes this has been discussed a couple of time on the forum, and this seems reasonable to me. On Sat, Feb 21, 2009 at 7:27 AM, Keir Mierle <mierle@xxxxxxxxx> wrote: > It would be nice if Eigen had a reshape function like numpy and matlab: > > In [15]: x = random.rand(12) > > In [16]: x > Out[16]: > array([ 0.98782169, 0.24576577, 0.43955455, 0.54305616, 0.00266062, > 0.48190312, 0.55144744, 0.36710248, 0.04064906, 0.34286723, > 0.13652416, 0.01933417]) > > In [17]: reshape(x, (3, 4)) > Out[17]: > array([[ 0.98782169, 0.24576577, 0.43955455, 0.54305616], > [ 0.00266062, 0.48190312, 0.55144744, 0.36710248], > [ 0.04064906, 0.34286723, 0.13652416, 0.01933417]]) > > In [18]: reshape(x, (6, 2)) > Out[18]: > array([[ 0.98782169, 0.24576577], > [ 0.43955455, 0.54305616], > [ 0.00266062, 0.48190312], > [ 0.55144744, 0.36710248], > [ 0.04064906, 0.34286723], > [ 0.13652416, 0.01933417]]) > > I mail because some of my old libmv1 code used this, and I am porting it to > libmv2. I use this a fair amount in numpy. Here's what I propose: > > Matrix<...> mymatrix(12, 1); > mymatrix.reshape(3, 4); // In place. > > This should do the same thing as resize, but does not allow changing the > number of elements, and does not change the contents. I'm not sure what the > semantics should be around column vs row major; I suspect it's best to not > do anything fancy (i.e. reshape() with differing row/col major will give > different results). > > Keir > >

**References**:**[eigen] Reshape function***From:*Keir Mierle

**Messages sorted by:**[ date | thread ]- Prev by Date:
**[eigen] Reshape function** - Next by Date:
**Re: [eigen] Transform products** - Previous by thread:
**[eigen] Reshape function** - Next by thread:
**Re: [eigen] Transform products**

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