org.netlib.util
Class Util

java.lang.Object
  extended by org.netlib.util.Util
Direct Known Subclasses:
StrictUtil

public class Util
extends java.lang.Object

Implementations of various Fortran intrinsic functions.

This file is part of the Fortran-to-Java (f2j) system, developed at the University of Tennessee.

This class contains various helper routines for f2j-generated code. These routines are primarily implemented for handling Fortran intrinsic functions.

Author:
Keith Seymour (seymour@cs.utk.edu)

Constructor Summary
Util()
           
 
Method Summary
static double cosh(double a)
          Fortran hyperbolic cosine (COSH) intrinsic function.
static double ddim(double a1, double a2)
          Fortran double precision positive difference (DDIM) intrinsic function.
static float dim(float a1, float a2)
          Fortran floating point positive difference (DIM) intrinsic function.
static double dsign(double a1, double a2)
          Fortran double precision transfer of sign (DSIGN) intrinsic function.
static int idim(int a1, int a2)
          Fortran integer positive difference (IDIM) intrinsic function.
static int idnint(double x)
          Fortran nearest integer (IDNINT) intrinsic function.
static int isign(int a1, int a2)
          Fortran integer transfer of sign (ISIGN) intrinsic function.
static double log10(double x)
          Base-10 logarithm function.
static float log10(float x)
          Base-10 logarithm function.
static double max(double x, double y, double z)
          Three argument double precision max function.
static float max(float x, float y, float z)
          Three argument single precision max function.
static int max(int x, int y, int z)
          Three argument integer max function.
static double min(double x, double y, double z)
          Three argument double precision min function.
static float min(float x, float y, float z)
          Three argument single precision min function.
static int min(int x, int y, int z)
          Three argument integer min function.
static int nint(float x)
          Fortran nearest integer (NINT) intrinsic function.
static void pause()
          Pauses execution temporarily.
static void pause(java.lang.String msg)
          Pauses execution temporarily.
static float sign(float a1, float a2)
          Fortran floating point transfer of sign (SIGN) intrinsic function.
static double sinh(double a)
          Fortran hyperbolic sine (SINH) intrinsic function.
static java.lang.String stringInsert(java.lang.String x, java.lang.String y, int E1, int E2)
          Inserts a string into a substring of another string.
static double tanh(double a)
          Fortran hyperbolic tangent (TANH) intrinsic function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

stringInsert

public static java.lang.String stringInsert(java.lang.String x,
                                            java.lang.String y,
                                            int E1,
                                            int E2)
Inserts a string into a substring of another string.

This method handles situations in which the lhs of an assignment statement is a substring operation. For example:

a(3:4) = 'hi'

We haven't figured out an elegant way to do this with Java Strings, but we do handle it, as follows:

a = new StringW( a.val.substring(0,E1-1) + "hi".substring(0,E2-E1+1) + a.val.substring(E2,a.val.length()) );

Where E1 is the expression representing the starting index of the substring and E2 is the expression representing the ending index of the substring

The resulting code looks pretty bad because we have to be prepared to handle rhs strings that are too big to fit in the lhs substring.

Parameters:
x - dest (string to be inserted into)
y - source (substring to insert into 'x')
E1 - expression representing the start of the substring
E2 - expression representing the end of the substring
Returns:
the string containing the complete string after inserting the substring

max

public static int max(int x,
                      int y,
                      int z)
Three argument integer max function.

Parameters:
x - value 1
y - value 2
z - value 3
Returns:
the largest of x, y, or z

max

public static float max(float x,
                        float y,
                        float z)
Three argument single precision max function.

Parameters:
x - value 1
y - value 2
z - value 3
Returns:
the largest of x, y, or z

max

public static double max(double x,
                         double y,
                         double z)
Three argument double precision max function.

Parameters:
x - value 1
y - value 2
z - value 3
Returns:
the largest of x, y, or z

min

public static int min(int x,
                      int y,
                      int z)
Three argument integer min function.

Parameters:
x - value 1
y - value 2
z - value 3
Returns:
the smallest of x, y, or z

min

public static float min(float x,
                        float y,
                        float z)
Three argument single precision min function.

