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 LMatInvert;


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

    Module  LMatInvert     (Version 1.0)

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

    Purpose   Compute the inverse of a double precision 
              matrix and solve a linear equation system 
              (matrix dimensions up to 62 x 62).
              
    Remarks   Algorithms (LU decomposition) taken from
              Press, W.H. et al. (1988). Numerical Recipes,
              Cambridge, pp 31-38 (ISBN 0521 30811 9).


    Programming

      o Design
        Dimitrios Gyalistras      11/05/1995

      o Implementation
        Dimitrios Gyalistras      11/05/1995


    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:  14/09/1999  AF

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


   FROM LMatrices IMPORT LMatrix, LVector;


   PROCEDURE GetMatInvertTolerance( VAR tol: LONGREAL );


   PROCEDURE SetMatInvertTolerance( tol: LONGREAL );
   (*
     Absolute tolerance for testing the inverse of a matrix or the
     solution of a linear system (see below). Default value is 1.0E-12.
   *)


   PROCEDURE InvertMatrix( VAR mat   : LMatrix;  (* VAR for speed-up only *)
                           nRowsCols : INTEGER;
                           VAR inv   : LMatrix;
                           VAR errTxt: ARRAY OF CHAR ): BOOLEAN;

   (*
     Computes the inverse matrix "inv" of matrix "mat" based on
     the LU Decomposition of "mat".  The procedure leaves "mat"
     untouched (unless the same variable is also passed as "inv").

     The procedure tests (1) whether "mat" is singular, and (2)
     whether
          | mat*inv[i,j] - one[i,j] | <= tol   (for all i,j),
     where "one" is the identity matrix, and "tol" is the currently
     set absolute tolerance.

     Returns FALSE and a corresponding error message in "errTxt"
     if one of these conditions is not met.
   *)



   PROCEDURE SolveLinEqu( VAR A     : LMatrix;  (* VAR for speed-up only *)
                          nRowsCols : INTEGER;
                          VAR b     : LVector;  (* VAR for speed-up only *)
                          VAR x     : LVector;
                          VAR errTxt: ARRAY OF CHAR ): BOOLEAN;
   (*
     Computes the solution "x" of the matrix equation "A x = b".
     The procedure leaves "A" and "b" untouched (unless the same
     variable is also passed as "x").

     The procedure tests (1) whether "mat" is singular, and (2)
     whether
            | (A*x)[i] - b[i] | <= tol   (for all i),
     where "tol" is the currently set absolute tolerance.

     Returns FALSE and a corresponding error message in "errTxt"
     if one of these conditions is not met.
   *)


END LMatInvert.

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