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

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

    Module  MathProcs     (Version 1.0)

      Copyright (c) 1986-2006 by Olivier Roth, Andreas Fischlin 
      and ETH Zurich

    Purpose   Some often used mathematical functions (REAL variant)

    Remarks   This module is a single precision (REAL) variant of 
              the companion module LMathProcs


    Programming

      o Design
        Olivier Roth              13/11/1986

      o Implementation
        Olivier Roth              13/11/1986
        Andreas Fischlin          17/03/1987


    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:  19/08/2007  af

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


  (****************************************)
  (*#####   MATHEMATICAL FUNCTIONS   #####*)
  (****************************************)
  
  PROCEDURE Equal (x,y: REAL): BOOLEAN;
  (*
    Returns wether two reals x and y are equal or differ at
    most by a small amount epsilon (ABS(x-y)<=epsilon).  The
    parameter epsilon is computed in a machine dependent way
    and represents the absolute minimum difference between two
    single precision real variables as defined by the floating
    point precision of the machine on which this module
    currently executes.  
  *)


  PROCEDURE SIGN (x: REAL): REAL;
  (* returns the sign of x, i.e. -1.0 or +1.0 depending on the sign of x *)

  PROCEDURE Int(x: REAL): INTEGER;
  (* returns the truncated integer part of real x*)

  PROCEDURE Round(x: REAL): INTEGER;
  (* returns the rounded integer part of real x *)
  
  PROCEDURE Frac (x: REAL): REAL;
  (* returns the fractional part of x (part after the decimal point) *)
  
  
  PROCEDURE PowerI( x: REAL; iexp: INTEGER): REAL;
  (* returns x to the power of iexp *)

  PROCEDURE Power( x, exp: REAL ): REAL;
  (* returns x to the power of exp *)

  PROCEDURE Lg(x: REAL): REAL;
  (* returns the logarithm of x to base 10 *)

  PROCEDURE Fac(k: CARDINAL): CARDINAL;
  (*
    returns the factorial for k, i.e. k!  =
    k*(k-1)*(k-2)*(k-3)...*1 (note 0!  = 1) 
  *)

  PROCEDURE IMax(i1,i2: INTEGER): INTEGER;
  (* returns maximum value of the two integers i1 and i2 *)

  PROCEDURE IMin(i1,i2: INTEGER): INTEGER;
  (* returns minimum value of the two integers i1 and i2 *)

  PROCEDURE RMax(x1,x2: REAL): REAL;
  (* returns maximum value of the two reals x1 and x2 *)

  PROCEDURE RMin(x1,x2: REAL): REAL;
  (* returns minimum value of the two reals x1 and x2 *)



  (******************************)
  (*#####   TRIGONOMETRY   #####*)
  (******************************)

  PROCEDURE Pi(): REAL;
  (* returns pi *)

  PROCEDURE Tan(x: REAL): REAL;
  (* returns the tangens of angle x in radians *)

  PROCEDURE ArcSin(x: REAL): REAL;
  (*
    Returns the inverse in radians of sine x (Note, with x
    in [-1.0..1.0] LongArcSin(x) returns values in [-pi/2 .. +pi/2]).
  *)

  PROCEDURE ArcCos(x: REAL): REAL;
  (*
    Returns the inverse in radians of cosine x (Note, with x
    in [-1.0..1.0] LongArcCos(x) returns values in [0 .. pi]).
  *)



END MathProcs.

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