This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Mixing views with noalias

Tags: None
(comma "," separated)
zeplincorvex
Registered Member
Posts
5
Karma
0

Mixing views with noalias

Sat Dec 01, 2012 7:11 am
I'm trying to efficiently compute an orthogonal transform of a real, symmetric matrix, N = Q * M * Q^{T}, where Q is orthogonal. Because M' is also symmetric I'm looking at

Code: Select all
A.noalias() = M.selfadjointview<Eigen::Lower>() * Q.transpose();
N.selfadjointview<Eigen::Lower>() = Q * A.


This works fine, but I want to avoid any temporary memory allocation in the second line. There doesn't seem to be support for mixing views with noalias, i.e.
Code: Select all
selfajointview<Eigen::Lower>().noalias()
or
Code: Select all
noalias().selfajointview<Eigen::Lower>()
; is there anyway to use the view while also avoiding a temporary?

Thanks.

-Mike
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Mixing views with noalias

Sat Dec 01, 2012 2:18 pm
Yes, no need to add noalias here, noaliasing is the default for views.
zeplincorvex
Registered Member
Posts
5
Karma
0

Re: Mixing views with noalias

Sat Dec 01, 2012 2:45 pm
Awesome.

On a similar note, what's the best way to access information about dense rows and columns from a partial matrix? The selfadjoint view doesn't seem to have row/column accessors, i.e.

Code: Select all
M.selfadjointView<Eigen::Lower>().row(i)


doesn't work.

Do I have to fill M explicitly? And, if so, is there a more efficient way than

Code: Select all
Mdense = M + M.triangularView<Eigen::StrictlyLower>().transpose()
?

Thanks, again!

-Mike


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]