cern.jet.math
Class IntFunctions

java.lang.Object
  |
  +--cern.jet.math.IntFunctions

public class IntFunctions
extends java.lang.Object

Integer Function objects to be passed to generic methods. Same as Functions except operating on integers.

For aliasing see intFunctions.


Field Summary
static cern.colt.function.IntFunction abs
          Function that returns Math.abs(a) == (a < 0) ? -a : a.
static cern.colt.function.IntIntFunction and
          Function that returns a & b.
static cern.colt.function.IntIntFunction compare
          Function that returns a < b ? -1 : a > b ? 1 : 0.
static cern.colt.function.IntFunction dec
          Function that returns a--.
static cern.colt.function.IntIntFunction div
          Function that returns a / b.
static cern.colt.function.IntIntFunction equals
          Function that returns a == b ? 1 : 0.
static cern.colt.function.IntFunction factorial
          Function that returns (int) Arithmetic.factorial(a).
static cern.colt.function.IntFunction identity
          Function that returns its argument.
static cern.colt.function.IntFunction inc
          Function that returns a++.
static IntFunctions intFunctions
          Little trick to allow for "aliasing", that is, renaming this class.
static cern.colt.function.IntIntProcedure isEqual
          Function that returns a == b.
static cern.colt.function.IntIntProcedure isGreater
          Function that returns a > b.
static cern.colt.function.IntIntProcedure isLess
          Function that returns a < b.
static cern.colt.function.IntIntFunction max
          Function that returns Math.max(a,b).
static cern.colt.function.IntIntFunction min
          Function that returns Math.min(a,b).
static cern.colt.function.IntIntFunction minus
          Function that returns a - b.
static cern.colt.function.IntIntFunction mod
          Function that returns a % b.
static cern.colt.function.IntIntFunction mult
          Function that returns a * b.
static cern.colt.function.IntFunction neg
          Function that returns -a.
static cern.colt.function.IntFunction not
          Function that returns ~a.
static cern.colt.function.IntIntFunction or
          Function that returns a | b.
static cern.colt.function.IntIntFunction plus
          Function that returns a + b.
static cern.colt.function.IntIntFunction pow
          Function that returns (int) Math.pow(a,b).
static cern.colt.function.IntIntFunction shiftLeft
          Function that returns a << b.
static cern.colt.function.IntIntFunction shiftRightSigned
          Function that returns a >> b.
static cern.colt.function.IntIntFunction shiftRightUnsigned
          Function that returns a >>> b.
static cern.colt.function.IntFunction sign
          Function that returns a < 0 ? -1 : a > 0 ? 1 : 0.
static cern.colt.function.IntFunction square
          Function that returns a * a.
static cern.colt.function.IntIntFunction xor
          Function that returns a ^ b.
 
Constructor Summary
protected IntFunctions()
          Makes this class non instantiable, but still let's others inherit from it.
 
Method Summary
static cern.colt.function.IntFunction and(int b)
          Constructs a function that returns a & b.
static cern.colt.function.IntFunction between(int from, int to)
          Constructs a function that returns (from<=a && a<=to) ? 1 : 0.
static cern.colt.function.IntFunction bindArg1(cern.colt.function.IntIntFunction function, int c)
          Constructs a unary function from a binary function with the first operand (argument) fixed to the given constant c.
static cern.colt.function.IntFunction bindArg2(cern.colt.function.IntIntFunction function, int c)
          Constructs a unary function from a binary function with the second operand (argument) fixed to the given constant c.
static cern.colt.function.IntFunction chain(cern.colt.function.IntFunction g, cern.colt.function.IntFunction h)
          Constructs the function g( h(a) ).
static cern.colt.function.IntIntFunction chain(cern.colt.function.IntFunction g, cern.colt.function.IntIntFunction h)
          Constructs the function g( h(a,b) ).
