This commit is contained in:
commit
568474d52f
1591 files changed
+528213
No files matched your search
@@ -0,0 +1,10 @@
|
||||
double kahan_sum(const double *x, long n) {
|
||||
double total = 0.0, c = 0.0;
|
||||
for (long i = 0; i < n; i++) {
|
||||
double y = x[i] - c;
|
||||
double t = total + y;
|
||||
c = (t - total) - y;
|
||||
total = t;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
def kahan_sum(x: List[Float64]) -> Float64:
|
||||
var total: Float64 = 0.0
|
||||
var c: Float64 = 0.0
|
||||
for i in range(len(x)):
|
||||
var y = x[i] - c
|
||||
var t = total + y
|
||||
c = (t - total) - y
|
||||
total = t
|
||||
return total
|
||||
@@ -0,0 +1,9 @@
|
||||
def kahan_sum(x):
|
||||
total = 0.0
|
||||
c = 0.0
|
||||
for v in x:
|
||||
y = v - c
|
||||
t = total + y
|
||||
c = (t - total) - y
|
||||
total = t
|
||||
return total
|
||||
Reference in new issue
Block a user