Fix minor inaccuracies in the new sum() algorithm.
FossilOrigin-Name: e3f7a960c9bd8e84cd70f0585bb955d043604a92001d0e2bf6c1216bb1fd7221
This commit is contained in:
parent
45d7562843
commit
26cd8bc1af
15
manifest
15
manifest
@ -1,5 +1,5 @@
|
||||
C Experimental\sattempt\sto\sboost\sthe\saccuracy\sof\ssum()\susing\sthe\nKahan-Babuska-Neumaier\salgorithm.
|
||||
D 2023-07-06T13:19:10.993
|
||||
C Fix\sminor\sinaccuracies\sin\sthe\snew\ssum()\salgorithm.
|
||||
D 2023-07-06T14:45:53.235
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -590,7 +590,7 @@ F src/delete.c cd5f5cd06ed0b6a882ec1a8c2a0d73b3cecb28479ad19e9931c4706c5e2182be
|
||||
F src/expr.c 8d1656b65e26af3e34f78e947ac423f0d20c214ed25a67486e433bf16ca6b543
|
||||
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
|
||||
F src/fkey.c a7fcbf7e66d14dbb73cf49f31489ebf66d0e6006c62b95246924a3bae9f37b36
|
||||
F src/func.c baa50a89130c980f2f7da89918da76cfa72708074c72d2fe5b21308a59454d37
|
||||
F src/func.c 994a3a30d36c079c6e26d6653d770153675590daa549d3692eb38c5ac05dc663
|
||||
F src/global.c a16553245e315ee0cda8f9b0bf744efef9dc99f86e9d77f58975ea58824ded92
|
||||
F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220
|
||||
F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51
|
||||
@ -2043,11 +2043,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P 9427f42687ed6d97c474bf42d0c3e82d6f4b0075e74206adcb5699d72e32140e
|
||||
R d2e2f73c16e9792f0c7025c31bf09b42
|
||||
T *branch * kahan-babuska-neumaier-summation
|
||||
T *sym-kahan-babuska-neumaier-summation *
|
||||
T -sym-trunk *
|
||||
P ebc5edd3b10c1102b07b9fb0d6837266b81e55504ef883b9b8a7ad5e8ab29dd2
|
||||
R fc07faedc8ec40abb250af878f96b89f
|
||||
U drh
|
||||
Z 0c513397b66b5a1b4aafb74e58b9b2cf
|
||||
Z a457302fb05d630d42e97f2453c1a24d
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@ -1 +1 @@
|
||||
ebc5edd3b10c1102b07b9fb0d6837266b81e55504ef883b9b8a7ad5e8ab29dd2
|
||||
e3f7a960c9bd8e84cd70f0585bb955d043604a92001d0e2bf6c1216bb1fd7221
|
15
src/func.c
15
src/func.c
@ -1690,11 +1690,12 @@ static void kahanBabuskaNeumaierStep(
|
||||
volatile SumCtx *pSum,
|
||||
volatile double r
|
||||
){
|
||||
volatile double t = pSum->rSum + r;
|
||||
if( fabs(pSum->rSum) > fabs(r) ){
|
||||
pSum->rErr += (pSum->rSum - t) + r;
|
||||
volatile double s = pSum->rSum;
|
||||
volatile double t = s + r;
|
||||
if( fabs(s) > fabs(r) ){
|
||||
pSum->rErr += (s - t) + r;
|
||||
}else{
|
||||
pSum->rErr += (r - t) + pSum->rSum;
|
||||
pSum->rErr += (r - t) + s;
|
||||
}
|
||||
pSum->rSum = t;
|
||||
}
|
||||
@ -1706,7 +1707,7 @@ static void kahanBabuskaNeumaierStepInt64(volatile SumCtx *pSum, i64 iVal){
|
||||
volatile double rVal = (double)iVal;
|
||||
kahanBabuskaNeumaierStep(pSum, rVal);
|
||||
if( iVal<=-4503599627370496 || iVal>=+4503599627370496 ){
|
||||
double rDiff = (double)(iVal - (double)rVal);
|
||||
double rDiff = (double)(iVal - (i64)rVal);
|
||||
kahanBabuskaNeumaierStep(pSum, rDiff);
|
||||
}
|
||||
}
|
||||
@ -1788,8 +1789,8 @@ static void sumInverse(sqlite3_context *context, int argc, sqlite3_value**argv){
|
||||
if( iVal!=SMALLEST_INT64 ){
|
||||
kahanBabuskaNeumaierStepInt64(p, -iVal);
|
||||
}else{
|
||||
kahanBabuskaNeumaierStepInt64(p, LARGEST_INT64/2);
|
||||
kahanBabuskaNeumaierStepInt64(p, LARGEST_INT64/2+1);
|
||||
kahanBabuskaNeumaierStepInt64(p, LARGEST_INT64);
|
||||
kahanBabuskaNeumaierStepInt64(p, 1);
|
||||
}
|
||||
}else{
|
||||
kahanBabuskaNeumaierStep(p, -sqlite3_value_double(argv[0]));
|
||||
|
Loading…
Reference in New Issue
Block a user