How to use GSL library in C for diagonalization of

2019-08-22 05:36发布

问题:

I have basic knowledge about C programming language. I know loop structure, array and control statements. Suddenly I need to know that how to diagonalize a Hermitian matrix using the GSL library in C language. Installation of GSL is not a problem. But I would like to know how to use it for this specific purpose. I am reading GSL manual these days but a concise and precise answer would be highly appreciated?

回答1:

Start by looking at section 15.2 Complex Hermitian Matrices.

To compute the eigenvalues you'll first want to look here:

gsl_eigen_herm_workspace * gsl_eigen_herm_alloc (const size_t n)

This function allocates a workspace for computing eigenvalues of n-by-n complex hermitian matrices. The size of the workspace is O(3n).

Then look at:

int gsl_eigen_herm (gsl_matrix_complex * A, gsl_vector * eval, gsl_eigen_herm_workspace * w)

This function computes the eigenvalues of the complex hermitian matrix A. Additional workspace of the appropriate size must be provided in w. The diagonal and lower triangular part of A are destroyed during the computation, but the strict upper triangular part is not referenced. The imaginary parts of the diagonal are assumed to be zero and are not referenced. The eigenvalues are stored in the vector eval and are unordered.

Eigenvalues and Eigenvectors can be found using:

gsl_eigen_hermv_workspace * gsl_eigen_hermv_alloc (const size_t n)

int gsl_eigen_hermv (gsl_matrix_complex * A, gsl_vector * eval, gsl_matrix_complex * evec, gsl_eigen_hermv_workspace * w)


标签: c gsl