Re: [eigen] [PATCH] adding Reverse expression |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] [PATCH] adding Reverse expression
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Tue, 3 Feb 2009 00:50:20 +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=jDZxvwulcQazGXtKOTjtZ2+l/QZAEcJG+39zGkfz1Yg=; b=C0wZMBXgryghWLQMuHLEkcLRphnJXZCrXm/TvMJuz+rLAYAMNJtxsVGwXlcabUZ8tn li5fg0beKr3ASg/nUzCXFQGAxiD4PrK5gfuDY8e0zOC+bbm00fUoAEgvT07mTfwjwxZe 8NNc1vlGQ9z1ncGLFdujieWi7t3AglTtigTBg=
- 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=ava+vVN/Fd5EnVcrz5rYBTxD3XWCf7CHNmkE873R9x66GICUjR4DO02IhUUTQoZ0j6 vB/Yd7T7IWtyAdAhcOVksw4LWjDfoOlQU/tRklNigrOKw2xZDrqPjBFfe31uwkbXwazG SaR2kSkeesq1drd04Oz3O8RLhNYvhhgopazj4=
Thanks for your patch; comments below:
2009/2/3 Ricard Marxer Piñón <email@xxxxxxxxxxxxxxxx>:
> Here is a patch to add the Reverse expression this is useful for flipping
> matrices, rows or columns.
I can see that you declare a class Reverse, but don't actually define
it. You probably forgot to "svn add Reverse.h" ?
Your PartialRedux::reverse() method returns a ExpressionType which has
2 drawbacks:
1) it requires ExpressionType to be writable, e.g. one can't use your
reverse() like this,
m3 = (m1+m2).rowwise().reverse();
2) more importantly, your PartialRedux::reverse() is not lazy, so when one does
v2 = v1.reverse();
the arrays are traversed twice: first a temporary vector is created by
reverse(), then this temporary vector is copied into v2.
This is of course inefficient. It is exactly in order to overcome
that, that we introduct expression templates ;)
Cheers,
Benoit