Array Math.Sum Method
Definition
Namespace: Extreme.Mathematics
Assembly: Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.23
Assembly: Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.23
Overload List
Sum(Double[]) | Computes the sum of the elements of an array. |
Sum(Double[], Int32, Int32) | Computes the sum of the elements in a segment of an array. |
Sum<T>(IEnumerable<T>) | Computes the sum of the sequence of values. |
Sum<T, U>(IEnumerable<T>, Func<T, U>) | Computes the sum of the sequence of values that are obtained by invoking a transform function on each element of the input sequence. |
Sum(Double[])
Computes the sum of the elements of an array.
public static double Sum(
this double[] array
)
Parameters
Return Value
DoubleThe sum of the elements in array.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type Double[]. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).Sum<T>(IEnumerable<T>)
Computes the sum of the sequence of values.
public static T Sum<T>(
this IEnumerable<T> source
)
Parameters
- source IEnumerable<T>
- A sequence of values.
Type Parameters
- T
- The element type of source.
Return Value
TUsage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable<T>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).Sum<T, U>(IEnumerable<T>, Func<T, U>)
Computes the sum of the sequence of values that are obtained
by invoking a transform function on each element of the input sequence.
public static U Sum<T, U>(
this IEnumerable<T> source,
Func<T, U> selector
)
Parameters
- source IEnumerable<T>
- A sequence of values.
- selector Func<T, U>
- A transform function to apply to each element.
Type Parameters
- T
- The element type of source.
- U
- The type of the result.
Return Value
UThe sum of the projected values.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable<T>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).Sum(Double[], Int32, Int32)
Computes the sum of the elements in a segment of an array.
public static double Sum(
this double[] array,
int startIndex,
int Length
)
Parameters
- array Double[]
- A Double array.
- startIndex Int32
- The zero-based index of the first element to be included in the sum.
- Length Int32
- The length of the segment.
Return Value
DoubleThe sum of the specified elements in array.