Testing a Lanczos (tridiagonalization) algorithm

In summary, the conversation discusses the implementation of a tridiagonalization algorithm and the accuracy of the results. The idea of testing the code with a smaller matrix and using a convergence method to find the extremal eigenvalue is suggested. It is also recommended to consult a book on Matrix Computations for better understanding and to use a pre-written routine like ARPACK for a more reliable calculation. The issue of breakdown in Lanczos algorithm is also mentioned and it is suggested to test it against other packages such as LINPACK or LAPACK. The conversation concludes with a request for someone who has implemented Lanczos algorithms for solving linear system of equations, particularly in Matlab, to share their code.
  • #1
senorbum
8
0
So I implemented a tridiagonalization algorithm, however I don't know if the result that I am receiving is accurate. Does anyone know of an easy way of testing this? I suppose it is possible to scour around for code, but it would be difficult to find matching code. So if anyone knows anything that could help me, that would be much appreciated!

Edit: One other question. If you tridiagonalize a matrix, then compute the Singular Value Decomposition, then re-compute the matrix with say 'k' singular values, isn't the resulting matrix going to also be tridiagonalized? In which case, how can you apply the SVD of a tridiagonal matrix back to the original matrix?
 
Last edited:
Physics news on Phys.org
  • #2
what u can do is test the code for a smaller matrix of the same type. and if u r trying to find the extremal eigenvalue then u can do the following :

check for convergence of the extremal eigenvalue of ur tridiagonal matrix after it has grown by 10 dimensions, i.e. find the lowest/heighest eig val when ur tridiagonal matrix is 10 dim, then chk again when its 20 dim, then 30 dim, and so forth. once the value has reached a fixed point (it generally does so by 70-80 dim) u have ur extremal eigen value.
this saves a lot of resource, especially when u r generating the matrix with a lanczos.
 
  • #3
vkroom said:
what u can do is test the code for a smaller matrix of the same type. and if u r trying to find the extremal eigenvalue then u can do the following :

check for convergence of the extremal eigenvalue of ur tridiagonal matrix after it has grown by 10 dimensions, i.e. find the lowest/heighest eig val when ur tridiagonal matrix is 10 dim, then chk again when its 20 dim, then 30 dim, and so forth. once the value has reached a fixed point (it generally does so by 70-80 dim) u have ur extremal eigen value.
this saves a lot of resource, especially when u r generating the matrix with a lanczos.

Thanks. I have been doing that recently. Is simple lanczos even good for more than the extremal eigenvalue? It seems that I'd have to reorthogonalize if I wanted more than one, but I'm not 100% sure. Basically I am wondering if it will preserve say the top x eigenvalues where x << matrix dimension (say like 20 in a 200x200 matrix). It seems like it may generate some spurious values, but I was wondering if you could confirm this.
 
  • #4
the lanczos vectors lose their orthonormality rapidly. so some kind of re-orthonormalization scheme is required. but thus far i didn't have any problem with the naive lanczos iterations.
You might want to consult the book "Matrix Computations" by Golub. Its pretty good.

the bottomline is that for practical and reliable calculations its better to use some ready made routine, rather than code one for urself. there are a few fine tuning required to produce a robust lanczos routine, and u mite want to use some readymade ones for the purpose.

one such is ARPACK. this one is coded in fortran. there's a c++ inrterface : ARPACK++


good luck
 
  • #5
vkroom said:
the lanczos vectors lose their orthonormality rapidly. so some kind of re-orthonormalization scheme is required. but thus far i didn't have any problem with the naive lanczos iterations.
You might want to consult the book "Matrix Computations" by Golub. Its pretty good.

the bottomline is that for practical and reliable calculations its better to use some ready made routine, rather than code one for urself. there are a few fine tuning required to produce a robust lanczos routine, and u mite want to use some readymade ones for the purpose.

one such is ARPACK. this one is coded in fortran. there's a c++ inrterface : ARPACK++


good luck

Well, my portion of this project is done, but thanks for the response. I used a naive version of Lanczos, but will need somebody who has a better understanding of linear algebra to implement a reorthogonalization technique. The reason I couldn't use a pre-written routine is because I was coding it using CUDA, which is NVidia's GPU programming language. If I had more time I might have been able to figure out how ARPACK has theirs coded and replicate it, but my time is up within a week and a half, so I have more pressing issues to attend to (The project is for a summer internship, hence the random cutoff time).

Anyways, thanks again for the response.
 
  • #6
I will be grateful if some one can help me in explaining the idea of breakdown in Lanczos algorithm and what is the difference between the breakdown and stoping criteria of lanczos algorithms. I will appreciate if some one can send me the codes of lanczos algorithm which they have tested on some problems of linear system of equation. Any one who knows the linear systems where this lanczos algorithm fails. Sorry to ask so many questions but I am really in hot water and I need the answeres of all these questions. I hope you people will help me out of this situations.
 
  • #7
Test it against LINPACK, or LAPACK, or some similar package. I bet they have an implementation in there. I haven't heard of ARPACK before, but I suspect it's similar.
 
  • #8
Thank you very much for your response. Can you explain the following, I mean the theoritical aspects only please,,"The idea of breakdown in Lanczos algorithm and what is the difference between the breakdown and stoping criteria of lanczos algorithms".

Any one who can explain it please?

With Best Regards

Farooq
 
  • #9
Any one who has implemented Lanczos algorithms for solving linear system of equation. I will appreciate if anyone has done it in Matlab and can send it to me please.

Regards
 

1. What is a Lanczos algorithm?

A Lanczos algorithm is a method for computing eigenvalues and eigenvectors of a large, sparse matrix. It is based on the Lanczos tridiagonalization process, which involves reducing the original matrix to a smaller, tridiagonal matrix that has the same eigenvalues as the original matrix.

2. How does a Lanczos algorithm work?

The Lanczos algorithm works by choosing an initial vector and performing a series of matrix-vector multiplications to generate a sequence of orthogonal vectors. These vectors are then used to construct a tridiagonal matrix, which can be used to approximate the eigenvalues and eigenvectors of the original matrix.

3. What are the advantages of using a Lanczos algorithm?

One of the main advantages of using a Lanczos algorithm is that it is much more efficient for computing a small number of eigenvalues and eigenvectors compared to other methods, such as the power method or the QR algorithm. It is also well-suited for large, sparse matrices, which are commonly encountered in scientific and engineering applications.

4. What are the limitations of a Lanczos algorithm?

One limitation of the Lanczos algorithm is that it can only be used for symmetric matrices. Additionally, the algorithm may not converge if the matrix has a large number of small eigenvalues or if the initial vector is not well-chosen. In these cases, alternative methods may be more suitable.

5. How can the accuracy of a Lanczos algorithm be evaluated?

The accuracy of a Lanczos algorithm can be evaluated by comparing the computed eigenvalues and eigenvectors to the exact values, if known. This can be done using various metrics, such as the residual norm or the relative error. Additionally, the algorithm can be tested on known matrices with known eigenvalues to assess its performance and accuracy.

Similar threads

  • Linear and Abstract Algebra
Replies
1
Views
1K
  • Linear and Abstract Algebra
Replies
5
Views
2K
  • Linear and Abstract Algebra
Replies
1
Views
2K
Replies
9
Views
1K
  • Advanced Physics Homework Help
Replies
6
Views
1K
Replies
10
Views
2K
  • Programming and Computer Science
Replies
1
Views
2K
  • High Energy, Nuclear, Particle Physics
Replies
1
Views
1K
  • General Math
Replies
11
Views
1K
  • Programming and Computer Science
Replies
30
Views
4K
Back
Top