Package com.singularsys.jep.functions

# Class VSum

java.lang.Object
com.singularsys.jep.functions.PostfixMathCommand
com.singularsys.jep.functions.ArrayFunctionBase
com.singularsys.jep.functions.VSum

All Implemented Interfaces:
  `ZeroLengthBehaviourI`, `PostfixMathCommandI`, `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 interface com.singularsys.jep.functions.ZeroLengthBehaviourI

  `ZeroLengthBehaviourI.DefaultZeroLengthBehaviourI, ZeroLengthBehaviourI.ZeroLengthErrorBehaviour, ZeroLengthBehaviourI.ZeroLengthHelper`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final Add`
  `add`

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

  `curNumberOfParameters, description, name, NaN, numberOfParameters`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `VSum()`
  Default constructor.
  `VSum(Add add, ZeroLengthBehaviourI.ZeroLengthErrorBehaviour zeroLengthErrorBehaviour)`
  Constructor with specified Add object and zero length error behaviour.
  `VSum(Add add, Object zeroLengthValue)`
  Constructor with specified Add object and zero length value.
  `VSum(ZeroLengthBehaviourI.ZeroLengthErrorBehaviour zeroLengthErrorBehaviour)`
  Constructor with specified zero length error behaviour.
  `VSum(Object zeroLengthValue)`
  Constructor with specified zero length value.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected Object`
  `calc(List<Object> v)`
  Abstract method for performing the array calculation.
  `Object`
  `sum(List<Object> vals)`
  Returns the sum of a set of values.

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

  `addToArray, checkNumberOfParameters, getZeroLengthErrorBehaviour, getZeroLengthValue, run, setZeroLengthErrorBehaviour, setZeroLengthValue, throwAtLeastOneExcep`

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

  `asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, asType, 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`

  ### Methods inherited from interface com.singularsys.jep.functions.ZeroLengthBehaviourI

  `getErrorMessage, getValueOrException, zeroLengthResultOrException`

- ## Field Details

  - ### add

    protected final Add add

- ## Constructor Details

  - ### VSum

    public VSum()
    Default constructor. Sets the zero-length value to 0.0

  - ### VSum

    public VSum(ZeroLengthBehaviourI.ZeroLengthErrorBehaviour zeroLengthErrorBehaviour)
    Constructor with specified zero length error behaviour.

  - ### VSum

    public VSum(Object zeroLengthValue)
    Constructor with specified zero length value.

  - ### VSum

    public VSum(Add add, Object zeroLengthValue)
    Constructor with specified Add object and zero length value.

  - ### VSum

    public VSum(Add add, ZeroLengthBehaviourI.ZeroLengthErrorBehaviour zeroLengthErrorBehaviour)
    Constructor with specified Add object and zero length error behaviour.

- ## Method Details

  - ### sum

    public Object sum(List<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` - if the calculation cannot be performed

  - ### calc

    protected Object calc(List<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. Note this is in reverse order of the arguments of the function.
    Returns:
      The result of the calculation.
    Throws:
      `EvaluationException` - if the calculation cannot be performed