Documentation of 'cern.jet.math.tlong.LongFunctions' Java class
LongFunctions
cern.jet.math.tlong

Class LongFunctions



  • public class LongFunctions
    extends java.lang.Object
    Long Function objects to be passed to generic methods. Same as DoubleFunctions except operating on longs.

    For aliasing see longFunctions.

    • Field Detail

      • longFunctions

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

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

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

        LongFunctions F = LongFunctions.longFunctions;
        F.chain(F.plus,F.mult(3),F.chain(F.square,F.div(2)));

      • abs

        public static final LongFunction abs
        Function that returns Math.abs(a) == (a < 0) ? -a : a.
      • dec

        public static final LongFunction dec
        Function that returns a--.
      • factorial

        public static final LongFunction factorial
        Function that returns (long) Arithmetic.factorial(a).
      • identity

        public static final LongFunction identity
        Function that returns its argument.
      • inc

        public static final LongFunction inc
        Function that returns a++.
      • neg

        public static final LongFunction neg
        Function that returns -a.
      • not

        public static final LongFunction not
        Function that returns ~a.
      • sign

        public static final LongFunction sign
        Function that returns a < 0 ? -1 : a > 0 ? 1 : 0.
      • square

        public static final LongFunction square
        Function that returns a * a.
      • compare

        public static final LongLongFunction compare
        Function that returns a < b ? -1 : a > b ? 1 : 0.
      • divNeg

        public static final LongLongFunction divNeg
        Function that returns -(a / b).
      • equals

        public static final LongLongFunction equals
        Function that returns a == b ? 1 : 0.
      • isEqual

        public static final LongLongProcedure isEqual
        Function that returns a == b.
      • isGreater

        public static final LongLongProcedure isGreater
        Function that returns a > b.
      • max

        public static final LongLongFunction max
        Function that returns Math.max(a,b).
      • min

        public static final LongLongFunction min
        Function that returns Math.min(a,b).
      • minus

        public static final LongLongFunction minus
        Function that returns a - b.
      • multNeg

        public static final LongLongFunction multNeg
        Function that returns -(a * b).
      • multSquare

        public static final LongLongFunction multSquare
        Function that returns a * b^2.
      • plusAbs

        public static final LongLongFunction plusAbs
        Function that returns Math.abs(a) + Math.abs(b).
      • pow

        public static final LongLongFunction pow
        Function that returns (long) Math.pow(a,b).
      • shiftLeft

        public static final LongLongFunction shiftLeft
        Function that returns a << b.
      • shiftRightSigned

        public static final LongLongFunction shiftRightSigned
        Function that returns a >> b.
      • shiftRightUnsigned

        public static final LongLongFunction shiftRightUnsigned
        Function that returns a >>> b.
    • Method Detail

      • and

        public static LongFunction and(long b)
        Constructs a function that returns a & b. a is a variable, b is fixed.
      • between

        public static LongFunction between(long from,
                                           long to)
        Constructs a function that returns (from<=a && a<=to) ? 1 : 0. a is a variable, from and to are fixed.
      • bindArg1

        public static LongFunction bindArg1(LongLongFunction function,
                                            long 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 LongFunction bindArg2(LongLongFunction function,
                                            long 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 LongFunction chain(LongFunction g,
                                         LongFunction h)
        Constructs the function g( h(a) ).
        Parameters:
        g - a unary function.
        h - a unary function.
        Returns:
        the unary function g( h(a) ).
      • compare

        public static LongFunction compare(long b)
        Constructs a function that returns a < b ? -1 : a > b ? 1 : 0. a is a variable, b is fixed.
      • constant

        public static LongFunction constant(long c)
        Constructs a function that returns the constant c.
      • div

        public static LongFunction div(long b)
        Constructs a function that returns a / b. a is a variable, b is fixed.
      • equals

        public static LongFunction equals(long b)
        Constructs a function that returns a == b ? 1 : 0. a is a variable, b is fixed.
      • isBetween

        public static LongProcedure isBetween(long from,
                                              long to)
        Constructs a function that returns from<=a && a<=to. a is a variable, from and to are fixed.
      • isEqual

        public static LongProcedure isEqual(long b)
        Constructs a function that returns a == b. a is a variable, b is fixed.
      • isGreater

        public static LongProcedure isGreater(long b)
        Constructs a function that returns a > b. a is a variable, b is fixed.
      • isLess

        public static LongProcedure isLess(long b)
        Constructs a function that returns a < b. a is a variable, b is fixed.
      • max

        public static LongFunction max(long b)
        Constructs a function that returns Math.max(a,b). a is a variable, b is fixed.
      • min

        public static LongFunction min(long b)
        Constructs a function that returns Math.min(a,b). a is a variable, b is fixed.
      • minus

        public static LongFunction minus(long b)
        Constructs a function that returns a - b. a is a variable, b is fixed.
      • minusMult

        public static LongLongFunction minusMult(long constant)
        Constructs a function that returns a - b*constant. a and b are variables, constant is fixed.
      • mod

        public static LongFunction mod(long b)
        Constructs a function that returns a % b. a is a variable, b is fixed.
      • mult

        public static LongFunction mult(long b)
        Constructs a function that returns a * b. a is a variable, b is fixed.
      • or

        public static LongFunction or(long b)
        Constructs a function that returns a | b. a is a variable, b is fixed.
      • plus

        public static LongFunction plus(long b)
        Constructs a function that returns a + b. a is a variable, b is fixed.
      • multSecond

        public static LongLongFunction multSecond(long constant)
        Constructs a function that returns b*constant.
      • pow

        public static LongFunction pow(long b)
        Constructs a function that returns (long) Math.pow(a,b). a is a variable, b is fixed.
      • plusMultSecond

        public static LongLongFunction plusMultSecond(long constant)
        Constructs a function that returns a + b*constant. a and b are variables, constant is fixed.
      • plusMultFirst

        public static LongLongFunction plusMultFirst(long constant)
        Constructs a function that returns a * constant + b. a and b are variables, constant is fixed.
      • random

        public static LongFunction random()
        Constructs a function that returns a 32 bit uniformly distributed random number in the closed longerval [Long.MIN_VALUE,Long.MAX_VALUE] (including Long.MIN_VALUE and Long.MAX_VALUE). Currently the engine is DoubleMersenneTwister and is seeded with the current time.

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

      • shiftLeft

        public static LongFunction shiftLeft(long b)
        Constructs a function that returns a << b. a is a variable, b is fixed.
      • shiftRightSigned

        public static LongFunction shiftRightSigned(long b)
        Constructs a function that returns a >> b. a is a variable, b is fixed.
      • shiftRightUnsigned

        public static LongFunction shiftRightUnsigned(long b)
        Constructs a function that returns a >>> b. a is a variable, b is fixed.
      • swapArgs

        public static LongLongFunction swapArgs(LongLongFunction 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 LongFunction xor(long b)
        Constructs a function that returns a | b. a is a variable, b is fixed.

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.