static cern.colt.function.IntIntFunction chain(cern.colt.function.IntIntFunction f, cern.colt.function.IntFunction g, cern.colt.function.IntFunction h)
          Constructs the function f( g(a), h(b) ).
static cern.colt.function.IntFunction compare(int b)
          Constructs a function that returns a < b ? -1 : a > b ? 1 : 0.
static cern.colt.function.IntFunction constant(int c)
          Constructs a function that returns the constant c.
static cern.colt.function.IntFunction div(int b)
          Constructs a function that returns a / b.
static cern.colt.function.IntFunction equals(int b)
          Constructs a function that returns a == b ? 1 : 0.
static cern.colt.function.IntProcedure isBetween(int from, int to)
          Constructs a function that returns from<=a && a<=to.
static cern.colt.function.IntProcedure isEqual(int b)
          Constructs a function that returns a == b.
static cern.colt.function.IntProcedure isGreater(int b)
          Constructs a function that returns a > b.
static cern.colt.function.IntProcedure isLess(int b)
          Constructs a function that returns a < b.
static cern.colt.function.IntFunction max(int b)
          Constructs a function that returns Math.max(a,b).
static cern.colt.function.IntFunction min(int b)
          Constructs a function that returns Math.min(a,b).
static cern.colt.function.IntFunction minus(int b)
          Constructs a function that returns a - b.
static cern.colt.function.IntFunction mod(int b)
          Constructs a function that returns a % b.
static cern.colt.function.IntFunction mult(int b)
          Constructs a function that returns a * b.
static cern.colt.function.IntFunction or(int b)
          Constructs a function that returns a | b.
static cern.colt.function.IntFunction plus(int b)
          Constructs a function that returns a + b.
static cern.colt.function.IntFunction pow(int b)
          Constructs a function that returns (int) Math.pow(a,b).
static cern.colt.function.IntFunction random()
          Constructs a function that returns a 32 bit uniformly distributed random number in the closed interval [Integer.MIN_VALUE,Integer.MAX_VALUE] (including Integer.MIN_VALUE and Integer.MAX_VALUE).
static cern.colt.function.IntFunction shiftLeft(int b)
          Constructs a function that returns a << b.
static cern.colt.function.IntFunction shiftRightSigned(int b)
          Constructs a function that returns a >> b.
static cern.colt.function.IntFunction shiftRightUnsigned(int b)
          Constructs a function that returns a >>> b.
static cern.colt.function.IntIntFunction swapArgs(cern.colt.function.IntIntFunction function)
          Constructs a function that returns function.apply(b,a), i.e.
static cern.colt.function.IntFunction xor(int b)
          Constructs a function that returns a | b.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

intFunctions

public static final IntFunctions intFunctions
Little trick to allow for "aliasing", that is, renaming this class. Writing code like

IntFunctions.chain(IntFunctions.plus,IntFunctions.mult(3),IntFunctions.chain(IntFunctions.square,IntFunctions.div(2)));

is a bit awkward, to say the least. Using the aliasing you can instead write

IntFunctions F = IntFunctions.intFunctions;
F.chain(F.plus,F.mult(3),F.chain(F.square,F.div(2)));


abs

public static final cern.colt.function.IntFunction abs
Function that returns Math.abs(a) == (a < 0) ? -a : a.


dec

public static final cern.colt.function.IntFunction dec
Function that returns a--.


factorial

public static final cern.colt.function.IntFunction factorial
Function that returns (int) Arithmetic.factorial(a).


identity

public static final cern.colt.function.IntFunction identity
Function that returns its argument.


inc

public static final cern.colt.function.IntFunction inc
Function that returns a++.


neg

public static final cern.colt.function.IntFunction neg
Function that returns -a.


not

public static final cern.colt.function.IntFunction not
Function that returns ~a.


sign

public static final cern.colt.function.IntFunction sign
Function that returns a < 0 ? -1 : a > 0 ? 1 : 0.


