FunctionMath.SumIf<T> Method

Computes the sum of an expression evaluated for each member of a collection that meets the specified condition.

Definition

Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.4
C#
public static double SumIf<T>(
	IEnumerable<T> collection,
	Func<T, bool> predicate,
	Func<T, double> terms
)

Parameters

collection  IEnumerable<T>
An enumerable collection of elements of type T.
predicate  Func<T, Boolean>
A function that returns true if the element should be included in the sum.
terms  Func<T, Double>
A delegate that returns the value of the specified term.

Type Parameters

T
The type of the elements of the collection.

Return Value

Double
The sum of terms evaluated for each element of collection for which predicate returns true. .

Exceptions

ArgumentNullException

terms is null.

See Also