'eigs and eig'-- which one should I choose?

115 ビュー (過去 30 日間)
mingcheng nie
mingcheng nie 2023 年 4 月 3 日
回答済み: Vandit 2023 年 4 月 4 日
Hi there,
I have two square matrix G1 and G2, both obtain the same size. Now, I want to obtain the princinple eigenvector of matrix set (G1,G2). Which function should I use? eigs or eig? Also I want to know their computational complexity, I guess is around O(n^3)? n is the matrix dimension.
Thanks
  1 件のコメント
Oguz Kaan Hancioglu
Oguz Kaan Hancioglu 2023 年 4 月 3 日
Eigs returns subset of eig command. If you examine all eigenvector both commands are the same. You can call eigs command with the subset dimensions. I don't know anything about the time complexity. Also in eigs comment there is a comment from matlab:
  • "Using eigs is not the most efficient way to find a few eigenvalues of small, dense matrices. For such problems, it might be quicker to use eig(full(A)). For example, finding three eigenvalues in a 500-by-500 matrix is a relatively small problem that is easily handled with eig."
Also there no code generation for eigs.
After you get the eigenvector, you can use vector opearions (such as max) to find princinpal eigenvectors.
Best.

サインインしてコメントする。

回答 (1 件)

Vandit
Vandit 2023 年 4 月 4 日
The choice of whether to use “eig” or “eigs” function depends on the size of the matrix and the desired accuracy.
"eig" function is used to calculate all the eigenvalues and eigenvectors of a matrix so its computational complexity is O(n^3) for a matrix of size n x n. Therefore, if the size of the matrix is relatively small and you need all the eigenvalues and eigenvectors, you can use the "eig" function to obtain the principal eigenvector of the matrix set.
On the other hand, if the size of the matrix is large and you only need the principal eigenvector or a few eigenvalues and eigenvectors of a matrix then "eigs" function can be more efficient.
The computational cost of the "eigs" function is much lower than that of the "eig" function for large matrices, as it only computes a few eigenvalues and eigenvectors instead of all of them.
You can refer to the syntax of the both the functions using the link given below:

カテゴリ

Help Center および File ExchangeLinear Algebra についてさらに検索

タグ

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by