I have a square Eigen::MatrixXcd
x
that has complex values assigned to the upper triangular part including the diagonal axis and some random values assigned to the lower triangular part like that (4x4 example):
X00 X01 X02 X03
X10 X11 X12 X13
X20 X21 X22 X23
X30 X31 X32 X33
I want to assign the complex conjugate values of the upper triangular part to the lower one so that it looks like that:
X00 X01 X02 X03
conj(X01) X11 X12 X13
conj(X02) conj(X12) X22 X23
conj(X03) conj(X13) conj(X23) X33
How do I express this assignment for arbitrary sized matrices nicely?
In many cases you don't need to do that and instead just use (instead of X
):
X.selfadjointView<Eigen::Upper>()
Especially, for bigger matrices this can reduce the needed memory-throughput (and cache space). For smaller matrices it introduces quite some overhead, though. So to copy the adjoint of the upper right to the strictly lower left write:
X.triangularView<Eigen::StrictlyLower>() = X.adjoint();
For both variants X
has to be square, of course.