org.jutil.math
Class Math

java.lang.Object
  |
  +--org.jutil.math.Math

public abstract class Math
extends java.lang.Object

This is a general utility class for mathematical stuff.


Field Summary
static java.lang.String CVS_REVISION
           
 
Constructor Summary
Math()
           
 
Method Summary
static long lpower(long base, long exponent)
          Compute a^b when b is positive.
static void main(java.lang.String[] args)
           
static double power(double base, long exponent)
          Compute a^b when b is positive.
static double sign(double x)
          Return the sign of x
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CVS_REVISION

public static final java.lang.String CVS_REVISION
Constructor Detail

Math

public Math()
Method Detail

sign

public static double sign(double x)
Return the sign of x

Parameters:
x - The number of which the sign is requested.

Specifications:
public behavior
ensures (x >= 0) ==> \result == 1;
ensures (x < 0) ==> \result == -1;

lpower

public static final long lpower(long base,
                                long exponent)

Compute a^b when b is positive. This metod is significantly faster than Math.pow, but introduces slightly different result than Math.pow (Although I've only seen differences in the last digit up to now, and also Math.pow doesn't always return the exact same result as Matlab).

To give you an idea, it is more than 10 times faster using Sun jdk 1.4.0 on a celeron 366MHz and a P4 1.5GHz processor.

Parameters:
base - The number of which the exponent'th power is requested
exponent - The exponent

Specifications:
public behavior
requires exponent > 0;
ensures (* \result == java.lang.Math.pow(base,exponent) *);

power

public static final double power(double base,
                                 long exponent)

Compute a^b when b is positive. This metod is significantly faster than Math.pow, but introduces slightly different result than Math.pow (Although I've only seen differences in the last digit up to now, and also Math.pow doesn't always return the exact same result as Matlab).

To give you an idea, it is more than 10 times faster using Sun jdk 1.4.0 on a celeron 366MHz and a P4 1.5GHz processor.

Parameters:
base - The number of which the exponent'th power is requested
exponent - The exponent

Specifications:
public behavior
requires exponent > 0;
ensures (* \result == java.lang.Math.pow(base,exponent) *);

main

public static void main(java.lang.String[] args)