Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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, java.io.Serializable

    public final class Power

extends BinaryFunction
implements RealBinaryFunction

Computes the power of an 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

Field Summary

Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
`curNumberOfParameters, name, NaN, numberOfParameters`

Constructor Summary
`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
`java.lang.Object` | `eval(java.lang.Object l, java.lang.Object r)`
`double` | `evaluate(double l, double r)`
`boolean` | `isAllowComplexResults()` Whether complex results are allowed for number arguments.
`static java.lang.Object` | `power(Complex c1, Complex c2)`
`static java.lang.Object` | `power(Complex c, java.lang.Number d)`
`static double` | `power(double l, int n)` A fast routine for computing integer powers.
`static java.lang.Object` | `power(java.lang.Number d, Complex c)`
`java.lang.Object` | `power(java.lang.Number d1, java.lang.Number d2)`
`java.lang.Object` | `power(java.lang.Object param1, java.lang.Object param2)`
`void` | `setAllowComplexResults(boolean allowComplexResults)`

Methods inherited from class com.singularsys.jep.functions.BinaryFunction
`run`

Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand
`asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, checkNumberOfParameters, checkStack, getName, getNumberOfParameters, setCurNumberOfParameters, setName, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### 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` -

Method Detail

### eval

    public java.lang.Object eval(java.lang.Object l,
                                 java.lang.Object r)
                          throws EvaluationException

  Specified by:
    `eval` in class `BinaryFunction`
  Throws:
    `EvaluationException`

### power

    public java.lang.Object power(java.lang.Object param1,
                                  java.lang.Object param2)
                           throws EvaluationException

  Throws:
    `EvaluationException`

### power

    public java.lang.Object power(java.lang.Number d1,
                                  java.lang.Number d2)

### power

    public static java.lang.Object power(Complex c1,
                                         Complex c2)

### power

    public static java.lang.Object power(Complex c,
                                         java.lang.Number d)

### power

    public static java.lang.Object power(java.lang.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 to take x to. 0 <= n <= Integer.MAX_VALUE Negative numbers will be treated as unsigned positives.
  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)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008 Singular Systems http://www.singularsys.com/jep