Re: [eigen] Adding general (dense matrix) expressions and diagonal matrix expressions
• To: eigen <eigen@xxxxxxxxxxxxxxxxxxx>
• Subject: Re: [eigen] Adding general (dense matrix) expressions and diagonal matrix expressions
• From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
• Date: Tue, 22 Mar 2016 13:19:34 +0100
• Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=RmfK74urRN+Atzmt1oYoO5QXYCqCJ/9McX8DOFQofTE=; b=U7joMCcNZGbkPoMgcABbwC2CnSEVkKewLYxx4ZJBQUFpnIyGBGxNaW2Xx4fl9iwwJ8 vrPvGPmcV0TsnrFpOSDGtvciCICEgljdteCqmpz1cBbHk6PVD87vdbqIyUe/DPzQrQRg +Qflwu3WOIQXWAJ09lxJihGfRZOurbuQ9LWJWSvcMJ78d10yzNYhhVGHHaU/1X5gW9D1 n/FTln5x4cSnGaLMZryC+yf5FlLXUNmWzLJiT2Vd68TLjr+xSomXVvZXuysSKqPnTJgt ZBt5yvhKOO8/ikO0aGswQXqzwuEmBVXPS2xlMzlXfsrLhdPkDdWdkCQo5504pwp1fUSN BVBA==

Hi,

I guess you are referring to coefficient-wise expressions like A+diag(v). The difficulty is that for performance reasons, it is crucial to separate the dense part from the diagonal part so that we can evaluate the dense part at once and then add/subtract the diagonal part. For instance, if you have:

C = A + diag(v) - 2*B - 3*diag(w)

we would have to rewrite the _expression_ as:

C = (A- 2*B) + diag(v-3*w)

to then be able to optimally evaluate it in two steps as:

C = A- 2*B
diag(C) += v-3*w

This is not possible in Eigen 3.2, and in Eigen 3.3, doing the last step is straightforward. Rewriting the _expression_ is also doable (to some extent), but at the cost of significant compilation times.

Could you provide a typical example of the expressions you want to assemble?

gael

On Tue, Mar 22, 2016 at 12:19 PM, Dan Čermák wrote:
Hi everyone,

I am frequently running into the problem, that I can't add general dense
matrix expressions and diagonal matrix expressions.

Is there any way around this problem? I would really like to be able to create
expressions of that kind since then I could simply let some of my functions
return them and add them up without having to keep track of the diagonal and
non-diagonal expressions myself.

Is something planed to be implemented in the long run or is this fundamentally
impossible?