edu.neu.ccs
Class F

java.lang.Object
  extended byedu.neu.ccs.F

public class F
extends Object

Class F is a collection of static methods that make it easy to create and manipulate functions of one argument, that is, objects that implement the interface Function.OneArg. Such function objects must have a method of the form:

public double evaluate(double x)

This class defines methods that make all functions of one argument in the following packages into objects:

In addition, the class defines methods to add, subtract, multiply, divide, and compose functions of one argument.

Finally, some additional useful methods are defined.

Class F cannot be instantiated.

In 2.5.0, made a slight change to the random function and removed the related functional method randomDouble.

Since:
2.5.0
Version:
2.5.0

Field Summary
static Function.OneArg abs
          The function x --> abs(x).
static Function.OneArg acos
          The function x --> acos(x).
static Function.OneArg acosdeg
          The function x --> acosdeg(x).
static Function.OneArg asin
          The function x --> asin(x).
static Function.OneArg asindeg
          The function x --> asindeg(x).
static Function.OneArg atan
          The function x --> atan(x).
static Function.OneArg atandeg
          The function x --> atandeg(x).
static Function.OneArg ceil
          The function x --> ceil(x).
static Function.OneArg cos
          The function x --> cos(x).
static Function.OneArg cosdeg
          The function x --> cosdeg(x).
static Function.OneArg exp
          The function x --> exp(x).
static Function.OneArg exp10
          The function x --> 10-to-the-power-x = exp(x * log(10)).
static Function.OneArg exp2
          The function x --> 2-to-the-power-x = exp(x * log(2)).
static Function.OneArg floor
          The function x --> floor(x).
static Function.OneArg identity
          The identity function x --> x.
static Function.OneArg log
          The function x --> log(x).
static Function.OneArg log10
          The function x --> log-base-10(x) = log(x) / log(10).
static Function.OneArg log2
          The function x --> log-base-2(x) = log(x) / log(2).
private static double logOf10
          The constant log(10).
private static double logOf2
          The constant log(2).
static Function.OneArg random
          The function x --> Math.random() * x.
static Function.OneArg rint
          The function x --> rint(x).
static Function.OneArg sin
          The function x --> sin(x).
static Function.OneArg sindeg
          The function x --> sindeg(x).
static Function.OneArg sqrt
          The function x --> sqrt(x).
static Function.OneArg tan
          The function x --> tan(x).
static Function.OneArg tandeg
          The function x --> tandeg(x).
static Function.OneArg toDegrees
          The function x --> toDegrees(x).
static Function.OneArg toRadians
          The function x --> toRadians(x).
 
Constructor Summary
private F()
           
 
Method Summary
static Function.OneArg add(Function.OneArg f, Function.OneArg g)
          The function to add functions f,g: f + g.
static Function.OneArg atan2(Function.OneArg f, Function.OneArg g)
          The function to compute the function atan2(f, g).
static Function.OneArg atan2deg(Function.OneArg f, Function.OneArg g)
          The function to compute the function atan2deg(f, g).
static Function.OneArg aToPowerX(double a)
          The function x --> a-to-the-power-x = Math.pow(a, x).
private static void checkNull(String method, Function.OneArg f)
          Check for null function arguments and throw a NullPointerException if necessary.
private static void checkNull(String method, Function.OneArg f, Function.OneArg g)
          Check for null function arguments and throw a NullPointerException if necessary.
static Function.OneArg compose(Function.OneArg f, Function.OneArg g)
          The function to compose functions f,g: x --> f(g(x)).
static Function.OneArg constant(double c)
          The constant function x --> c.
static Function.OneArg divide(Function.OneArg f, Function.OneArg g)
          The function to divide functions f,g: f / g.
static Function.OneArg linear(double a, double b)
          The linear function x --> a * x + b.
static Function.OneArg max(Function.OneArg f, Function.OneArg g)
          The function to compute the function max(f, g).
static Function.OneArg min(Function.OneArg f, Function.OneArg g)
          The function to compute the function min(f, g).
static Function.OneArg multiply(Function.OneArg f, Function.OneArg g)
          The function to multiply functions f,g: f * g.
static Function.OneArg pow(double a, Function.OneArg f)
          The function to compute the function a-to-the-power-f = Math.pow(a,f.evaluate(x)).
static Function.OneArg pow(Function.OneArg f, double a)
          The function to compute the function f-to-the-power-a = Math.pow(f.evaluate(x),a).
static Function.OneArg pow(Function.OneArg f, Function.OneArg g)
          The function to compute the function f-to-the-power-g = Math.pow(f.evaluate(x),g.evaluate(x)).
static Function.OneArg power(Function.OneArg f, int n)
          The function to compute the function f-to-the-power-n = MathUtilities.power(f.evaluate(x),n).
static Function.OneArg scale(double a)
          The scale function x --> a * x.
static Function.OneArg subtract(Function.OneArg f, Function.OneArg g)
          The function to subtract functions f,g: f - g.
static Function.OneArg translate(double b)
          The translate function x --> x + b.
static Function.OneArg xToPowerA(double a)
          The function x --> x-to-the-power-a = Math.pow(x, a).
static Function.OneArg xToPowerN(int n)
          The function x --> x-to-the-power-n = MathUtilities.power(x,n).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logOf2

private static final double logOf2
The constant log(2).


logOf10

private static final double logOf10
The constant log(10).


identity

public static final Function.OneArg identity
The identity function x --> x.


