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

## org.lsmp.djep.xjep.function
Class SumType

    java.lang.Object
      org.nfunk.jep.function.PostfixMathCommand
          org.lsmp.djep.xjep.function.SumType

All Implemented Interfaces:
  CallbackEvaluationI, PostfixMathCommandI

Direct Known Subclasses:
  Max, MaxArg, Min, MinArg, Product, Sum, Trapezium

    public abstract class SumType

extends PostfixMathCommand
implements CallbackEvaluationI

Base class for functions like Sum(x^2,x,1,10) which finds the sum of x^2 with x running from 1 to 10. The first argument should be an equation, the second argument is a variable name, the third argument is the min value, the forth is the max value and the fifth argument (if present, default 1) is the increment to use. Sub classes should implement the

    public abstract Object evaluate(Object elements[]) throws ParseException;

method, which is passed an array of the value

Author:
  Rich Morris Created on 10-Sept-2004

Field Summary
`protected java.lang.String` | `name` The name of the function, use in error reporting.

Fields inherited from class org.nfunk.jep.function.PostfixMathCommand
`curNumberOfParameters, numberOfParameters`

Constructor Summary
`SumType()`
`SumType(java.lang.String funName)`

Method Summary
`boolean` | `checkNumberOfParameters(int n)` Checks the number of parameters of the function.
`java.lang.Object` | `evaluate(Node node, EvaluatorI pv)` Evaluates the operator in given context.
`java.lang.Object` | `evaluate(Node node, Variable var, double min, double max, double inc, EvaluatorI pv)` Evaluates the node by repeatibly setting the value of the variable from min to max, and calculating the value of the first argument.
`abstract java.lang.Object` | `evaluate(java.lang.Object[] elements)` Evaluates the function given the set of y values.
`void` | `run(java.util.Stack s)` run method.

Methods inherited from class org.nfunk.jep.function.PostfixMathCommand
`checkStack, getNumberOfParameters, setCurNumberOfParameters`

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

Field Detail

### name

    protected java.lang.String name

  The name of the function, use in error reporting.

Constructor Detail

### SumType

    public SumType(java.lang.String funName)

### SumType

    public SumType()

Method Detail

### checkNumberOfParameters

    public boolean checkNumberOfParameters(int n)

  Description copied from class: `PostfixMathCommand`
  Checks the number of parameters of the function. Functions which set numberOfParameter=-1 should overload this method

  Specified by:
    `checkNumberOfParameters` in interface `PostfixMathCommandI`
  Overrides:
    `checkNumberOfParameters` in class `PostfixMathCommand`
  Parameters:
    `n` - number of parameters function will be called with.
  Returns:
    False if an illegal number of parameters is supplied, true otherwise.

### evaluate

    public java.lang.Object evaluate(Node node,
                                     EvaluatorI pv)
                              throws ParseException

  Evaluates the operator in given context. Typically does not need to be sub-classed as the other evaluate methods are more useful. This method just checks the arguments.

  Specified by:
    `evaluate` in interface `CallbackEvaluationI`
  Parameters:
    `node` - The current node
    `pv` - The visitor, can be used evaluate the children
  Returns:
    the value after evaluation
  Throws:
    `ParseException`

### evaluate

    public java.lang.Object evaluate(Node node,
                                     Variable var,
                                     double min,
                                     double max,
                                     double inc,
                                     EvaluatorI pv)
                              throws ParseException

  Evaluates the node by repeatibly setting the value of the variable from min to max, and calculating the value of the first argument. Sub classes generally do not need to implement this method as `evaluate(Object[])` is more useful. If they do they should follow the pattern used here.

  Parameters:
    `node` -
    `var` -
    `min` -
    `max` -
    `inc` -
    `pv` -
  Returns:
    the result of evaluation
  Throws:
    `ParseException`

### evaluate

    public abstract java.lang.Object evaluate(java.lang.Object[] elements)
                                       throws ParseException

  Evaluates the function given the set of y values. For example for Sum(x^2,x,1,5) the function will be passed the array [1,4,9,16,25].

  Parameters:
    `elements` - the y values
  Returns:
    the result of the function
  Throws:
    `ParseException`

### run

    public void run(java.util.Stack s)
             throws ParseException

  run method. Should not be called.

  Specified by:
    `run` in interface `PostfixMathCommandI`
  Overrides:
    `run` in class `PostfixMathCommand`
  Throws:
    `ParseException`

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

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