Re: [eigen] Blockwise matrix multiplication |

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

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] Blockwise matrix multiplication*From*: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>*Date*: Wed, 9 Jun 2010 09:37:00 +0200*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type; bh=GwAT092+LQtES0qtsVqnUgwBApwJRyerqMcIe648tDo=; b=aaavJeT6VHHUBf5sRVRjaMxrGDdgT9WDHrwQGy58Z/GSqJv+9Z+BLLre+G/ttze6cc xlMWyAKykQoW/dK6IjM23ZtWoQXsAfzPBz9GEX8ZRueUVjwOBha4j/tzAJrtpIt7Ho9W PFZ/BrAXWjxdSK5tdZWgQIX50NFLxc6Ljkz5I=*Domainkey-signature*: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=LRZuOmuM2vzNVVieI4Kcf2LABWMqjKlCguEtRBKmDRV6kN2oXuWWnd1reFW4/VrlLU /ZRulYJQKEGD+QFYmGans3ENR+2i5X9hziLTYkrInAdImDCAtE2ZQA/J4AMcVSa9rk20 m6UCCwaNZieJiAyRfhVjAL7++D7kRfvtb1k14=

Hi,

Indeed the same could be achieved using a block diagonal matrix, or a more general sparse block matrix, however there is no such things in Eigen yet. So currently I have nothing better to propose.

gael

On Tue, Jun 8, 2010 at 5:39 PM, Sidney Cadot <sidney..cadot@xxxxxxxxx> wrote:

Hi all,

I have a problem that reduces to a matrix multiplication on blocks around the main diagonal, and I want to verify with you guys if my coding approach is the best possible using Eigen.

I'll illustrate with a concrete example:

Suppose I have a 20x100 source matrix (20 rows, 100 columns).

I need to construct a target matrix, where every consecutive four rows of the source matrix are summarized as three rows using a 3x4 weighting matrix. The target matrix will thus be 15x100, with each group of three consecutive rows being a linear combination of four consecutive rows in the source matrix.

What I do now (and it works fine):

Eigen::MatrixXd source(20,100);

Eigen::MatrixXd target(15,100);

for (int i = 0; i < 5; ++i)

{

Eigen::Matrix<double, 3, 4> weights = getWeights(i);

target.block(3 * i, 0, 3, 100) = weights * source.block(4 * i, 0, 4, 100);

}

.... I was wondering if the code could be written any smarter than this; specifically, without an explicit loop (e.g. using a sparse weighting matrix or something like that). Any feedback is greatly appreciated.

Best regards, Sidney

**References**:**[eigen] Blockwise matrix multiplication***From:*Sidney Cadot

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] stable norm** - Next by Date:
**Re: [eigen] stable norm** - Previous by thread:
**[eigen] Blockwise matrix multiplication** - Next by thread:
**[eigen] shared libraries and including Eigen in base class**

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