Re: [eigen] Adding general (dense matrix) expressions and diagonal matrix expressions |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
Hi,
thanks for your reply.
So technically this should work in Eigen 3.3?
Concerning the expressions, its quite complicated since I am building Jacobian
matrices of discretized partial differential equations.
For instance one example is the following one:
Jacobian _ i,l
= Sum_j (K_ijl * K_jl * n_j) + δi,l Sum_j K_jl n_j + K_li * n_i
(where the first summand is implemented via an own function, since its a 3d
matrix contraction)
As you can see, the second summand is only contributing to the diagonal,
whereas the other two are contributing to the whole matrix. As I want to add
up several of these matrices, it would be very nice to be able to add them up
via + .
I hope that makes a bit of sense.
Cheers,
Dan
On Tuesday 22 March 2016 13:19:34 Gael Guennebaud wrote:
> 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 <dan.cermak@xxxxxxxxxxxxxxxxxxx
> > 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?
> >
> >
> > Thanks in advance,
> >
> > Dan