Code covered by the BSD License  

Highlights from
slatec

from slatec by Ben Barrowes
The slatec library converted into matlab functions.

[nm,n,a,wr,wi,matz,z,iv1,fv1,ierr]=rg(nm,n,a,wr,wi,matz,z,iv1,fv1,ierr);
function [nm,n,a,wr,wi,matz,z,iv1,fv1,ierr]=rg(nm,n,a,wr,wi,matz,z,iv1,fv1,ierr);
%***BEGIN PROLOGUE  RG
%***PURPOSE  Compute the eigenvalues and, optionally, the eigenvectors
%            of a real general matrix.
%***LIBRARY   SLATEC (EISPACK)
%***CATEGORY  D4A2
%***TYPE      SINGLE PRECISION (RG-S, CG-C)
%***KEYWORDS  EIGENVALUES, EIGENVECTORS, EISPACK
%***AUTHOR  Smith, B. T., et al.
%***DESCRIPTION
%
%     This subroutine calls the recommended sequence of
%     subroutines from the eigensystem subroutine package (EISPACK)
%     To find the eigenvalues and eigenvectors (if desired)
%     of a REAL GENERAL matrix.
%
%     On Input
%
%        NM must be set to the row dimension of the two-dimensional
%          array parameters, A and Z, as declared in the calling
%          program dimension statement.  NM is an INTEGER variable.
%
%        N is the order of the matrix A.  N is an INTEGER variable.
%          N must be less than or equal to NM.
%
%        A contains the real general matrix.  A is a two-dimensional
%          REAL array, dimensioned A(NM,N).
%
%        MATZ is an INTEGER variable set equal to zero if only
%          eigenvalues are desired.  Otherwise, it is set to any
%          non-zero integer for both eigenvalues and eigenvectors.
%
%     On Output
%
%        A has been destroyed.
%
%        WR and WI contain the real and imaginary parts, respectively,
%          of the eigenvalues.  The eigenvalues are unordered except
%          that complex conjugate pairs of eigenvalues appear consecu-
%          tively with the eigenvalue having the positive imaginary part
%          first.  If an error exit is made, the eigenvalues should be
%          correct for indices IERR+1, IERR+2, ..., N.  WR and WI are
%          one-dimensional REAL arrays, dimensioned WR(N) and WI(N).
%
%        Z contains the real and imaginary parts of the eigenvectors
%          if MATZ is not zero.  If the J-th eigenvalue is real, the
%          J-th column of Z contains its eigenvector.  If the J-th
%          eigenvalue is complex with positive imaginary part, the
%          J-th and (J+1)-th columns of Z contain the real and
%          imaginary parts of its eigenvector.  The conjugate of this
%          vector is the eigenvector for the conjugate eigenvalue.
%          Z is a two-dimensional REAL array, dimensioned Z(NM,N).
%
%        IERR is an INTEGER flag set to
%          Zero       for normal return,
%          10*N       if N is greater than NM,
%          J          if the J-th eigenvalue has not been
%                     determined after a total of 30 iterations.
%                     The eigenvalues should be correct for indices
%                     IERR+1, IERR+2, ..., N, but no eigenvectors are
%                     computed.
%
%        IV1 and FV1 are one-dimensional temporary storage arrays of
%          dimension N.  IV1 is of type INTEGER and FV1 of type REAL.
%
%     Questions and comments should be directed to B. S. Garbow,
%     APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
%     ------------------------------------------------------------------
%
%***REFERENCES  B. T. Smith, J. M. Boyle, J. J. Dongarra, B. S. Garbow,
%                 Y. Ikebe, V. C. Klema and C. B. Moler, Matrix Eigen-
%                 system Routines - EISPACK Guide, Springer-Verlag,
%                 1976.
%***ROUTINES CALLED  BALANC, BALBAK, ELMHES, ELTRAN, HQR, HQR2
%***REVISION HISTORY  (YYMMDD)
%   760101  DATE WRITTEN
%   890831  Modified array declarations.  (WRB)
%   890831  REVISION DATE from Version 3.2
%   891214  Prologue converted to Version 4.0 format.  (BAB)
%   920501  Reformatted the REFERENCES section.  (WRB)
%   921103  Corrected description of IV1.  (DWL, FNF and WRB)
%***end PROLOGUE  RG
%
persistent is1 is2 ; 

if isempty(is1), is1=0; end;
if isempty(is2), is2=0; end;
a_shape=size(a);a=reshape([a(:).',zeros(1,ceil(numel(a)./prod([nm])).*prod([nm])-numel(a))],nm,[]);
wr_shape=size(wr);wr=reshape(wr,1,[]);
wi_shape=size(wi);wi=reshape(wi,1,[]);
z_shape=size(z);z=reshape([z(:).',zeros(1,ceil(numel(z)./prod([nm])).*prod([nm])-numel(z))],nm,[]);
fv1_shape=size(fv1);fv1=reshape(fv1,1,[]);
iv1_shape=size(iv1);iv1=reshape(iv1,1,[]);
%
%***FIRST EXECUTABLE STATEMENT  RG
if( n<=nm )
%
[nm,n,a,is1,is2,fv1]=balanc(nm,n,a,is1,is2,fv1);
[nm,n,is1,is2,a,iv1]=elmhes(nm,n,is1,is2,a,iv1);
if( matz~=0 )
%     .......... FIND BOTH EIGENVALUES AND EIGENVECTORS ..........
[nm,n,is1,is2,a,iv1,z]=eltran(nm,n,is1,is2,a,iv1,z);
[nm,n,is1,is2,a,wr,wi,z,ierr]=hqr2(nm,n,is1,is2,a,wr,wi,z,ierr);
if( ierr==0 )
n_orig=n;    [nm,n,is1,is2,fv1,dumvar6,z]=balbak(nm,n,is1,is2,fv1,n,z);    n(dumvar6~=n_orig)=dumvar6(dumvar6~=n_orig);
end;
else;
%     .......... FIND EIGENVALUES ONLY ..........
[nm,n,is1,is2,a,wr,wi,ierr]=hqr(nm,n,is1,is2,a,wr,wi,ierr);
end;
else;
ierr = fix(10.*n);
end;
a_shape=zeros(a_shape);a_shape(:)=a(1:numel(a_shape));a=a_shape;
wr_shape=zeros(wr_shape);wr_shape(:)=wr(1:numel(wr_shape));wr=wr_shape;
wi_shape=zeros(wi_shape);wi_shape(:)=wi(1:numel(wi_shape));wi=wi_shape;
z_shape=zeros(z_shape);z_shape(:)=z(1:numel(z_shape));z=z_shape;
fv1_shape=zeros(fv1_shape);fv1_shape(:)=fv1(1:numel(fv1_shape));fv1=fv1_shape;
iv1_shape=zeros(iv1_shape);iv1_shape(:)=iv1(1:numel(iv1_shape));iv1=iv1_shape;
end
%DECK RGG

Contact us at files@mathworks.com