Most efficient way to find nearest positive semi-definite matrix?
1 view (last 30 days)
Show older comments
Currently working on a GAN, for which I need to calculate the nearest positive semi-definite matrix to the covariance matrix of the data distribution. The smallest embedding space that works is with a dimension of 60416, meaning that my covariance matrix is 60416x60416.
I have made an extensive search, which led me to this question: https://www.mathworks.com/matlabcentral/answers/471045-how-to-find-the-nearest-positive-definite-matix. I have tried the script found at https://www.mathworks.com/matlabcentral/fileexchange/42885-nearestspd, but has crashed the cluster where the experiments are being conducted and even if it eventually runs, the current memory usage is still not desirable.
Is there any way to more efficiently make this computation? The script is almost 10 years old and I find it very odd that there is not a more recent/optimized version. Thanks in advance for any help provided.
5 Comments
Walter Roberson
on 3 Aug 2022
Edited: Walter Roberson
on 4 Aug 2022
you can make some minor changes to the code such as
H = V*Sigma*V';
After that you could clear V. A couple of lines later you can clear H.
These minor changes might allow you handle slightly larger matrives, but I doubt it will make much difference.
Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!