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

New to Eigen, am I doing it right?

Tags: None
(comma "," separated)
jaycew
Registered Member
Posts
1
Karma
0

New to Eigen, am I doing it right?

Mon Mar 30, 2015 8:34 pm
Hello!

I've come to Eigen after jumping the CBLAS boat. I'm just getting some practice now. I'm currently trying to use write a function which does a change of basis on a Hermitian matrix. Is the following the most efficient way (runtime wise) to do it using the Eigen library?

Code: Select all
template <int N> using matrix = Eigen::Matrix<std::complex<double>, N, N>;
template <int N> void basis_change(matrix<N> &rho, const matrix<N> &U)
{
  matrix<N> rho_prime;
  rho_prime.template triangularView<Eigen::Upper>() =
          U * rho.template selfadjointView<Eigen::Upper>() * U.adjoint();
  rho = rho_prime;
}


Thanks in advance!
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Sounds good. Note that if N is not too small, like greater than 16, then there is no real benefits of specifying the sizes at compile-time. Also, note that Eigen is very slow when compiling without compiler optimization.


Bookmarks



Who is online

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