Class IntFunctions
java.lang.Object
cern.jet.math.IntFunctions
Integer Function objects to be passed to generic methods.
Same as
Functions except operating on integers.
For aliasing see intFunctions.
- Version:
- 1.0, 09/24/99
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final IntFunctionFunction that returns Math.abs(a) == (a invalid input: '<' 0) ? -a : a.static final IntIntFunctionFunction that returns a invalid input: '&' b.static final IntIntFunctionFunction that returns a invalid input: '<' b ? -1 : a > b ? 1 : 0.static final IntFunctionFunction that returns a--.static final IntIntFunctionFunction that returns a / b.static final IntIntFunctionFunction that returns a == b ? 1 : 0.static final IntFunctionFunction that returns (int) Arithmetic.factorial(a).static final IntFunctionFunction that returns its argument.static final IntFunctionFunction that returns a++.static final IntFunctionsLittle trick to allow for "aliasing", that is, renaming this class.static final IntIntProcedureFunction that returns a == b.static final IntIntProcedureFunction that returns a > b.static final IntIntProcedureFunction that returns a invalid input: '<' b.static final IntIntFunctionFunction that returns Math.max(a,b).static final IntIntFunctionFunction that returns Math.min(a,b).static final IntIntFunctionFunction that returns a - b.static final IntIntFunctionFunction that returns a % b.static final IntIntFunctionFunction that returns a * b.static final IntFunctionFunction that returns -a.static final IntFunctionFunction that returns ~a.static final IntIntFunctionFunction that returns a | b.static final IntIntFunctionFunction that returns a + b.static final IntIntFunctionFunction that returns (int) Math.pow(a,b).static final IntIntFunctionFunction that returns a invalid input: '<'invalid input: '<' b.static final IntIntFunctionFunction that returns a >> b.static final IntIntFunctionFunction that returns a >>> b.static final IntFunctionFunction that returns a invalid input: '<' 0 ? -1 : a > 0 ? 1 : 0.static final IntFunctionFunction that returns a * a.static final IntIntFunctionFunction that returns a ^ b. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMakes this class non instantiable, but still let's others inherit from it. -
Method Summary
Modifier and TypeMethodDescriptionstatic IntFunctionand(int b) Constructs a function that returns a invalid input: '&' b.static IntFunctionbetween(int from, int to) Constructs a function that returns (frominvalid input: '<'=a invalid input: '&'invalid input: '&' ainvalid input: '<'=to) ? 1 : 0.static IntFunctionbindArg1(IntIntFunction function, int c) Constructs a unary function from a binary function with the first operand (argument) fixed to the given constant c.static IntFunctionbindArg2(IntIntFunction function, int c) Constructs a unary function from a binary function with the second operand (argument) fixed to the given constant c.static IntFunctionchain(IntFunction g, IntFunction h) Constructs the function g( h(a) ).static IntIntFunctionchain(IntFunction g, IntIntFunction h) Constructs the function g( h(a,b) ).static IntIntFunctionchain(IntIntFunction f, IntFunction g, IntFunction h) Constructs the function f( g(a), h(b) ).static IntFunctioncompare(int b) Constructs a function that returns a invalid input: '<' b ? -1 : a > b ? 1 : 0.static IntFunctionconstant(int c) Constructs a function that returns the constant c.static IntFunctiondiv(int b) Constructs a function that returns a / b.static IntFunctionequals(int b) Constructs a function that returns a == b ? 1 : 0.static IntProcedureisBetween(int from, int to) Constructs a function that returns frominvalid input: '<'=a invalid input: '&'invalid input: '&' ainvalid input: '<'=to.static IntProcedureisEqual(int b) Constructs a function that returns a == b.static IntProcedureisGreater(int b) Constructs a function that returns a > b.static IntProcedureisLess(int b) Constructs a function that returns a invalid input: '<' b.static IntFunctionmax(int b) Constructs a function that returns Math.max(a,b).static IntFunctionmin(int b) Constructs a function that returns Math.min(a,b).static IntFunctionminus(int b) Constructs a function that returns a - b.static IntFunctionmod(int b) Constructs a function that returns a % b.static IntFunctionmult(int b) Constructs a function that returns a * b.static IntFunctionor(int b) Constructs a function that returns a | b.static IntFunctionplus(int b) Constructs a function that returns a + b.static IntFunctionpow(int b) Constructs a function that returns (int) Math.pow(a,b).static IntFunctionrandom()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 IntFunctionshiftLeft(int b) Constructs a function that returns a invalid input: '<'invalid input: '<' b.static IntFunctionshiftRightSigned(int b) Constructs a function that returns a >> b.static IntFunctionshiftRightUnsigned(int b) Constructs a function that returns a >>> b.static IntIntFunctionswapArgs(IntIntFunction function) Constructs a function that returns function.apply(b,a), i.e.static IntFunctionxor(int b) Constructs a function that returns a | b.
-
Field Details
-
intFunctions
Little trick to allow for "aliasing", that is, renaming this class. Writing code likeIntFunctions.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
Function that returns Math.abs(a) == (a invalid input: '<' 0) ? -a : a. -
dec
Function that returns a--. -
factorial
Function that returns (int) Arithmetic.factorial(a). -
identity
Function that returns its argument. -
inc
Function that returns a++. -
neg
Function that returns -a. -
not
Function that returns ~a. -
sign
Function that returns a invalid input: '<' 0 ? -1 : a > 0 ? 1 : 0. -
square
Function that returns a * a. -
and
Function that returns a invalid input: '&' b. -
compare
Function that returns a invalid input: '<' b ? -1 : a > b ? 1 : 0. -
div
Function that returns a / b. -
equals
Function that returns a == b ? 1 : 0. -
isEqual
Function that returns a == b. -
isLess
Function that returns a invalid input: '<' b. -
isGreater
Function that returns a > b. -
max
Function that returns Math.max(a,b). -
min
Function that returns Math.min(a,b). -
minus
Function that returns a - b. -
mod
Function that returns a % b. -
mult
Function that returns a * b. -
or
Function that returns a | b. -
plus
Function that returns a + b. -
pow
Function that returns (int) Math.pow(a,b). -
shiftLeft
Function that returns a invalid input: '<'invalid input: '<' b. -
shiftRightSigned
Function that returns a >> b. -
shiftRightUnsigned
Function that returns a >>> b. -
xor
Function that returns a ^ b.
-
-
Constructor Details
-
IntFunctions
protected IntFunctions()Makes this class non instantiable, but still let's others inherit from it.
-
-
Method Details
-
and
Constructs a function that returns a invalid input: '&' b. a is a variable, b is fixed. -
between
Constructs a function that returns (frominvalid input: '<'=a invalid input: '&'invalid input: '&' ainvalid input: '<'=to) ? 1 : 0. a is a variable, from and to are fixed. -
bindArg1
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
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
Constructs the function g( h(a) ).- Parameters:
g- a unary function.h- a unary function.- Returns:
- the unary function g( h(a) ).
-
chain
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
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
Constructs a function that returns a invalid input: '<' b ? -1 : a > b ? 1 : 0. a is a variable, b is fixed. -
constant
Constructs a function that returns the constant c. -
div
Constructs a function that returns a / b. a is a variable, b is fixed. -
equals
Constructs a function that returns a == b ? 1 : 0. a is a variable, b is fixed. -
isBetween
Constructs a function that returns frominvalid input: '<'=a invalid input: '&'invalid input: '&' ainvalid input: '<'=to. a is a variable, from and to are fixed. -
isEqual
Constructs a function that returns a == b. a is a variable, b is fixed. -
isGreater
Constructs a function that returns a > b. a is a variable, b is fixed. -
isLess
Constructs a function that returns a invalid input: '<' b. a is a variable, b is fixed. -
max
Constructs a function that returns Math.max(a,b). a is a variable, b is fixed. -
min
Constructs a function that returns Math.min(a,b). a is a variable, b is fixed. -
minus
Constructs a function that returns a - b. a is a variable, b is fixed. -
mod
Constructs a function that returns a % b. a is a variable, b is fixed. -
mult
Constructs a function that returns a * b. a is a variable, b is fixed. -
or
Constructs a function that returns a | b. a is a variable, b is fixed. -
plus
Constructs a function that returns a + b. a is a variable, b is fixed. -
pow
Constructs a function that returns (int) Math.pow(a,b). a is a variable, b is fixed. -
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 isMersenneTwisterand is seeded with the current time.Note that any random engine derived from
RandomEngineand any random distribution derived fromAbstractDistributionare 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
Constructs a function that returns a invalid input: '<'invalid input: '<' b. a is a variable, b is fixed. -
shiftRightSigned
Constructs a function that returns a >> b. a is a variable, b is fixed. -
shiftRightUnsigned
Constructs a function that returns a >>> b. a is a variable, b is fixed. -
swapArgs
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
Constructs a function that returns a | b. a is a variable, b is fixed.
-