Package com.singularsys.jep.functions

# Class Power

java.lang.Object
com.singularsys.jep.functions.PostfixMathCommand
com.singularsys.jep.functions.BinaryFunction
com.singularsys.jep.functions.Power

All Implemented Interfaces:
  `PostfixMathCommandI`, `RealBinaryFunction`, `Serializable`

Direct Known Subclasses:
  `BigDecPow`

public class Power extends BinaryFunction implements RealBinaryFunction
Computes the power of a number. Implements a fast algorithm for integer powers by Patricia Shanahan pats@acm.org.

Since:
  3.3 Returns NaN rather than throwing and exception for out of range real arguments
Author:
  N Funk, R Morris, Patricia Shanahan
See Also:
  - Serialized Form

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class com.singularsys.jep.functions.BinaryFunction

  `BinaryFunction.BiFunctionWithException<T>`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected boolean`
  `strict`

  ### Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand

  `curNumberOfParameters, description, name, NaN, numberOfParameters`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Power()`
  Standard constructor, Complex results for x < 0, y non integral.
  `Power(boolean strict)`
  If strict is true then returns NaN for x < 0, y non-integral.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Object`
  `eval(Object l, Object r)`
  Evaluate the function
  `double`
  `evaluate(double l, double r)`
  `boolean`
  `isAllowComplexResults()`
  Whether complex results are allowed for number arguments.
  `static double`
  `power(double l, int n)`
  A fast routine for computing integer powers.
  `static Object`
  `power(Complex c1, Complex c2)`
  `static Object`
  `power(Complex c, Number d)`
  `static Object`
  `power(Number d, Complex c)`
  `Object`
  `power(Number d1, Number d2)`
  `Object`
  `power(Object param1, Object param2)`
  `void`
  `setAllowComplexResults(boolean allowComplexResults)`

  ### Methods inherited from class com.singularsys.jep.functions.BinaryFunction

  `instanceOf, instanceOf, instanceOf, instanceOf, run`

  ### Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand

  `asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, asType, checkNumberOfParameters, getDescription, getDescription, getDescriptionWithType, getName, getNumberOfParameters, setCurNumberOfParameters, setDescription, setName, toString, toString`

  ### Methods inherited from class java.lang.Object

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

- ## Field Details

  - ### strict

    protected boolean strict

- ## Constructor Details

  - ### Power

    public Power()
    Standard constructor, Complex results for x < 0, y non integral.

  - ### Power

    public Power(boolean strict)
    If strict is true then returns NaN for x < 0, y non-integral.
    Parameters:
      `strict` - true to force real results

- ## Method Details

  - ### eval

    public Object eval(Object l, Object r) throws EvaluationException
    Description copied from class: `BinaryFunction`
    Evaluate the function
    Specified by:
      `eval` in class `BinaryFunction`
    Parameters:
      `l` - lhs argument
      `r` - rhs argument
    Returns:
      the results
    Throws:
      `EvaluationException` - if the function cannot be evaluated.

  - ### power

    public Object power(Object param1, Object param2) throws EvaluationException
    Throws:
      `EvaluationException`

  - ### power

    public Object power(Number d1, Number d2)

  - ### power

    public static Object power(Complex c1, Complex c2)

  - ### power

    public static Object power(Complex c, Number d)

  - ### power

    public static Object power(Number d, Complex c)

  - ### power

    public static double power(double l, int n)
    A fast routine for computing integer powers. Code adapted from efficient power by Patricia Shanahan pats@acm.org Almost identical to the method Knuth gives on page 462 of The Art of Computer Programming Volume 2 Seminumerical Algorithms.
    Parameters:
      `l` - number to be taken to a power.
      `n` - power
    Returns:
      x to the power n

  - ### evaluate

    public double evaluate(double l, double r)
    Specified by:
      `evaluate` in interface `RealBinaryFunction`

  - ### isAllowComplexResults

    public boolean isAllowComplexResults()
    Whether complex results are allowed for number arguments. If l is a negative Number and r is non-integral Number then the pow function typically returns a Complex result. If this flag is set then an EvaluationException would be thrown instead.
    Returns:
      the status of the allowComplexResults flag.

  - ### setAllowComplexResults

    public void setAllowComplexResults(boolean allowComplexResults)