Class Utility

java.lang.Object
  extended by Utility

final class Utility
extends Object


Method Summary
(package private) static long gcd(long a, long b)
          Calculates the greatest common divisor of two given integers using Euclid's algorithm.
(package private) static int[] generatePermutation(int n)
          Generates a permutation of integers 1 to n.
(package private) static long lcm(long a, long b)
          Calculates the least common multiple of two given integers using formula lcm(a,b)=(a*b)/gcd(a,b).
(package private) static boolean randBool()
          Generates a random boolean.
(package private) static int randInt(int min, int max)
          Generates a random number from interval (inclusive), while the numbers closer to the center of the interval are more probable.
(package private) static int randIntUniform(int min, int max)
          Generates a random number from interval (inclusive).
(package private) static int[] randNTuple(int min, int max, int n)
          Generates an n-tuple of random numbers from interval (inclusive), while the numbers closer to the center of the interval are more probable.
(package private) static int[] randNTupleUniform(int min, int max, int n)
          Generates an n-tuple of random numbers from interval (inclusive).
(package private) static void texOut(String str)
          Writes to tex file containing results.
(package private) static void textOut(String str)
          Writes to text file containing results.
 
Methods inherited from class
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

gcd

static long gcd(long a,
                long b)
Calculates the greatest common divisor of two given integers using Euclid's algorithm.

Parameters:
a - the first number
b - the other number
Returns:
greatest common divisor of the arguments (gcd is always positive, gcd(x,0) returns |x|)

generatePermutation

static int[] generatePermutation(int n)
Generates a permutation of integers 1 to n.

Parameters:
n - number of integers to permutate

lcm

static long lcm(long a,
                long b)
Calculates the least common multiple of two given integers using formula lcm(a,b)=(a*b)/gcd(a,b).

Parameters:
a - the first number
b - the other number
Returns:
least common multiple of the arguments (gcd is always non-negative)

randBool

static boolean randBool()
Generates a random boolean.


randInt

static int randInt(int min,
                   int max)
Generates a random number from interval (inclusive), while the numbers closer to the center of the interval are more probable.

Parameters:
min - minimum value
max - maximum value (must be at least min; if min is greater than max, we switch the values)

randIntUniform

static int randIntUniform(int min,
                          int max)
Generates a random number from interval (inclusive).

Parameters:
min - minimum value
max - maximum value (must be at least min; if min is greater than max, we switch the values)

randNTuple

static int[] randNTuple(int min,
                        int max,
                        int n)
Generates an n-tuple of random numbers from interval (inclusive), while the numbers closer to the center of the interval are more probable.

Parameters:
min - minimum value
max - maximum value (must be greater than min; if min is greater than max, we switch the values)

randNTupleUniform

static int[] randNTupleUniform(int min,
                               int max,
                               int n)
Generates an n-tuple of random numbers from interval (inclusive).

Parameters:
min - minimum value
max - maximum value (must be greater than min; if min is greater than max, we switch the values)

texOut

static void texOut(String str)
Writes to tex file containing results.

Parameters:
str - string to be written

textOut

static void textOut(String str)
Writes to text file containing results.

Parameters:
str - string to be written