[babl] Add simple test app to test pow-24 accuracy
- From: Ãyvind KolÃs <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl] Add simple test app to test pow-24 accuracy
- Date: Fri, 27 Jul 2012 19:08:09 +0000 (UTC)
commit dc824c0ac704b35130aff44e544e8666e21b5bc5
Author: Alexander Larsson <alexl redhat com>
Date: Mon Jun 18 15:17:51 2012 +0200
Add simple test app to test pow-24 accuracy
https://bugzilla.gnome.org/show_bug.cgi?id=678318
babl/base/Makefile.am | 4 +++
babl/base/test-pow.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/babl/base/Makefile.am b/babl/base/Makefile.am
index 5b92521..58f711e 100644
--- a/babl/base/Makefile.am
+++ b/babl/base/Makefile.am
@@ -27,3 +27,7 @@ EXTRA_DIST = \
util.h \
pow-24.h
+noinst_PROGRAMS = test-pow
+
+test_pow_SOURCES = test-pow.c
+test_pow_LDADD = libbase.la $(MATH_LIB)
diff --git a/babl/base/test-pow.c b/babl/base/test-pow.c
new file mode 100644
index 0000000..08406c9
--- /dev/null
+++ b/babl/base/test-pow.c
@@ -0,0 +1,54 @@
+#include <stdio.h>
+#include <math.h>
+
+#include "pow-24.h"
+
+int
+main (int argc, char *argv[])
+{
+ double s, r1, r2, diff, max;
+ double at_s, at_r1, at_r2;
+ long i;
+
+ s = 0.03;
+ at_s = 0;
+ max = 0;
+ for (i = 0; i < 1100000000; i++)
+ {
+ r1 = babl_pow_24 (s);
+ r2 = pow (s, 2.4);
+ diff = fabs (r2-r1);
+ if (diff > max) {
+ max = diff;
+ at_s = s;
+ at_r1 = r1;
+ at_r2 = r2;
+ }
+ s += 0.000000001;
+ }
+ printf ("x^2.4\n");
+ printf ("max from 0 to %f is %e\n", s, max);
+ printf ("at: %f %f %f\n", at_s, at_r1, at_r2);
+
+ s = 0.03;
+ at_s = 0;
+ max = 0;
+ for (i = 0; i < 1100000000; i++)
+ {
+ r1 = babl_pow_1_24 (s);
+ r2 = pow (s, 1/2.4);
+ diff = fabs (r2-r1);
+ if (diff > max) {
+ max = diff;
+ at_s = s;
+ at_r1 = r1;
+ at_r2 = r2;
+ }
+ s += 0.000000001;
+ }
+ printf ("x^(1/2.4)\n");
+ printf ("max from 0 to %f is %e\n", s, max);
+ printf ("at: %f %f %f\n", at_s, at_r1, at_r2);
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]