org.jaitools.jiffle.runtime
Class JiffleFunctions

java.lang.Object
  extended by org.jaitools.jiffle.runtime.JiffleFunctions

public class JiffleFunctions
extends java.lang.Object

Provides functions for Jiffle runtime objects. An instance of this class is used as a field in AbstractJiffleRuntime.

Since:
0.1
Version:
$Id: JiffleFunctions.java 1653 2011-06-16 10:23:02Z michael.bedward $
Author:
Michael Bedward

Constructor Summary
JiffleFunctions()
           
 
Method Summary
 double AND(double x, double y)
          Tests if both x and y are non-zero.
 java.util.List concatDL(double x, java.util.List list)
          Creates a new list by concatenating {2code x} and list.
 java.util.List concatLD(java.util.List list, double x)
          Creates a new list by concatenating list and {2code x}.
 java.util.List concatLL(java.util.List list1, java.util.List list2)
          Creates a new list by concatenating two existing lists.
 double degToRad(double x)
          Converts an angle in degrees to radians.
 double EQ(double x, double y)
          Tests if x is equal to y.
 double GE(double x, double y)
          Tests if x is greater than or equal to y.
 double GT(double x, double y)
          Tests if x is greater than y.
 double isinf(double x)
          Tests if x is infinite (equal to Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY).
 double isnan(double x)
          Tests if x is equal to Double.NaN.
 double isnull(double x)
          Tests if x is null.
 double LE(double x, double y)
          Tests if x is less than or equal to y.
 double log2Arg(double x, double b)
          Gets the log of x to base b.
 double LT(double x, double y)
          Tests if x is less than y.
 double max(java.util.List values)
          Gets the maximum of the input values.
 double mean(java.util.List values)
          Gets the mean of the input values.
 double median(java.util.List values)
          Gets the median of the input values.
 double min(java.util.List values)
          Gets the minimum of the input values.
 double mode(java.util.List values)
          Gets the mode of the input values.
 double NE(double x, double y)
          Tests if x is not equal to y.
 double NOT(double x)
          Treats x as true if non-zero, or false if zero and then returns the logical complement.
 double OR(double x, double y)
          Tests if either x or y is non-zero.
 double radToDeg(double x)
          Converts an angle in radians to degrees.
 double rand(double x)
          Gets a random value between 0 (inclusive) and x (exclusive).
 double randInt(double x)
          Gets a random integer value (actually a truncated double) between 0 (inclusive) and floor(x) (exclusive).
 double range(java.util.List values)
          Gets the range of the input values.
 double round2Arg(double x, double prec)
          Rounds the input value to the given precision.
 double sdev(java.util.List values)
          Gets the sample standard deviation of the input values.
 java.lang.Integer sign(double x)
          Return the sign of x as an integer.
 double sum(java.util.List values)
          Gets the sum of the input values.
 double variance(java.util.List values)
          Gets the sample variance of the input values.
 double XOR(double x, double y)
          Tests if just one of x or y is non-zero.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JiffleFunctions

public JiffleFunctions()
Method Detail

degToRad

public double degToRad(double x)
Converts an angle in degrees to radians.

Parameters:
x - input angle in degrees
Returns:
angle in radians

sign

public java.lang.Integer sign(double x)
Return the sign of x as an integer. This method is used by Jiffle to implement its various if functions.

Parameters:
x - test value
Returns:
-1 if x is negative; 0 if x is 0; 1 if x is positive; or null if x is NaN

isinf

public double isinf(double x)
Tests if x is infinite (equal to Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY).

Parameters:
x - test value
Returns:
1 if x is infinite; 0 if finite; or Double.Nan if x is Double.Nan

isnan

public double isnan(double x)
Tests if x is equal to Double.NaN.

Parameters:
x - test value
Returns:
1 if x is NaN; 0 otherwise

isnull

public double isnull(double x)
Tests if x is null. This is the same as isnan(double).

Parameters:
x - the test value
Returns:
1 if x is null; 0 otherwise

log2Arg

public double log2Arg(double x,
                      double b)
Gets the log of x to base b.

Parameters:
x - the value
b - the base
Returns:
log to base b

max

public double max(java.util.List values)
Gets the maximum of the input values. Double.Nan (null) values are ignored.

Parameters:
values - the input values
Returns:
the maximum value

mean

public double mean(java.util.List values)
Gets the mean of the input values. Double.Nan (null) values are ignored.

Parameters:
values - the input values
Returns:
the mean value

median

public double median(java.util.List values)
Gets the median of the input values. Double.Nan (null) values are ignored.

Parameters:
values - the input values
Returns:
the median value

min

public double min(java.util.List values)
Gets the minimum of the input values. Double.Nan (null) values are ignored.

