NAME

diagonalize - Diagonalizes a matrix

SYNOPSIS

#include "n/n_diagonalize.h"

Example compile flags (system dependent):
  -DLINUX_X86_64 -DLINUX_X86_64_OPTERON  -DGNU_COMPILER 
   -I/home/kobus/include
   -L/home/kobus/misc/load/linux_x86_64_opteron -L/usr/lib/x86_64-linux-gnu
  -lKJB                               -lfftw3  -lgsl -lgslcblas -ljpeg  -lSVM -lstdc++                    -lpthread -lSLATEC -lg2c    -lacml -lacml_mv -lblas -lg2c      -lncursesw 


int diagonalize
(
	const Matrix *mp,
	Matrix **E_mpp,
	Vector **D_vpp
);

DESCRIPTION

Given a matrix A, this routine computes A = E*D*inv(E), where D is diagonal, and contains the eigenvalues of A, and the columns of E contain the eigenvectors. If A is symmetric, then the eigenvalues are real. If A is not symmetric, then the eigenvalues may, or may not be real. Currently, this routine only returns the real parts of the eigenvalues, and prints a warning message if any of the imaginary components of the eigenvalues exceed a certain threshold. For many applications, the routines diagonalize_symmetric(), and diagonalize_2() are prefered (see below). The matrix of eigenvectors is put into the matrix pointed to by *E_mpp, which is created or resized as needed. The diagonal matrix of eigenvalues is put into the vector pointed to by *D_vpp, which is also created or resized as needed.

RETURNS

NO_ERROR on success, and ERROR on failure, with an appropriate error message being set.

NOTE

The underlying assumption of this routine is that the matrix to be diagonalized is NOT symmetric, BUT you are expecting essentially real eigenvectors (this was the case for the first application which led to this wrapper). If the matrix is symmetric, this routine will work, but diagonalize_symmetric() should be better. If the matrix is suspected of having complex eigenvectors/eigenvalues, then use the routine diagonalize_2() as this one will print a warning for each eigenvalue with absolute value of the imaginary part greater than 0.0001 of the maximum absolute value of all the eigenvalues.

NOTE

This routine sorts the eigenvalues and eigenvectors from largest to smallest (opposite of Matlab). Also, the matrix of eigenvectors is ambigous up to a sign, so if you compare the results with other eigensolvers, you may have to multiply one of the results by -1.

NOTE

This routine requires that that the LAPACK library is available. If this file was compiled without the presence of that library, then this routine will return ERROR.

DISCLAIMER

This software is not adequatedly tested. It is recomended that results are checked independantly where appropriate.

AUTHOR

Kobus Barnard

DOCUMENTER

Kobus Barnard

SEE ALSO

diagonalize_2 , diagonalize_symmetric