wavelet_util
Class binary

java.lang.Object
  |
  +--wavelet_util.binary

public class binary
extends java.lang.Object

Calculate power and log functions using fast binary operations.


Constructor Summary
binary()
           
 
Method Summary
static byte log2(int val)
           Calculate floor( log2( val ) ), where val > 0
static int nearestPower2(int val)
          nearestPower2
static int power2(byte n)
          Calculate 2n where n >= 0
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Constructor Detail

binary

public binary()
Method Detail

power2

public static int power2(byte n)
Calculate 2n where n >= 0
Parameters:
n - a value between 0..31
Returns:
power2 returns 2n

log2

public static byte log2(int val)

Calculate floor( log2( val ) ), where val > 0

The log function is undefined for 0.

Parameters:
val - a positive value
Returns:
floor( log2( val ) )

nearestPower2

public static int nearestPower2(int val)
nearestPower2

Given a value "val", where val > 0, nearestPower2 returns the power of 2 that is less than or equal to val.