DEFINITION MODULE NumAlLib1;

  (*------------------------------------------------------------------------*)
  (* Einige Routinen aus der NUMAL Numerical Algol library (Stichting CWI)  *)
  (* Teil 1 (numal5p1)                                                      *)
  (* Some routinen from the NUMAL Numerical Algol library (Stichting CWI)   *)
  (*------------------------------------------------------------------------*)
  (* Implementation : Michael Riedl                                         *)
  (* Licence        : GNU Lesser General Public License (LGPL)              *)
  (*------------------------------------------------------------------------*)

  (* $Id: NumAlLib1.def,v 1.1 2018/01/16 09:20:20 mriedl Exp $ *)

PROCEDURE ChlDec1(VAR A        : ARRAY OF LONGREAL;
                      N        : CARDINAL;
                  VAR iFehl    : INTEGER;
                      eps      : LONGREAL);

          (*----------------------------------------------------------------*)
          (* Performs the cholesky decomposition of a symmetric positive    *)
          (* definite matrix, whose upper triangle is stored in a one-      *)
          (* dimensional array, by cholesky's square root method without    *)
          (* pivoting.                                                      *)
          (*                                                                *)
          (* formal parameters:                                             *)
          (*                                                                *)
          (*  A     : Array of dimension A[1 : N*(N+1)/2]                   *)
          (*          - on entry the upper-triangular part of the  positive *)
          (*            definite symmetric matrix must be given columnwise  *)
          (*            in array A (the (i,j)-th element of the matrix must *)
          (*            be given in a[(j-1)*j / 2 + i]; 1 <= i <= j <= n);  *)
          (*          - on exit the  cholesky decomposition of the matrix   *)
          (*            is delivered columnwise in A.                       *)
          (*  N     : the order of the matrix                               *)
          (*  iFehl : exit code                                             *)
          (*          - for normal exit iFehl is 0                          *)
          (*          - if the decomposition cannot be carried out because  *)
          (*            the matrix is (numerically) not positive definite,  *)
          (*            iFehl = k - 1, where k is the last stage number     *)
          (*            (abnormal exit)                                     *)
          (*  eps   : a relative tolerance used to control the calculation  *)
          (*          of the diagonal elements;                             *)
          (*                                                                *)
          (* Source: NUMAL Numerical Algol library (Stichting CWI)          *)
          (*----------------------------------------------------------------*)

PROCEDURE ChlSol1(    N : CARDINAL;
                  VAR A : ARRAY OF LONGREAL; (* SUPERVEKTOR *)
                  VAR B : ARRAY OF LONGREAL);

          (* ---------------------------------------------------------------*)
          (* Calculates the solution of a system of linear equations,       *)
          (* provided that the coefficient matrix has been decomposed by a  *)
          (* successful call of chldec1 or chldecsol1.                      *)
          (* Several systems with the same coefficient matrix but different *)
          (* right hand sides can be solved by successive calls of chlsol1. *)
          (*                                                                *)
          (* formal parameters:                                             *)
          (*                                                                *)
          (*   N  : the order of the matrix                                 *)
          (*   A  : the upper-triangular part of the cholesky matrix as     *)
          (*        produced by ChlDec (the contents of A is not changed)   *)
          (*   B  : vector parameter                                        *)
          (*        - On entry the right hand side ot the system of linear  *)
          (*          equations                                             *)
          (*        - On exit the solution of the system                    *)
          (*                                                                *)
          (* Source: NUMAL Numerical Algol library (Stichting CWI)          *)
          (*----------------------------------------------------------------*)

PROCEDURE ChlInv1(VAR A : ARRAY OF LONGREAL;
                      N : CARDINAL);

          (*----------------------------------------------------------------*)
          (* Calculated the inversion of a symmetric positive definite      *)
          (* matrix, if the matrix has been decomposed by a call of the     *)
          (* procedure ChlDec1                                              *)
          (*                                                                *)
          (* formal parameters:                                             *)
          (*                                                                *)
          (* A  : array A[1:(N+1)*N / 2]                                    *)
          (*      on entry : upper-triangular part of the cholesky matrix   *)
          (*                 as produced  by chldec1 columnwise in array a  *)
          (*      on exit  : upper-triangular part of the inverse matrix is *)
          (*                 delivered columnwise in array a                *)
          (* N  : the order of the matrix.                                  *)
          (*                                                                *)
          (* Source: NUMAL Numerical Algol library (Stichting CWI)          *)
          (*----------------------------------------------------------------*)

END NumAlLib1.
