Loosen check-math-partial-sums for floating error (r=dmandelin)

This commit is contained in:
Luke Wagner 2010-03-04 16:32:06 -08:00
parent cef73f06e6
commit a87d51a58a

View File

@ -26,11 +26,16 @@ function partial(n){
a9 += alt/(2*k -1);
}
return [ a1, a2, a3, a4, a5, a6, a7, a8, a9 ].join(',');
return [ a1, a2, a3, a4, a5, a6, a7, a8, a9 ];
}
var actual = '';
for (var i = 1024; i <= 16384; i *= 2) {
actual += partial(i) + ';';
}
assertEq(actual, "2.9999999999999987,62.555269219624684,0.9990243902439033,30.174793391263677,42.99468748637077,7.509175672278132,1.6439579810301654,0.6926591377284127,0.785154022830656;2.9999999999999987,89.06036157695789,0.9995119570522216,30.30796333494624,42.99485339033617,8.202078771817716,1.6444459047881168,0.6929030995395857,0.7852760930922243;2.9999999999999987,126.54745783224483,0.999755918965097,30.314167756318135,42.994888939123,8.89510389696629,1.6446899560231332,0.6930251251486118,0.7853371282421086;2.9999999999999987,179.56450569047874,0.9998779445868421,30.314499725429847,42.99489723774016,9.588190046095265,1.644812003986005,0.693086149128997,0.785367645819433;2.9999999999999987,254.54355172132264,0.9999389685688135,30.31451920492601,42.99489939769195,10.281306710008463,1.6448730335545856,0.6931166639131536,0.7853829046083998;")
var actual = [];
for (var i = 1024; i <= 16384; i *= 2)
Array.prototype.push.apply(actual, partial(i));
var eps = 1e-12;
var expect = [2.9999999999999987,62.555269219624684,0.9990243902439033,30.174793391263677,42.99468748637077,7.509175672278132,1.6439579810301654,0.6926591377284127,0.785154022830656,2.9999999999999987,89.06036157695789,0.9995119570522216,30.30796333494624,42.99485339033617,8.202078771817716,1.6444459047881168,0.6929030995395857,0.7852760930922243,2.9999999999999987,126.54745783224483,0.999755918965097,30.314167756318135,42.994888939123,8.89510389696629,1.6446899560231332,0.6930251251486118,0.7853371282421086,2.9999999999999987,179.56450569047874,0.9998779445868421,30.314499725429847,42.99489723774016,9.588190046095265,1.644812003986005,0.693086149128997,0.785367645819433,2.9999999999999987,254.54355172132264,0.9999389685688135,30.31451920492601,42.99489939769195,10.281306710008463,1.6448730335545856,0.6931166639131536,0.7853829046083998];
assertEq(actual.length, expect.length);
for (var i = 0; i < expect.length; ++i)
assertEq(Math.abs(actual[i] - expect[i]) < eps, true);