square

public static final cern.colt.function.IntFunction square
Function that returns a * a.


and

public static final cern.colt.function.IntIntFunction and
Function that returns a & b.


compare

public static final cern.colt.function.IntIntFunction compare
Function that returns a < b ? -1 : a > b ? 1 : 0.


div

public static final cern.colt.function.IntIntFunction div
Function that returns a / b.


equals

public static final cern.colt.function.IntIntFunction equals
Function that returns a == b ? 1 : 0.


isEqual

public static final cern.colt.function.IntIntProcedure isEqual
Function that returns a == b.


isLess

public static final cern.colt.function.IntIntProcedure isLess
Function that returns a < b.


isGreater

public static final cern.colt.function.IntIntProcedure isGreater
Function that returns a > b.


max

public static final cern.colt.function.IntIntFunction max
Function that returns Math.max(a,b).


min

public static final cern.colt.function.IntIntFunction min
Function that returns Math.min(a,b).


minus

public static final cern.colt.function.IntIntFunction minus
Function that returns a - b.


mod

public static final cern.colt.function.IntIntFunction mod
Function that returns a % b.


mult

public static final cern.colt.function.IntIntFunction mult
Function that returns a * b.


or

public static final cern.colt.function.IntIntFunction or
Function that returns a | b.


plus

public static final cern.colt.function.IntIntFunction plus
Function that returns a + b.


pow

public static final cern.colt.function.IntIntFunction pow
Function that returns (int) Math.pow(a,b).


shiftLeft

public static final cern.colt.function.IntIntFunction shiftLeft
Function that returns a << b.


shiftRightSigned

public static final cern.colt.function.IntIntFunction shiftRightSigned
Function that returns a >> b.


shiftRightUnsigned

public static final cern.colt.function.IntIntFunction shiftRightUnsigned
Function that returns a >>> b.


xor

public static final cern.colt.function.IntIntFunction xor
Function that returns a ^ b.

Constructor Detail

IntFunctions

protected IntFunctions()
Makes this class non instantiable, but still let's others inherit from it.

Method Detail

and

public static cern.colt.function.IntFunction and(int b)
Constructs a function that returns a & b. a is a variable, b is fixed.


between

public static cern.colt.function.IntFunction between(int from,
                                                     int to)
Constructs a function that returns (from<=a && a<=to) ? 1 : 0. a is a variable, from and to are fixed.


bindArg1

public static cern.colt.function.IntFunction bindArg1(cern.colt.function.IntIntFunction function,
                                                      int c)
Constructs a unary function from a binary function with the first operand (argument) fixed to the given constant c. The second operand is variable (free).

Parameters:
function - a binary function taking operands in the form function.apply(c,var).
Returns:
the unary function function(c,var).

bindArg2

public static cern.colt.function.IntFunction bindArg2(cern.colt.function.IntIntFunction function,
                                                      int c)
Constructs a unary function from a binary function with the second operand (argument) fixed to the given constant c. The first operand is variable (free).

Parameters:
function - a binary function taking operands in the form function.apply(var,c).
Returns:
the unary function function(var,c).

chain

public static cern.colt.function.IntFunction chain(cern.colt.function.IntFunction g,
                                                   cern.colt.function.IntFunction h)
Constructs the function g( h(a) ).

Parameters:
g - a unary function.
h - a unary function.
Returns:
the unary function g( h(a) ).

chain

public static cern.colt.function.IntIntFunction chain(cern.colt.function.IntFunction g,
                                                      cern.colt.function.IntIntFunction h)
Constructs the function g( h(a,b) ).

Parameters:
g - a unary function.
h - a binary function.
Returns:
the unary function g( h(a,b) ).

chain

public static cern.colt.function.IntIntFunction chain(cern.colt.function.IntIntFunction f,
                                                      cern.colt.function.IntFunction g,
                                                      cern.colt.function.IntFunction h)
