ETHZ_Logo RAMSES_Logo_Right   RAMSES   RAMSES_Logo_Left Systems Ecology  
Start    search button      Modules:   A-Z   Function   Layer        QuickRefs:   DM   AuxLib   AuxLibE   SciLib   EasyMW   MW   ISIS   RMSLib

DEFINITION MODULE EigVecs;

  (*******************************************************************

    Module  EigVecs     (Version 1.0)

      Copyright (c) 1992-2006 by Dimitrios Gyalistras and ETH Zurich.

    Purpose   Calculate eigenvalues and eigenvectors of a
              real symmetric matrix.

    Remarks   Algorithms taken from W.H. Press et.al., Numerical
              Recipes, Cambridge 1988, ISBN 0521 30811 9, p 335ff.
              and pp748-750.


    Programming

      o Design
        Dimitrios Gyalistras      03/04/1992

      o Implementation
        Dimitrios Gyalistras      03/04/1992


    ETH Zurich
    Systems Ecology
    CHN E 35.1
    Universitaetstrasse 16
    8092 Zurich
    SWITZERLAND

    URLs:
        <mailto:RAMSES@env.ethz.ch>
        <http://www.sysecol.ethz.ch>
        <http://www.sysecol.ethz.ch/SimSoftware/RAMSES>


    Last revision of definition:  24/05/2002   AF

  *******************************************************************)


  IMPORT Errors;
  FROM LgMatrices IMPORT LMatrix, LVector;


  (******************************************************************)

  CONST  (* result codes returned *)
    allOk   = Errors.allOk;
    notDone = Errors.onlyAnInsert;

  (*
    Note: the dimensions of all LVector and LMatrix objects used below
    are determined automatically via procedures LgMatrices.NElems,
    LgMatrices.NRows and LgMatrices.NCols.
  *)


  PROCEDURE Jacobi( mat         : LMatrix;  (* in  *)
                    eigVals     : LVector;  (* out *)
  					eigVecs     : LMatrix;  (* out *)
  					VAR numRot  : INTEGER;
                    VAR resCode : INTEGER;
  					VAR errTxt  : ARRAY OF CHAR );
  (*
    Calculates all eigenvectors and eigenvalues of the real and
    symmetric N x N -matrix contained in mat, eigVals returns in
    its first N elements the eigen- values of mat.  eigVecs is a
    N x N -matrix returning the normalized eigenvectors of mat
    (sum of squares of vector elements = 1).  numRot returns the
    number of jacobi rotations which were required.

    IMPORTANT IMPLEMENTATION RESTRICTIONS:

      1) A non-symmetrical matrix mat is quietly accepted without
         generating an error message. However, all returned results
         are WRONG!!!!!

      2) After calling this procedure, all elements of mat
         above the diagonal will have been overwritten with 0!
  *)

  PROCEDURE EigSort( eigVals     : LVector;  (* in/out *)
                     eigVecs     : LMatrix;  (* in/out *)
                     VAR resCode : INTEGER;
  					 VAR errTxt  : ARRAY OF CHAR );
  (*
    Given N eigenvalues in vector eigVals and the N x N -matrix eigVecs
    containing the corresponding eigenvectors (as obtained both from
    procedure Jacobi), this routine sorts the eigenvalues in descending
    order.  The columns of the eigVecs-matrix are rearranged
    correspondingly.  The method used is straight insertion.
  *)

END EigVecs.

  Contact RAMSES@env.ethz.ch Last updated: 25-Jul-2011 [Top of page]