|Re: [eigen] Eigen "views"|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Eigen "views"
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Tue, 16 Aug 2011 08:48:38 +0200
- Cc: Michael Dixon <mdixon@xxxxxxxxxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=aAIAxUw3m9c6rHa7sUvA1fSb2MHIzCWufD9VxF5ij6E=; b=ccRQqjuDJ0z1KoRbvYasuN6RBEczRQ6vHPGxR2R7m3Fi9Jb+tUQXwExSdboLJ+kNjp HdSI+gFNYcUslS3m0VS2+Yp8rWbaS3FmqtdricjSv/C7x8A5E539Rb/XE07O5VGv5aRp ki3gGDKonz8MjouqzXF3npe1QaRXeSSR5Ctmo=
I confirm what Benoit said, this has yet to be implemented and this is
probably the most wanted feature!
API-wise, what about simply overloading operator(). For vectors:
VectorXf v1, v2;
v2 = v1(indices);
And for matrices:
MatrixXf m1, m2;
VectorXi indices1, indices2;
m2 = m1(indices1,indices2);
m2 = m1(Eigen::All,indices2);
m2 = m1(indices1,Eigen::All);
"m1(indices1)" would be forbidden for matrices.
Maybe the constant "All" is too intrusive when someone do using
namespace Eigen ??
On Mon, Aug 15, 2011 at 9:24 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
> (Disclaimer: I've been away for a while so I might not be up to date.
> If Gael contradicts me, listen to him)
> This has been asked for many times, and I think there was consensus
> that this would be a welcome addition. It also isn't hard to
> implement. It's just that nobody has actually done the work yet :)
> If you want to do it yourself, the right Eigen way to do it is to add
> a new expression class, holding references to the original vector and
> to the integer vector of indices. For a simple expression class to
> start from as an example, look at the Minor class in Eigen2Support,
> it's as easy as it gets. The core part of the implementation would be
> the coeff() accessor methods in this class, and they would look like:
> CoeffReturnType MyViewExpression::coeff(Index i)
> return m_originalVector.coeff(m_indicesVector.coeff(i));
> I'll be happy to provide guidance.
> 2011/8/15 Radu B. Rusu <rusu@xxxxxxxxxxxxxxxx>:
>> Hi guys,
>> We were wondering whether there was ever a discussion about implementing
>> "views" into Eigen. Here's an example:
>> Eigen::Vector<dynamic, float> vector1, vector2;
>> vector1 = defineSomeDataSomehow ();
>> Eigen::Vector<dynamic, int> idx = defineSomeIndicesSomehow ();
>> vector2 = vector1 (idx);
>> assert (vector2.size () == idx.size ());
>> Basically addressing data without copies.
>> Point Cloud Library (PCL) - http://pointclouds.org