Constructs the function f( g(a), h(b) ).

Parameters:
f - a binary function.
g - a unary function.
h - a unary function.
Returns:
the binary function f( g(a), h(b) ).

compare

public static cern.colt.function.IntFunction compare(int b)
Constructs a function that returns a < b ? -1 : a > b ? 1 : 0. a is a variable, b is fixed.


constant

public static cern.colt.function.IntFunction constant(int c)
Constructs a function that returns the constant c.


div

public static cern.colt.function.IntFunction div(int b)
Constructs a function that returns a / b. a is a variable, b is fixed.


equals

public static cern.colt.function.IntFunction equals(int b)
Constructs a function that returns a == b ? 1 : 0. a is a variable, b is fixed.


isBetween

public static cern.colt.function.IntProcedure isBetween(int from,
                                                        int to)
Constructs a function that returns from<=a && a<=to. a is a variable, from and to are fixed.


isEqual

public static cern.colt.function.IntProcedure isEqual(int b)
Constructs a function that returns a == b. a is a variable, b is fixed.


isGreater

public static cern.colt.function.IntProcedure isGreater(int b)
Constructs a function that returns a > b. a is a variable, b is fixed.


isLess

public static cern.colt.function.IntProcedure isLess(int b)
Constructs a function that returns a < b. a is a variable, b is fixed.


max

public static cern.colt.function.IntFunction max(int b)
Constructs a function that returns Math.max(a,b). a is a variable, b is fixed.


min

public static cern.colt.function.IntFunction min(int b)
Constructs a function that returns Math.min(a,b). a is a variable, b is fixed.


minus

public static cern.colt.function.IntFunction minus(int b)
Constructs a function that returns a - b. a is a variable, b is fixed.


mod

public static cern.colt.function.IntFunction mod(int b)
Constructs a function that returns a % b. a is a variable, b is fixed.


mult

public static cern.colt.function.IntFunction mult(int b)
Constructs a function that returns a * b. a is a variable, b is fixed.


or

public static cern.colt.function.IntFunction or(int b)
Constructs a function that returns a | b. a is a variable, b is fixed.


plus

public static cern.colt.function.IntFunction plus(int b)
Constructs a function that returns a + b. a is a variable, b is fixed.


pow

public static cern.colt.function.IntFunction pow(int b)
Constructs a function that returns (int) Math.pow(a,b). a is a variable, b is fixed.


random

public static cern.colt.function.IntFunction random()
Constructs a function that returns a 32 bit uniformly distributed random number in the closed interval [Integer.MIN_VALUE,Integer.MAX_VALUE] (including Integer.MIN_VALUE and Integer.MAX_VALUE). Currently the engine is MersenneTwister and is seeded with the current time.

Note that any random engine derived from RandomEngine and any random distribution derived from AbstractDistribution are function objects, because they implement the proper interfaces. Thus, if you are not happy with the default, just pass your favourite random generator to function evaluating methods.


shiftLeft

public static cern.colt.function.IntFunction shiftLeft(int b)
Constructs a function that returns a << b. a is a variable, b is fixed.


shiftRightSigned

public static cern.colt.function.IntFunction shiftRightSigned(int b)
Constructs a function that returns a >> b. a is a variable, b is fixed.


shiftRightUnsigned

public static cern.colt.function.IntFunction shiftRightUnsigned(int b)
Constructs a function that returns a >>> b. a is a variable, b is fixed.


swapArgs

public static cern.colt.function.IntIntFunction swapArgs(cern.colt.function.IntIntFunction function)
Constructs a function that returns function.apply(b,a), i.e. applies the function with the first operand as second operand and the second operand as first operand.

Parameters:
function - a function taking operands in the form function.apply(a,b).
Returns:
the binary function function(b,a).

xor

public static cern.colt.function.IntFunction xor(int b)
Constructs a function that returns a | b. a is a variable, b is fixed.