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.

Version:
$Revision: 1.5 $
Author:
Marko van Dooren, Tom Schrijvers

Field Summary
static java.lang.String CVS_REVISION
           
 
Constructor Summary
Math()
           
 
Method Summary
static long lpower(long base, long exponent)
          public behavior

pre exponent > 0;

post \result == java.lang.Math.pow(base,exponent);
static void main(java.lang.String[] args)
           
static double power(double base, long exponent)
          public behavior

pre exponent > 0;

post \result == java.lang.Math.pow(base,exponent);
static double sign(double x)
          public behavior

post (x>=0) => \result == 1;
post (x<0) => \result == -1;
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)
public behavior

post (x>=0) => \result == 1;
post (x<0) => \result == -1;
Return the sign of x
Parameters:
x - The number of which the sign is requested.

lpower

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

pre exponent > 0;

post \result == java.lang.Math.pow(base,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

power

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

pre exponent > 0;

post \result == java.lang.Math.pow(base,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

main

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