简体   繁体   中英

Complex matrix exponential with Armadillo library

I'm doing some physics simulation in C++ using Armadillo. I need to calculate a product looking like:

Q = R * exp(neg_i*Lambda*t) * R.t() * Q

Where Q,R are cx_mat class of the same size, Lambda is a mat class of the same size as Q,R and is diagonal, neg_i is -i the complex number and t is a double. I should get a unitary matrix as a solution but what I'm getting is non unitary. I was wondering if the exponential function works well with complex matrices? or if not what should I replace it with?

You need to use the expmat() function for a matrix exponential, exp() calculates an element-wise exponential.

For example, some code I'm currently using for a physics simulation:

arma::cx_mat f;  // A hermitian matrix
double delta_t ;  // A time step
std::complex<double> i_imag(0.0,1.0) ;  // i, the imaginary number

std::vector<arma::cx_mat> U; // A vector of complex unitary matrices.

U.push_back(arma::expmat(-i_imag * delta_t * f));

Have tested this code, taking the matrix exponential of anti-hermitian matrices to get unitary transformation and works fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM