[git commit] tests/valarray: reduce precision

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Tue Apr 1 14:05:27 UTC 2014


commit: http://git.uclibc.org/uClibc++/commit/?id=46f0c32b255a9e580e89b01e87de0450ee302445
branch: http://git.uclibc.org/uClibc++/commit/?id=refs/heads/master

Print reduced precision for long double tests to avoid noise imposed by
different math implementations in libc's.

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
 tests/testoutput/valarraytest.good |   22 +++++++++++-----------
 tests/valarraytest.cpp             |    6 ++++--
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/tests/testoutput/valarraytest.good b/tests/testoutput/valarraytest.good
index 2468c62..ea8cdd8 100644
--- a/tests/testoutput/valarraytest.good
+++ b/tests/testoutput/valarraytest.good
@@ -20,31 +20,31 @@ Result of asin(f): 0 nan nan nan nan nan nan nan nan nan
 Result of asin(ld): 0 1.5708 nan nan nan nan nan nan nan nan
 Result of atan(d): 0 0.785398 1.10715 1.24905 1.32582 1.3734 1.40565 1.4289 1.44644 1.46014
 Result of atan(f): 0 0.832981 1.14417 1.27656 1.34732 1.39094 1.42042 1.44165 1.45765 1.47013
-Result of atan(ld): 0 0.785398 1.57078 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708
+Result of atan(ld): 0 0.7854 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708
 Result of atan2(d, d): 0 0.785398 0.785398 0.785398 0.785398 0.785398 0.785398 0.785398 0.785398 0.785398
 Result of atan2(type, d): 0 0 0 0 0 0 0 0 0 0
 Result of atan2(d, type): 0 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708
 Result of atan2(f, f): 0 0.785398 0.785398 0.785398 0.785398 0.785398 0.785398 0.785398 0.785398 0.785398
 Result of atan2(type, f): 0 0 0 0 0 0 0 0 0 0
 Result of atan2(f, type): 0 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708
-Result of atan2(ld, ld): 0 0.785398 0.785398 0.785398 0.785398 0.785398 0.785398 0.785398 0.785398 0.785398
+Result of atan2(ld, ld): 0 0.7854 0.7854 0.7854 0.7854 0.7854 0.7854 0.7854 0.7854 0.7854
 Result of atan2(type, ld): 0 0 0 0 0 0 0 0 0 0
 Result of atan2(ld, type): 0 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708
 Result of cos(d): 1 0.540302 -0.416147 -0.989992 -0.653644 0.283662 0.96017 0.753902 -0.1455 -0.91113
 Result of cos(f): 1 0.453596 -0.588501 -0.98748 -0.307333 0.70867 0.950233 0.153374 -0.811093 -0.889191
-Result of cos(ld): 1 0.540302 -0.721835 -0.90761 -0.886887 0.915809 0.628683 0.0376966 0.99158 0.817215
+Result of cos(ld): 1 0.5403 -0.72183 -0.90761 -0.88689 0.91581 0.62868 0.037697 0.99158 0.81721
 Result of cosh(d): 1 1.54308 3.7622 10.0677 27.3082 74.2099 201.716 548.317 1490.48 4051.54
 Result of cosh(f): 1 1.66852 4.56791 13.5748 40.7316 122.348 367.548 1104.17 3317.12 9965.18
-Result of cosh(ld): 1 1.54308 inf inf inf inf inf inf inf inf
+Result of cosh(ld): 1 1.5431 inf inf inf inf inf inf inf inf
 Result of exp(d): 1 2.71828 7.38906 20.0855 54.5982 148.413 403.429 1096.63 2980.96 8103.08
 Result of exp(f): 1 3.00417 9.02501 27.1126 81.4509 244.692 735.095 2208.35 6634.25 19930.4
-Result of exp(ld): 1 2.71828 inf inf inf inf inf inf inf inf
+Result of exp(ld): 1 2.7183 inf inf inf inf inf inf inf inf
 Result of log(d): -inf 0 0.693147 1.09861 1.38629 1.60944 1.79176 1.94591 2.07944 2.19722
 Result of log(f): -inf 0.0953102 0.788457 1.19392 1.4816 1.70475 1.88707 2.04122 2.17475 2.29253
-Result of log(ld): -inf 0 11.0904 17.5778 22.1807 25.751 28.6682 31.1346 33.2711 35.1556
+Result of log(ld): -inf 0 11.09 17.578 22.181 25.751 28.668 31.135 33.271 35.156
 Result of log10(d): -inf 0 0.30103 0.477121 0.60206 0.69897 0.778151 0.845098 0.90309 0.954243
 Result of log10(f): -inf 0.0413927 0.342423 0.518514 0.643453 0.740363 0.819544 0.886491 0.944483 0.995635
-Result of log10(ld): -inf 0 4.81648 7.63394 9.63296 11.1835 12.4504 13.5216 14.4494 15.2679
+Result of log10(ld): -inf 0 4.8165 7.6339 9.633 11.184 12.45 13.522 14.449 15.268
 Result of pow(d, d): 1 1 4 27 256 3125 46656 823543 1.67772e+07 3.8742e+08
 Result of pow(type, d): 1 0 0 0 0 0 0 0 0 0
 Result of pow(d, type): 1 1 1 1 1 1 1 1 1 1
@@ -56,17 +56,17 @@ Result of pow(type, ld): 1 0 0 0 0 0 0 0 0 0
 Result of pow(ld, type): 1 1 1 1 1 1 1 1 1 1
 Result of sin(d): 0 0.841471 0.909297 0.14112 -0.756802 -0.958924 -0.279415 0.656987 0.989358 0.412118
 Result of sin(f): 0 0.891207 0.808496 -0.157746 -0.951602 -0.70554 0.311541 0.988168 0.584917 -0.457536
-Result of sin(ld): 0 0.841471 0.692065 0.419814 -0.461987 -0.401613 0.777662 -0.999289 0.129496 -0.576333
+Result of sin(ld): 0 0.84147 0.69207 0.41981 -0.46199 -0.40161 0.77766 -0.99929 0.1295 -0.57634
 Result of sinh(d): 0 1.1752 3.62686 10.0179 27.2899 74.2032 201.713 548.316 1490.48 4051.54
 Result of sinh(f): 0 1.33565 4.45711 13.5379 40.7193 122.344 367.547 1104.17 3317.12 9965.18
 Result of sinh(ld): 0 1.1752 inf inf inf inf inf inf inf inf
 Result of sqrt(d): 0 1 1.41421 1.73205 2 2.23607 2.44949 2.64575 2.82843 3
 Result of sqrt(f): 0 1.04881 1.48324 1.81659 2.09762 2.34521 2.56905 2.77489 2.96648 3.14643
-Result of sqrt(ld): 0 1 256 6561 65536 390625 1.67962e+06 5.7648e+06 1.67772e+07 4.30467e+07
+Result of sqrt(ld): 0 1 256 6561 65536 3.9062e+05 1.6796e+06 5.7648e+06 1.6777e+07 4.3047e+07
 Result of tan(d): 0 1.55741 -2.18504 -0.142547 1.15782 -3.38052 -0.291006 0.871448 -6.79971 -0.452316
 Result of tan(f): 0 1.96476 -1.37382 0.159746 3.09632 -0.995584 0.327858 6.44286 -0.721147 0.514552
-Result of tan(ld): 0 1.55741 -0.958759 -0.462548 0.520908 -0.438534 1.23697 -26.5087 0.130596 -0.705241
+Result of tan(ld): 0 1.5574 -0.95876 -0.46255 0.52091 -0.43853 1.237 -26.509 0.1306 -0.70524
 Result of tanh(d): 0 0.761594 0.964028 0.995055 0.999329 0.999909 0.999988 0.999998 1 1
 Result of tanh(f): 0 0.800499 0.975743 0.997283 0.999699 0.999967 0.999996 1 1 1
-Result of tanh(ld): 0 0.761594 1 1 1 1 1 1 1 1
+Result of tanh(ld): 0 0.76159 1 1 1 1 1 1 1 1
 
diff --git a/tests/valarraytest.cpp b/tests/valarraytest.cpp
index ec5503b..d587e71 100644
--- a/tests/valarraytest.cpp
+++ b/tests/valarraytest.cpp
@@ -40,12 +40,14 @@ void print_array(std::string s, std::valarray<float>& a) {
 	std::cout << std::endl;
 }
 #if defined __UCLIBCXX_HAS_LONG_DOUBLE__ || defined _GLIBCXX_USE_C99_MATH_TR1
+#include <iomanip>
 void print_array(std::string s, std::valarray<long double>& a) {
-	std::cout << s;
+	std::streamsize old_precision = std::cout.precision();
+	std::cout << s << std::setprecision(old_precision - 1);
 	for (size_t i = 0; i < a.size(); ++i){
 		std::cout << " " << a[i];
 	}
-	std::cout << std::endl;
+	std::cout << std::setprecision(old_precision) << std::endl;
 }
 #endif
 


More information about the uClibc-cvs mailing list