Azzera filtri
Azzera filtri

Info

This question is locked. Riaprila per modificarla o per rispondere.

Eigenvalue for a big matrix

10 visualizzazioni (ultimi 30 giorni)
Mücahit Özalp
Mücahit Özalp il 14 Mag 2021
Locked: Rena Berman il 30 Lug 2024
I have a matrix 24990001 x 24990001 and I want to calculate the smallest 10 eigenvalues of this matrix. But I get out of memory error. Is there a way to do that. (I have 16GB of Ram)
I used this code. There is no problem up to this code. It can form the matrix but cannot find the eigenvalues.
E=eigs(D,10,'smallestabs');
And my matrix is
N=5000;
a1=4;b1=-1;
A =diag(a1*ones(1,N-1)) + diag(b1*ones(1,N-2),1) + diag(b1*ones(1,N-2),-1);
B=(-1)*eye(N-1);
E0=speye(N);
E1=E0(2:end,1:end-1);
E0=E0(1:end-1,1:end-1);
D=kron(E0,A) + kron(E1,B)+kron(E1.',B);
  2 Commenti
Matt J
Matt J il 14 Mag 2021
Modificato: Matt J il 14 Mag 2021
Not sure if this helps, but there appear to be some papers out there dealing with eigendecomposition of block tridiagonal matrices, e.g.,
Rena Berman
Rena Berman il 30 Lug 2024

(Answers Dev) Restored edit

Risposte (1)

Maneet Kaur Bagga
Maneet Kaur Bagga il 8 Mag 2024
Hi,
From the above question it is my understanding that, you want to compute the smallest 10 eigen values of a large sparse matrix in MATLAB, following could be the possible workaround for the same:
To minimize the memory usage the matrix "D" should be a sparse matrix and specify options tailored for large scale problems:
D = kron(E0,A) + kron(E1,B) + kron(E1.',B); % D should be sparse
% Assuming D is your large sparse matrix
opts.tol = 1e-3; % Adjust tolerance to manage computation time and memory
opts.maxit = 300; % Limit the maximum number of iterations
opts.isreal = true; % Set based on your matrix, can affect performance
opts.issym = true; % If D is symmetric, this can significantly improve efficiency
% Find the smallest 10 eigenvalues
[EigVec, EigVal] = eigs(D, 10, 'smallestabs', opts);
Assuming you have the "Parallel Computing Toolbox", you can utilize multiple cores to speed up the computation:
% Enable parallel computing
parpool; % Initializes a parallel pool of workers
% Use 'eigs' with parallel options if applicable
[EigVec, EigVal] = eigs(D, 10, 'smallestabs', opts); % The same as before, MATLAB will automatically use available workers
Another possible workaround for this is to integrate external libraries in the following way:
  1. ARPACK: For more control or different configurations, consider using ARPACK directly from C++ or Fortran and interfacing with MATLAB via MEX files.
  2. SLEPc: Using SLEPc (a scalable library for eigenvalue problem computations) involves more setup. You can write a C or C++ program that uses SLEPc for the eigenvalue computations, then call this program from MATLAB using the system command or compile it as a MEX file to be called directly from MATLAB.
Please refer to the following code below for reference:
// A very rough pseudo-code for using an external library like SLEPc
#include <slepc.h>
int main(int argc, char **argv) {
// Initialize SLEPc
SlepcInitialize(&argc,&argv,(char*)0,help);
// Your matrix setup and eigenvalue computation goes here
// Finalize SLEPc
SlepcFinalize();
return 0;
}
Hope this helps!

This question is locked.

Community Treasure Hunt

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

Start Hunting!

Translated by