com.singularsys.jep.functions
Class VSum

java.lang.Object
  extended by com.singularsys.jep.functions.PostfixMathCommand
      extended by com.singularsys.jep.functions.ArrayFunctionBase
          extended by com.singularsys.jep.functions.VSum
All Implemented Interfaces:
PostfixMathCommandI, java.io.Serializable

public class VSum
extends ArrayFunctionBase

Summation function which expands the arguments. The VSum function will expand any arrays given as arguments so vsum([1,2],[3,4]) will be 10. This differs from the standard Sum function which does not expand them. The result of sum([1,2],[3,4]) in contrast would be [4,6].

Since:
3.4
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.singularsys.jep.functions.ArrayFunctionBase
ArrayFunctionBase.ZeroLengthErrorBehaviour
 
Field Summary
protected  Add add
           
 
Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, name, NaN, numberOfParameters
 
Constructor Summary
VSum()
           
 
Method Summary
protected  java.lang.Object calc(java.util.List<java.lang.Object> v)
          Abstract method for performing the array calculation.
 java.lang.Object sum(java.util.List<java.lang.Object> vals)
          Returns the sum of a set of values.
 
Methods inherited from class com.singularsys.jep.functions.ArrayFunctionBase
checkNumberOfParameters, getZeroLengthErrorBehaviour, run, setZeroLengthErrorBehaviour, throwAtLeastOneExcep
 
Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, checkStack, getName, getNumberOfParameters, setCurNumberOfParameters, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

add

protected Add add
Constructor Detail

VSum

public VSum()
Method Detail

sum

public java.lang.Object sum(java.util.List<java.lang.Object> vals)
                     throws EvaluationException
Returns the sum of a set of values. Depends on the Add classes to perform the calculation.

Parameters:
vals - Values to be averaged
Returns:
the sum of values
Throws:
EvaluationException

calc

protected java.lang.Object calc(java.util.List<java.lang.Object> v)
                         throws EvaluationException
Description copied from class: ArrayFunctionBase
Abstract method for performing the array calculation.

Specified by:
calc in class ArrayFunctionBase
Parameters:
v - The list to operate on.
Returns:
The result of the calculation.
Throws:
EvaluationException


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