cgyurgyik / eigenvectors-from-eigenvalues Goto Github PK
View Code? Open in Web Editor NEWFunction to compute the normed eigenvectors from the eigenvalues of a Hermitian matrix.
License: MIT License
Function to compute the normed eigenvectors from the eigenvalues of a Hermitian matrix.
License: MIT License
Consider, the following MATLAB code:
prod( 1 - (2:10000) )/prod( 1 - (3:10001))
ans =
NaN
which happens due to overflow and underflow issues. (The denominator and numerator are both equally huge.) Instead, it is better to do the mathematically equivalent calculation:
prod( (1 - (2:10000) ) ./ ( 1 - (3:10001) ) )
ans =
9.999999999999994e-05
Hence, why I did this:
https://github.com/cgyurgyik/EigenvectorsFromEigenvalues/blob/66d594c55375ff7e4d6cd76df174fe4b78a0694b/GetEigenvectorFromEigenvalues.m#L29
So just running some quick trials,
n = 10000;
H = randn(n,n);
H = (H+H')/2;
disp('eig');
tic;
for k = 1:5
[eigenvectors, ~] = eig(H);
end
toc;
H = randn(n,n);
H = (H+H')/2;
disp('GEFE');
tic;
for k = 1:5
ev_of_H = GetEigenvectorFromEigenvalues(H,1,1);
toc;
end
(eig) Elapsed time is 185.192800 seconds.
(GEFE) Elapsed time is 119.087356 seconds.
So yes, GEFE is faster (as you claimed) to find the value of the ith row and jth column of an eigenvector for very large matrices. (One small catch here is GEFE provides normed values while eig does not).
It does exactly that, only finds the ith row and jth column value of an eigenvector. If we wanted to find, say, two values, you're essentially 'doubling' the time. (Well, we can provide an optional argument to the function where the user can provide the eigenvalues, so that they aren't computed for H each time.) On the other hand, eig provides ALL the eigenvectors.
So applying Amdahl's law, I suspect the largest chunk of computation time for GEFE goes to getting the eigenvalues of H and hj using eig(). The question then, is there a faster way to provide the eigenvalues of a matrix, when we don't exactly need the eigenvectors?
What I know:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.