Prev: Normality test
Next: DeleteDuplicates is too slow?
From: Jim Lambaugh on 4 Feb 2010 06:24 Hi guys I am in a situation, where I have to diagonalize very large matrices. My experience with Mathematica is limited, but what I need is the entire set of eigenvalues. From what I have read, this excludes the use of ARPACK, since this is used to find certain eigenvalues (i.e. largest, smallest etc.). I read that LAPACK is used to find entire sets of eigenvalues, but the Mathematica-help does not say much on this subject. So to make a long story short: What is the most effective way of finding the entire set of eigenvalues (and corresponding eigenvectors) of a very large matrix? Best regards, Jim
From: Mark McClure on 5 Feb 2010 03:31 On Thu, Feb 4, 2010 at 6:25 AM, Jim Lambaugh <lambaugh(a)gmail.com> wrote: > I am in a situation, where I have to diagonalize very large matrices. > My experience with Mathematica is limited, but what I need is the > entire set of eigenvalues. > > I read that LAPACK is used to find entire sets of eigenvalues, but the > Mathematica-help does not say much on this subject. So to make a long > story short: What is the most effective way of finding the entire set > of eigenvalues (and corresponding eigenvectors) of a very large > matrix? If you have a large matrix M with real, floating point entries (such as 1.0), simply use the Eigensystem command: {vals,vecs} = Eigensystem[M] The previous command will store the eigenvalues and eigenvectors in the variables vals and vecs. If you are familiar with Lapack, you should be aware that use of Mathematica is very different. Lapack is a much lower level tool and the programmer is expected to know which algorithm to call in certain situations. For example, DSTEQR uses a QR algorithm to compute the eigenvalues of a symmetric, tri-diagonal matrix of doubles - and there are a zillion such functions. Mathematica automates the process, choosing the appropriate Lapack function to call based on the input. Hope that helps, Mark McClure
From: Mark McClure on 13 Feb 2010 05:22 On Fri, Feb 12, 2010 at 2:18 PM, Jim Lambaugh <lambaugh(a)gmail.com> wrote: > Thanks for that example - that illustrated it very well. My background is in > physics (currently doing a B.S.). If I define my matrix (lets call it > "lattice") as being dense, then I have made it sparse by using > SparseArray[{lattice}], because - as you mentioned - I believe it is a > little tricky using the rules of generation of a sparse array. What I need > is the full spectrum of the matrix, i.e. all the eigenvectors - will a > sparse matrix also be useful in this case, or is it not possible finding all > the eigenvectors when using a sparse matrix? No, probably not. The Arnoldi technique is applied to find one eigenvalue/eigenvector pair at a time. The matrix is then deflated and another can be found. There is loss of precision with each deflation step so this can only be done so many times. In fact, if you ask Mathematica to use the Arnoldi technique to find too many eigenvalues of a sparse matrix, then it will complain. > I am not sure this is enough information, but if you had a large matrix > containing many zeroes and you had to find all the eigenvectors - then what > would you do? You've got to use dense techniques. In Mathematica, this means Eigenvalues[A]. I would assume that you almost certainly want numerical approximations, i.e. 1.414, versus Sqrt[2]. So be sure that your plugging in a numerical matrix in the first place. For example, here's the eigenvalue computation for a random zero-one matrix: A = RandomInteger[{0, 1}, {100, 100}]; Eigenvalues[N[A]]; // Timing Takes about 0.01 seconds on my machine. Note the N[A]. If I replace that with just A, it takes more like 20 seconds. A 1000x1000 matrix is easy with the N but infeasible without. > I really appreciate your help. Currently, you are my only source of > Mathematica-help, so any help is greatly appreciated. I read mathgroup regularly and post when the questions touch on something I feel reasonable competent about. I think you'll find it quite helpful, if a bit slow due the delay. Hope that helps, Mark
|
Pages: 1 Prev: Normality test Next: DeleteDuplicates is too slow? |