Parameters:
values - the input values
Returns:
the minimum value

mode

public double mode(java.util.List values)
Gets the mode of the input values. Double.Nan (null) values are ignored.

Parameters:
values - the input values
Returns:
the modal value

radToDeg

public double radToDeg(double x)
Converts an angle in radians to degrees.

Parameters:
x - input angle in radians
Returns:
angle in degrees

rand

public double rand(double x)
Gets a random value between 0 (inclusive) and x (exclusive).

Parameters:
x - upper limit
Returns:
the random value

randInt

public double randInt(double x)
Gets a random integer value (actually a truncated double) between 0 (inclusive) and floor(x) (exclusive).

Parameters:
x - upper limit
Returns:
the random value

range

public double range(java.util.List values)
Gets the range of the input values. Double.Nan (null) values are ignored.

Parameters:
values - the input values
Returns:
the range of the input values

round2Arg

public double round2Arg(double x,
                        double prec)
Rounds the input value to the given precision.

Parameters:
x - the input value
prec - the desired precision
Returns:
the rounded value

sdev

public double sdev(java.util.List values)
Gets the sample standard deviation of the input values. Double.Nan (null) values are ignored.

Parameters:
values - the input values
Returns:
the standard deviation of the input values

sum

public double sum(java.util.List values)
Gets the sum of the input values. Double.Nan (null) values are ignored.

Parameters:
values - the input values
Returns:
the sum of the input values

variance

public double variance(java.util.List values)
Gets the sample variance of the input values. Double.Nan (null) values are ignored.

Parameters:
values - the input values
Returns:
the variance of the input values

OR

public double OR(double x,
                 double y)
Tests if either x or y is non-zero.

Parameters:
x - x value
y - y value
Returns:
1 if either x or y is non-zero; 0 if this is not the case; or Double.Nan if either x or y is Double.Nan

AND

public double AND(double x,
                  double y)
Tests if both x and y are non-zero.

Parameters:
x - x value
y - y value
Returns:
1 if both x and y are non-zero; 0 if this is not the case; or Double.Nan if either x or y is Double.Nan

XOR

public double XOR(double x,
                  double y)
Tests if just one of x or y is non-zero.

Parameters:
x - x value
y - y value
Returns:
1 if just one of x or y is non-zero; 0 if this is not the case; or Double.Nan if either x or y is Double.Nan

GT

public double GT(double x,
                 double y)
Tests if x is greater than y.

Parameters:
x - x value
y - y value
Returns:
1 if x is greater than y; 0 if this is not the case; or Double.Nan if either x or y is Double.Nan

GE

public double GE(double x,
                 double y)
Tests if x is greater than or equal to y.

Parameters:
x - x value
y - y value
Returns:
1 if x is greater than or equal to y; 0 if this is not the case; or Double.Nan if either x or y is Double.Nan

LT

public double LT(double x,
                 double y)
Tests if x is less than y.

Parameters:
x - x value
y - y value
Returns:
1 if x is less than y; 0 if this is not the case; or Double.Nan if either x or y is Double.Nan

LE

public double LE(double x,
                 double y)
Tests if x is less than or equal to y.

Parameters:
x - x value
y - y value
Returns:
1 if x is less than or equal to y; 0 if this is not the case; or Double.Nan if either x or y is Double.Nan

EQ

public double EQ(double x,
                 double y)
Tests if x is equal to y.

Parameters:
x - x value
y - y value
Returns:
1 if x is equal to y; 0 if this is not the case; or Double.Nan if either x or y is Double.Nan

NE

public double NE(double x,
                 double y)
Tests if x is not equal to y.

Parameters:
x - x value
y - y value
Returns:
1 if x is not equal to y; 0 if this is not the case; or Double.Nan if either x or y is Double.Nan

NOT

public double NOT(double x)
Treats x as true if non-zero, or false if zero and then returns the logical complement.

Parameters:
x - the test value
Returns:
1 if x is zero; 0 if x is non-zero; or Double.Nan if x is Double.Nan

concatDL

public java.util.List concatDL(double x,
                               java.util.List list)
Creates a new list by concatenating {2code x} and list.

Parameters:
x - the value
list - the list
Returns:
a new list

concatLD

public java.util.List concatLD(java.util.List list,
                               double x)
Creates a new list by concatenating list and {2code x}.

Parameters:
list - the list
x - the value
Returns:
a new list

concatLL

public java.util.List concatLL(java.util.List list1,
                               java.util.List list2)
Creates a new list by concatenating two existing lists.

Parameters:
list1 - the first list
list2 - the second list
Returns:
a new list


Copyright © 2011. All Rights Reserved.