Parameters:
x - value 1
y - value 2
z - value 3
Returns:
the smallest of x, y, or z

min

public static double min(double x,
                         double y,
                         double z)
Three argument double precision min function.

Parameters:
x - value 1
y - value 2
z - value 3
Returns:
the smallest of x, y, or z

log10

public static double log10(double x)
Base-10 logarithm function.

Parameters:
x - the value
Returns:
base-10 log of x

log10

public static float log10(float x)
Base-10 logarithm function.

Parameters:
x - the value
Returns:
base-10 log of x

nint

public static int nint(float x)
Fortran nearest integer (NINT) intrinsic function.

Returns:

  • (int)(x+0.5), if x >= 0
  • (int)(x-0.5), if x < 0

Parameters:
x - the floating point value
Returns:
the nearest integer to x

idnint

public static int idnint(double x)
Fortran nearest integer (IDNINT) intrinsic function.

Returns:

  • (int)(x+0.5), if x >= 0
  • (int)(x-0.5), if x < 0

Parameters:
x - the double precision floating point value
Returns:
the nearest integer to x

sign

public static float sign(float a1,
                         float a2)
Fortran floating point transfer of sign (SIGN) intrinsic function.

Returns:

  • abs(a1), if a2 >= 0
  • -abs(a1), if a2 < 0

Parameters:
a1 - floating point value
a2 - sign transfer indicator
Returns:
equivalent of Fortran SIGN(a1,a2) as described above.

isign

public static int isign(int a1,
                        int a2)
Fortran integer transfer of sign (ISIGN) intrinsic function.

Returns:

  • abs(a1), if a2 >= 0
  • -abs(a1), if a2 < 0

Parameters:
a1 - integer value
a2 - sign transfer indicator
Returns:
equivalent of Fortran ISIGN(a1,a2) as described above.

dsign

public static double dsign(double a1,
                           double a2)
Fortran double precision transfer of sign (DSIGN) intrinsic function.

Returns:

  • abs(a1), if a2 >= 0
  • -abs(a1), if a2 < 0

Parameters:
a1 - double precision floating point value
a2 - sign transfer indicator
Returns:
equivalent of Fortran DSIGN(a1,a2) as described above.

dim

public static float dim(float a1,
                        float a2)
Fortran floating point positive difference (DIM) intrinsic function.

Returns:

  • a1 - a2, if a1 > a2
  • 0, if a1 <= a2

Parameters:
a1 - floating point value
a2 - floating point value
Returns:
equivalent of Fortran DIM(a1,a2) as described above.

idim

public static int idim(int a1,
                       int a2)
Fortran integer positive difference (IDIM) intrinsic function.

Returns:

  • a1 - a2, if a1 > a2
  • 0, if a1 <= a2

Parameters:
a1 - integer value
a2 - integer value
Returns:
equivalent of Fortran IDIM(a1,a2) as described above.

ddim

public static double ddim(double a1,
                          double a2)
Fortran double precision positive difference (DDIM) intrinsic function.

Returns:

  • a1 - a2, if a1 > a2
  • 0, if a1 <= a2

Parameters:
a1 - double precision floating point value
a2 - double precision floating point value
Returns:
equivalent of Fortran DDIM(a1,a2) as described above.

sinh

public static double sinh(double a)
Fortran hyperbolic sine (SINH) intrinsic function.

Parameters:
a - the value to get the sine of
Returns:
the hyperbolic sine of a

cosh

public static double cosh(double a)
Fortran hyperbolic cosine (COSH) intrinsic function.

Parameters:
a - the value to get the cosine of
Returns:
the hyperbolic cosine of a

tanh

public static double tanh(double a)
Fortran hyperbolic tangent (TANH) intrinsic function.

Parameters:
a - the value to get the tangent of
Returns:
the hyperbolic tangent of a

pause

public static void pause()
Pauses execution temporarily.

I think this was an implementation dependent feature of Fortran 77.


pause

public static void pause(java.lang.String msg)
Pauses execution temporarily.

I think this was an implementation dependent feature of Fortran 77.

Parameters:
msg - the message to be printed before pausing. if null, no message will be printed.