I have not seen a recent discussion of calculating eigenvalues and eigenvectors in Stan for a matrix that is not symmetric but is guaranteed of having real eigenvalues. Is such a calculation possible with the most recent version of Stan?
Hi,
this is quite out of my expertise, but since nobody else answered, I will give it a try. I don’t think this is currently supported, but I see at least two ways you might be able to make it happen (whether the computations would be quick and/or numerically stable is however unclear to me).
-
You should be able to implement the QR algorithm in pure Stan, as QR decomposition is available.
-
If you are OK with implementing your own C++ functions than you should be able to call the eigenvalues solver from the Eigen library (which Stan uses under the hood for most matrix computatoins) - most Eigen calls work out of the box with Stan’s autodiff types, so hopefully this one would as well. The relevant Eigen docs seem to be: Eigen: Eigenvalues module, while you might look at how Stan calls the QR decomposition functions (math/qr_Q.hpp at develop · stan-dev/math · GitHub) to get an idea how the C++ code could look - it should be pretty straightforward.
Best of luck!