eigs function works slowly

Hello!
I am having problem with eigs function, I want to find 36 eigenvaluses for a very large sparse matrix, it takes long and my laptop freezes, is these any possible way to make it faster?
The code is:
options = struct('isreal', true);
[V, D] = eigs(A, 36, 'largestreal', options);

4 comentarios

John D'Errico
John D'Errico el 30 de Dic. de 2023
It matters not that the code is as fast as they could make it. There will always be someone who wants it to be faster.
You don't say anything about the matrix, other than that it is apparently quite large. If you want any reasonable help (probably not from me, but there may be some who might offer some ideas), then post the sparse matrix in a .mat file.
Khalil Sabour
Khalil Sabour el 30 de Dic. de 2023
Editada: Khalil Sabour el 30 de Dic. de 2023
Actually, the laptop freezes, so it is not only about the speed, I don't mind wait for 4 or 5 hourse if I can get a results :).
The matrix is 641601 x 641601 and looks like this:
Tridiagonal matrix with additinoal 2 lines, above and below the tridiagonal lines.
If it helps, I will upload the matrix in a mat or dat file, however I want to know is someone has a solution or opinion.
John D'Errico
John D'Errico el 30 de Dic. de 2023
How much memory does your laptop have?
Khalil Sabour
Khalil Sabour el 31 de Dic. de 2023
6 GB RAM, it's not a lot.

Iniciar sesión para comentar.

Respuestas (2)

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 30 de Dic. de 2023
Note that eigs() is NOT computationally efficient and thus, eig() can be employed instead, e.g.,
A = randi(250, 100);
options = struct('isreal', true);
tic;
[V, D1] = eigs(A, 100, 'largestreal',options);
Time_EIGS = toc
Time_EIGS = 0.0499
tic;
[V2, D2] = eig(A);
Time_EIG = toc
Time_EIG = 0.0063

2 comentarios

John D'Errico
John D'Errico el 30 de Dic. de 2023
Editada: John D'Errico el 30 de Dic. de 2023
NO. Eig cannot be used on a matrix of size 641601x641601. This is why eigs exists in the first place, BECAUSE, compared to eig, eigs IS more computationally efficient on large sparse arrays.
Christine Tobler
Christine Tobler el 5 de En. de 2024
EIG is likely to be more efficient than EIGS on small matrices, since EIGS is specifically meant to compute a few eigenvalues of a large, sparse matrix.

Iniciar sesión para comentar.

Christine Tobler
Christine Tobler el 5 de En. de 2024
Editada: Christine Tobler el 5 de En. de 2024

0 votos

A possible issue is that "largestreal" option works less towards the strengths of the EIGS algorithm than the default "largestabs".
Basically inside of EIGS, there is an iteration which tends to find the eigenvalues with largest absolute values. What "largestreal" does is to do some iterations of this, but constantly cut off anything that isn't the largest in terms of the real part of the eigenvalue. This can be useful, but also sometimes stagnates.
So as a first step, could you try to call
[V, D] = eigs(A, 36, 'largestabs');
and let us know what eigenvalues are found for your matrix, and how much time it takes? It can help in understanding the spectrum of the matrix A. Of course if you know any additional information about A (is it symmetric? is it positive definite? EDIT: I see the diagonal is negative, so the question would be if the matrix is know to be negative definite) that can also help with deciding how to call EIGS.

Categorías

Más información sobre Linear Algebra en Centro de ayuda y File Exchange.

Productos

Versión

R2020a

Preguntada:

el 30 de Dic. de 2023

Editada:

el 5 de En. de 2024

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by