# Class FunctionCalculatorImpl

java.lang.Object
org.apfloat.calc.AbstractCalculatorImpl
org.apfloat.calc.FunctionCalculatorImpl

All Implemented Interfaces:
  `Serializable, CalculatorImpl`

Direct Known Subclasses:
  `ApfloatCalculatorImpl`

public abstract class FunctionCalculatorImpl extends AbstractCalculatorImpl
Calculator implementation with function support. Provides a mapping mechanism for functions.

Version:
  1.16.0
Author:
  Mikko Tommila
See Also:
  - Serialized Form

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `protected class`
  `FunctionCalculatorImpl.FixedFunction`
  Function taking a fixed number of arguments.
  `protected static interface`
  `FunctionCalculatorImpl.FixedFunctionHandler`
  Handler for FixedFunction.
  `protected static interface`
  `FunctionCalculatorImpl.Function`
  Arbitrary function.
  `protected static interface`
  `FunctionCalculatorImpl.Functions`
  Function implementations.

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `FunctionCalculatorImpl()`
  Default constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected FunctionCalculatorImpl.FixedFunction`
  `fixedFunction(String name, int minArguments, int maxArguments, FunctionCalculatorImpl.FixedFunctionHandler handler)`
  Factory method.
  `protected FunctionCalculatorImpl.FixedFunction`
  `fixedFunction(String name, int arguments, FunctionCalculatorImpl.FixedFunctionHandler handler)`
  Factory method.
  `Number`
  `function(String name, List<Number> arguments)`
  Arbitrary function.
  `protected abstract FunctionCalculatorImpl.Functions`
  `getFunctions(Number x)`
  Get the function implementations.
  `protected abstract Number`
  `promote(Number x)`
  Promote a number to a more specific class.
  `protected void`
  `setFunction(String name, FunctionCalculatorImpl.Function function)`
  Define a function.

  ### Methods inherited from class AbstractCalculatorImpl

  `add, divide, doubleFactorial, factorial, getFormat, getInputPrecision, getVariable, mod, multiply, negate, pow, setFormat, setInputPrecision, setVariable, subtract`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface CalculatorImpl

  `format, parseDecimal, parseInteger`

- ## Constructor Details

  - ### FunctionCalculatorImpl

    protected FunctionCalculatorImpl()
    Default constructor.

- ## Method Details

  - ### function

    public Number function(String name, List<Number> arguments) throws ParseException
    Description copied from interface: `CalculatorImpl`
    Arbitrary function.
    Parameters:
      `name` - Name of the function.
      `arguments` - Function arguments.
    Returns:
      Function value.
    Throws:
      `ParseException` - In case of invalid arguments.

  - ### fixedFunction

    protected FunctionCalculatorImpl.FixedFunction fixedFunction(String name, int arguments, FunctionCalculatorImpl.FixedFunctionHandler handler)
    Factory method.
    Parameters:
      `name` - The function's name.
      `arguments` - The number of arguments that the function takes.
      `handler` - The handler of the function.
    Returns:
      The function.

  - ### fixedFunction

    protected FunctionCalculatorImpl.FixedFunction fixedFunction(String name, int minArguments, int maxArguments, FunctionCalculatorImpl.FixedFunctionHandler handler)
    Factory method.
    Parameters:
      `name` - The function's name.
      `minArguments` - The minimum number of arguments that the function takes.
      `maxArguments` - The maximum number of arguments that the function takes.
      `handler` - The handler of the function.
    Returns:
      The function.

  - ### setFunction

    protected void setFunction(String name, FunctionCalculatorImpl.Function function)
    Define a function.
    Parameters:
      `name` - The function name.
      `function` - The function.

  - ### getFunctions

    protected abstract FunctionCalculatorImpl.Functions getFunctions(Number x)
    Get the function implementations.
    Parameters:
      `x` - The number to use as the function argument.
    Returns:
      The function implementations.

  - ### promote

    protected abstract Number promote(Number x)
    Promote a number to a more specific class.
    Parameters:
      `x` - The argument.
    Returns:
      The argument, possibly converted to a more specific subclass.