Mesa (master): gallivm: Simplify/reorder minimax helper.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Tue Apr 3 08:33:25 UTC 2012


Module: Mesa
Branch: master
Commit: d312b224b6759fd9b206d4c19450f6a4dfe53311
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d312b224b6759fd9b206d4c19450f6a4dfe53311

Author: José Fonseca <jfonseca at vmware.com>
Date:   Tue Apr  3 09:10:53 2012 +0100

gallivm: Simplify/reorder minimax helper.

---

 src/gallium/auxiliary/gallivm/f.cpp |   25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/f.cpp b/src/gallium/auxiliary/gallivm/f.cpp
index 6b9c35b..7cb50f1 100644
--- a/src/gallium/auxiliary/gallivm/f.cpp
+++ b/src/gallium/auxiliary/gallivm/f.cpp
@@ -31,20 +31,20 @@
  *
  *    ./minimax
  *
- * - For example, to compute log2 5th order polynomial between [1, 2] do:
+ * - For example, to compute exp2 5th order polynomial between [0, 1] do:
  *
  *    variant 0
- *    range 1 2
+ *    range 0 1
  *    order 5 0
  *    step 200
  *    info
  *
  *  and take the coefficients from the P = { ... } array.
  *
- * - To compute exp2 5th order polynomial between [0, 1] do:
+ * - To compute log2 5th order polynomial between [1, 2] do:
  *
  *    variant 1
- *    range 0 1
+ *    range 1 2
  *    order 5 0
  *    step 200
  *    info
@@ -59,20 +59,25 @@
 
 #include <cmath>
 
+boost::math::ntl::RR exp2(const boost::math::ntl::RR& x)
+{
+      return exp(x*log(2.0));
+}
+
+boost::math::ntl::RR log2(const boost::math::ntl::RR& x)
+{
+      return log(x)/log(2.0);
+}
 
 boost::math::ntl::RR f(const boost::math::ntl::RR& x, int variant)
 {
-   static const boost::math::ntl::RR tiny = boost::math::tools::min_value<boost::math::ntl::RR>() * 64;
-   
    switch(variant)
    {
    case 0:
-      // log2(x)/(x - 1)
-      return log(x)/log(2.0)/(x - 1.0);
+      return exp2(x);
 
    case 1:
-      // exp2(x)
-      return exp(x*log(2.0));
+      return log2(x)/(x - 1.0);
    }
 
    return 0;




More information about the mesa-commit mailing list