uk.ac.ic.doc.automed.util
Class NumberToolkit

java.lang.Object
  extended by uk.ac.ic.doc.automed.util.NumberToolkit

public class NumberToolkit
extends java.lang.Object

NumberToolkit.java Deals with number manipulation

Version:
1.0 Department of Computing, Imperial College
Author:
Duc M Le dmle@doc.ic.ac.uk

Field Summary
private static java.util.Random R
          a random number generator
 
Constructor Summary
private NumberToolkit()
          Creates a new instance of NumberToolkit
 
Method Summary
static java.lang.Object cloneNumber(java.lang.Object numObject)
           
static AutoMedType[][] createAutoMedNumberRanges(int min, int max, int numEqualRanges)
          Devide an integer range into an equal number of disjoint, equal-sized sub-ranges
static void createBinSequence(int[] binPattern, int position, int positions, int length, java.util.List seql)
          Create a List of all binary sequences of n where each sequence contains exactly k ones
static int[][] createNumberRanges(int min, int max, int numEqualRanges)
          Devide an integer range into an equal number of disjoint, equal-sized sub-ranges
static java.lang.String getBitString(int val)
          Get the bit string of an integer value
private static int[] outputBinSequence(int[] string, int position, int length)
          Used by createBinSequence(int string[], int position, int positions, int length, List seql) method
static double parseDouble(java.lang.Object numObject)
          Parse a numeric object to get double value.
static java.lang.Number parseNumber(java.lang.Object numObject)
          Parse a numeric object to a Number object for different usages.
If the input object is null then this method returns Number 0.
static int randomInt()
           
static long randomLong()
           
static int[][] toIntegerArray(AutoMedType[][] arr)
          Convert a 2-dimensional AutoMedIntegerType array to integer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

R

private static java.util.Random R
a random number generator

Constructor Detail

NumberToolkit

private NumberToolkit()
Creates a new instance of NumberToolkit

Method Detail

getBitString

public static java.lang.String getBitString(int val)
Get the bit string of an integer value


createNumberRanges

public static int[][] createNumberRanges(int min,
                                         int max,
                                         int numEqualRanges)
Devide an integer range into an equal number of disjoint, equal-sized sub-ranges

Returns:
int[][] a two dimensional array with 1st dimension containing low
values and 2nd dimension containing high values

createAutoMedNumberRanges

public static AutoMedType[][] createAutoMedNumberRanges(int min,
                                                        int max,
                                                        int numEqualRanges)
Devide an integer range into an equal number of disjoint, equal-sized sub-ranges

Returns:
AutoMedType[][] a two dimensional array with 1st dimension containing low
values and 2nd dimension containing high values

toIntegerArray

public static int[][] toIntegerArray(AutoMedType[][] arr)
Convert a 2-dimensional AutoMedIntegerType array to integer


createBinSequence

public static void createBinSequence(int[] binPattern,
                                     int position,
                                     int positions,
                                     int length,
                                     java.util.List seql)
Create a List of all binary sequences of n where each sequence contains exactly k ones

Parameters:
int[] - an empty binary sequence array to serve as the place holder for all sequences to be created
int - position the index position to start in the sequence
int - positions the number of one-positions (i.e. k)
seql - the output list which contains all k-one binary sequence created Adapted from "Efficiently Enumerating the Subsets of a Set", URL: http://citeseer.ist.psu.edu/529895.html

outputBinSequence

private static int[] outputBinSequence(int[] string,
                                       int position,
                                       int length)
Used by createBinSequence(int string[], int position, int positions, int length, List seql) method


parseDouble

public static double parseDouble(java.lang.Object numObject)
Parse a numeric object to get double value. If the input object is null then this method returns the double value 0D.


parseNumber

public static java.lang.Number parseNumber(java.lang.Object numObject)
Parse a numeric object to a Number object for different usages.
If the input object is null then this method returns Number 0.


cloneNumber

public static java.lang.Object cloneNumber(java.lang.Object numObject)

randomInt

public static int randomInt()

randomLong

public static long randomLong()