-
Notifications
You must be signed in to change notification settings - Fork 0
/
ICompensatedSum.cs
36 lines (32 loc) · 1.26 KB
/
ICompensatedSum.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//---------------------------------------------------------------------------
// PROJECT : Compensated Accumulators
// COPYRIGHT : Andy Thomas (C) 2019
// WEB URL : https://kuiper.zone
// LICENSE : GPLv3
//---------------------------------------------------------------------------
namespace CompensatedAccumulators
{
/// <summary>
/// An interface for a compensated sum algorithm. A "compensated sum" offers reduced numerical
/// error when summing finite precision values in comparison to "naive" summation.
/// </summary>
public interface ICompensatedSum
{
/// <summary>
/// Get or sets the current summation value.
/// </summary>
double Value { get; set; }
/// <summary>
/// Adds 'x' to the <see cref="Value"/> sum, using a compensation technique designed to reduce numerical
/// error.
void Add(double x);
/// <summary>
/// Sets the sum value to zero and resets initial state.
/// </summary>
void Clear();
/// <summary>
/// Creates a "deep" copy of the instance with the same value and internal state. Returns the new instance.
/// </summary>
ICompensatedSum Clone();
}
}