GithubHelp home page GithubHelp logo

cgyurgyik / eigenvectors-from-eigenvalues Goto Github PK

View Code? Open in Web Editor NEW
4.0 6.0 1.0 1.35 MB

Function to compute the normed eigenvectors from the eigenvalues of a Hermitian matrix.

License: MIT License

MATLAB 62.82% C++ 23.19% CMake 4.72% C 9.27%
eigenvalues matlab eigenvectors-from-eigenvalues eigenvectors eigenvectorsfromeigenvalues eigvec-from-eigval precision matlab-parallel normed-eigenvectors gefe

eigenvectors-from-eigenvalues's People

Contributors

ajt60gaibb avatar cgyurgyik avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

chaogecanfly

eigenvectors-from-eigenvalues's Issues

Calculating ratio of products without overflow/underflow

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

Decreasing computation time to get the eigenvalues of H

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:

  • eig(A) uses cholesky or shur decompositions.
  • svd(A) was even slower, at least for Hermitian matrices.
  • svds(A, k) provides the largest eigenvalues, and was even slower when setting k = n.
  • Just through some quick google searches, I saw the bisection algorithm and the power method. From what I understand, the power method doesn't fair too well with large matrices.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.