abs

public static final Function.OneArg abs
The function x --> abs(x).


ceil

public static final Function.OneArg ceil
The function x --> ceil(x).


floor

public static final Function.OneArg floor
The function x --> floor(x).


rint

public static final Function.OneArg rint
The function x --> rint(x).


sin

public static final Function.OneArg sin
The function x --> sin(x).


cos

public static final Function.OneArg cos
The function x --> cos(x).


tan

public static final Function.OneArg tan
The function x --> tan(x).


asin

public static final Function.OneArg asin
The function x --> asin(x).


acos

public static final Function.OneArg acos
The function x --> acos(x).


atan

public static final Function.OneArg atan
The function x --> atan(x).


sindeg

public static final Function.OneArg sindeg
The function x --> sindeg(x).


cosdeg

public static final Function.OneArg cosdeg
The function x --> cosdeg(x).


tandeg

public static final Function.OneArg tandeg
The function x --> tandeg(x).


asindeg

public static final Function.OneArg asindeg
The function x --> asindeg(x).


acosdeg

public static final Function.OneArg acosdeg
The function x --> acosdeg(x).


atandeg

public static final Function.OneArg atandeg
The function x --> atandeg(x).


toDegrees

public static final Function.OneArg toDegrees
The function x --> toDegrees(x).


toRadians

public static final Function.OneArg toRadians
The function x --> toRadians(x).


exp

public static final Function.OneArg exp
The function x --> exp(x).


log

public static final Function.OneArg log
The function x --> log(x).


exp2

public static final Function.OneArg exp2
The function x --> 2-to-the-power-x = exp(x * log(2)).


log2

public static final Function.OneArg log2
The function x --> log-base-2(x) = log(x) / log(2).


exp10

public static final Function.OneArg exp10
The function x --> 10-to-the-power-x = exp(x * log(10)).


log10

public static final Function.OneArg log10
The function x --> log-base-10(x) = log(x) / log(10).


sqrt

public static final Function.OneArg sqrt
The function x --> sqrt(x).


random

public static final Function.OneArg random

The function x --> Math.random() * x.

In effect, returns a random number between 0 and x.

Constructor Detail

F

private F()
Method Detail

constant

public static Function.OneArg constant(double c)
The constant function x --> c.

Parameters:
c - the constant.

scale

public static Function.OneArg scale(double a)
The scale function x --> a * x.

Parameters:
a - the scale.

translate

public static Function.OneArg translate(double b)
The translate function x --> x + b.

Parameters:
b - the translate.

linear

public static Function.OneArg linear(double a,
                                     double b)
The linear function x --> a * x + b.

Parameters:
a - the scale.
b - the translate.

xToPowerN

public static Function.OneArg xToPowerN(int n)
The function x --> x-to-the-power-n = MathUtilities.power(x,n).


xToPowerA

public static Function.OneArg xToPowerA(double a)
The function x --> x-to-the-power-a = Math.pow(x, a).


aToPowerX

public static Function.OneArg aToPowerX(double a)
The function x --> a-to-the-power-x = Math.pow(a, x).


add

public static Function.OneArg add(Function.OneArg f,
                                  Function.OneArg g)
The function to add functions f,g: f + g.


subtract

public static Function.OneArg subtract(Function.OneArg f,
                                       Function.OneArg g)
The function to subtract functions f,g: f - g.


multiply

public static Function.OneArg multiply(Function.OneArg f,
                                       Function.OneArg g)
The function to multiply functions f,g: f * g.


divide

public static Function.OneArg divide(Function.OneArg f,
                                     Function.OneArg g)
The function to divide functions f,g: f / g.


compose

public static Function.OneArg compose(Function.OneArg f,
                                      Function.OneArg g)
The function to compose functions f,g: x --> f(g(x)).


min

public static Function.OneArg min(Function.OneArg f,
                                  Function.OneArg g)
The function to compute the function min(f, g).


max

public static Function.OneArg max(Function.OneArg f,
                                  Function.OneArg g)
The function to compute the function max(f, g).


power

public static Function.OneArg power(Function.OneArg f,
                                    int n)
The function to compute the function f-to-the-power-n = MathUtilities.power(f.evaluate(x),n).


pow

public static Function.OneArg pow(Function.OneArg f,
                                  double a)
The function to compute the function f-to-the-power-a = Math.pow(f.evaluate(x),a).


pow

public static Function.OneArg pow(double a,
                                  Function.OneArg f)
The function to compute the function a-to-the-power-f = Math.pow(a,f.evaluate(x)).


pow

public static Function.OneArg pow(Function.OneArg f,
                                  Function.OneArg g)
The function to compute the function f-to-the-power-g = Math.pow(f.evaluate(x),g.evaluate(x)).


atan2

public static Function.OneArg atan2(Function.OneArg f,
                                    Function.OneArg g)
The function to compute the function atan2(f, g).


atan2deg

public static Function.OneArg atan2deg(Function.OneArg f,
                                       Function.OneArg g)
The function to compute the function atan2deg(f, g).


checkNull

private static void checkNull(String method,
                              Function.OneArg f)
Check for null function arguments and throw a NullPointerException if necessary.

Parameters:
method - the string name of the method
f - the function argument

checkNull

private static void checkNull(String method,
                              Function.OneArg f,
                              Function.OneArg g)
Check for null function arguments and throw a NullPointerException if necessary.

Parameters:
method - the string name of the method
f - the first function argument
g - the second function argument