com.graphbuilder.math.FuncMap Class Reference

Inheritance diagram for com.graphbuilder.math.FuncMap:
Inheritance graph
[legend]
Collaboration diagram for com.graphbuilder.math.FuncMap:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 FuncMap ()
 FuncMap (boolean caseSensitive)
void loadDefaultFunctions ()
 Adds the mappings for many common functions.
Function getFunction (String funcName, int numParam)
 Returns a function based on the name and the specified number of parameters.
void setFunction (String funcName, Function f)
 Assigns the name to map to the specified function.
boolean isCaseSensitive ()
 Returns true if the case of the function names is considered.
String[] getFunctionNames ()
 Returns an array of exact length of the function names stored in this map.
Function[] getFunctions ()
 Returns an array of exact length of the functions stored in this map.
void remove (String funcName)
 Removes the function-name and the associated function from the map.

Private Attributes

String[] name = new String[50]
Function[] func = new Function[50]
int numFunc = 0
boolean caseSensitive = false

Detailed Description

FuncMap maps a name to a function. A FuncMap is used in the eval method of an Expression object. This class can be used as the default function-map. The loadDefaultFunctions() method can be used to take advantage of the many already implemented functions (see below).

During the evaluation of an expression, if a function is not supported then a RuntimeException is thrown.

Default functions:

No Parameters
  • e() Math.E
  • pi() Math.PI
  • rand() Math.random()
  • min() Double.MIN_VALUE
  • max() Double.MAX_VALUE
1 Parameter
  • sin(x) Math.sin(double)
  • cos(x) Math.cos(double)
  • tan(x) Math.tan(double)
  • asin(x) Math.asin(double)
  • acos(x) Math.acos(double)
  • atan(x) Math.atan(double)
  • asinh(x) 2 * ln(sqrt((x+1)/2) + sqrt((x-1)/2))
  • acosh(x) ln(x + sqrt(1 + x2))
  • atanh(x) (ln(1+x) - ln(1-x)) / 2
  • sinh(x) (ex - e-x)/2
  • cosh(x) (ex + e-x)/2
  • tanh(x) (ex - e-x)/(ex + e-x)
  • sqrt(x) Math.sqrt(double)
  • abs(x) Math.abs(double)
  • ceil(x) Math.ceil(double)
  • floor(x) Math.floor(double)
  • exp(x) ex
  • ln(x) logex
  • lg(x) log2x
  • log(x) log10x
  • sign(x) x > 0 = 1, x < 0 = -1, else 0
  • fact(n) n! = 1 * 2 * ... * (n - 1) * n
  • round(x) Math.round(double)
2 Parameters
  • log(x,y) logyx
  • combin(n, r) PascalsTriangle.nCr(n, r)
  • mod(x, y) x % y
  • pow(x, y) xy
n Parameters
  • min(x1,x2,...,xn)
  • max(x1,x2,...,xn)
  • sum(x1,x2,...,xn) x1 + x2 + ... + xn
  • avg(x1,x2,...,xn) (x1 + x2 + ... + xn) / n

Note: Case sensitivity can only be specified in the constructor (for consistency). When case sensitivity is false, the String.equalsIgnoreCase method is used. When case sensitivity is true, the String.equals method is used. The matching does not include the parenthesis. For example, when case sensitivity is false and the default functions have been loaded, then "RaNd", "rand", and "RAND" all map to the RandFunction(). By default, case sensitivity is false.

Definition at line 81 of file FuncMap.java.


Constructor & Destructor Documentation

com.graphbuilder.math.FuncMap.FuncMap (  ) 

Definition at line 88 of file FuncMap.java.

com.graphbuilder.math.FuncMap.FuncMap ( boolean  caseSensitive  ) 

Definition at line 90 of file FuncMap.java.


Member Function Documentation

Function com.graphbuilder.math.FuncMap.getFunction ( String  funcName,
int  numParam 
)

Returns a function based on the name and the specified number of parameters.

Exceptions:
RuntimeException If no supporting function can be found.

Definition at line 152 of file FuncMap.java.

References com.graphbuilder.math.FuncMap.caseSensitive, com.graphbuilder.math.FuncMap.func, com.graphbuilder.math.FuncMap.name, and com.graphbuilder.math.FuncMap.numFunc.

Referenced by com.graphbuilder.math.FuncNode.eval().

String [] com.graphbuilder.math.FuncMap.getFunctionNames (  ) 

Returns an array of exact length of the function names stored in this map.

Definition at line 208 of file FuncMap.java.

References com.graphbuilder.math.FuncMap.name, and com.graphbuilder.math.FuncMap.numFunc.

Referenced by edu.rice.cs.hpc.viewer.metric.ExtDerivedMetricDlg.createDialogArea().

Function [] com.graphbuilder.math.FuncMap.getFunctions (  ) 

Returns an array of exact length of the functions stored in this map.

The returned array corresponds to the order of the names returned by getFunctionNames.

Definition at line 221 of file FuncMap.java.

References com.graphbuilder.math.FuncMap.func, and com.graphbuilder.math.FuncMap.numFunc.

Referenced by edu.rice.cs.hpc.viewer.metric.ExtDerivedMetricDlg.createDialogArea(), and edu.rice.cs.hpc.data.experiment.metric.MetricVarMap.main().

boolean com.graphbuilder.math.FuncMap.isCaseSensitive (  ) 

Returns true if the case of the function names is considered.

Definition at line 201 of file FuncMap.java.

References com.graphbuilder.math.FuncMap.caseSensitive.

void com.graphbuilder.math.FuncMap.loadDefaultFunctions (  ) 
void com.graphbuilder.math.FuncMap.remove ( String  funcName  ) 

Removes the function-name and the associated function from the map.

Does nothing if the function-name is not found.

Definition at line 234 of file FuncMap.java.

References com.graphbuilder.math.FuncMap.caseSensitive, com.graphbuilder.math.FuncMap.func, com.graphbuilder.math.FuncMap.name, and com.graphbuilder.math.FuncMap.numFunc.

void com.graphbuilder.math.FuncMap.setFunction ( String  funcName,
Function  f 
)

Assigns the name to map to the specified function.

Exceptions:
IllegalArgumentException If any of the parameters are null.

Definition at line 166 of file FuncMap.java.

References com.graphbuilder.math.FuncMap.caseSensitive, com.graphbuilder.math.FuncMap.func, com.graphbuilder.math.FuncMap.name, and com.graphbuilder.math.FuncMap.numFunc.

Referenced by edu.rice.cs.hpc.data.experiment.metric.ExtFuncMap.init(), and com.graphbuilder.math.FuncMap.loadDefaultFunctions().


Member Data Documentation

String [] com.graphbuilder.math.FuncMap.name = new String[50] [private]

The documentation for this class was generated from the following file:

Generated on 5 May 2015 for HPCVIEWER by  doxygen 1.6.1