]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/math/include_private/boost/math/tools/test_data.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / math / include_private / boost / math / tools / test_data.hpp
index 86e347ac5d663a5548fa9f982ee6b3001860898c..c2b375839a71dd010ffe670ae33a78ef68892d95 100644 (file)
@@ -52,6 +52,8 @@ enum parameter_type
    random_in_range = 0,
    periodic_in_range = 1,
    power_series = 2,
+   single_value = 3,
+   plus_minus_value = 4,
    dummy_param = 0x80
 };
 
@@ -75,6 +77,10 @@ parameter_type& operator |= (parameter_type& a, parameter_type b)
 // If type == power_series then
 // n1 and n2 are the endpoints of the exponents (closed range) and z1 is the basis.
 //
+// If type == single_value then z1 contains the single value to add.
+//
+// If type == plus_minus_value then test at +-z1
+//
 // If type & dummy_param then this data is ignored and not stored in the output, it
 // is passed to the generator function however which can do with it as it sees fit.
 //
@@ -107,11 +113,25 @@ inline parameter_info<T> make_power_param(T basis, int start_exponent, int end_e
    return result;
 }
 
+template <class T>
+inline parameter_info<T> make_single_param(T val)
+{
+   parameter_info<T> result = { single_value, val };
+   return result;
+}
+
+template <class T>
+inline parameter_info<T> make_plus_minus_param(T val)
+{
+   parameter_info<T> result = { plus_minus_value, val };
+   return result;
+}
+
 namespace detail{
 
 template <class Seq, class Item, int N>
-inline void unpack_and_append_tuple(Seq& s,
-                                    const Item& data,
+inline void unpack_and_append_tuple(Seq&,
+                                    const Item&,
                                     const boost::integral_constant<int, N>&,
                                     const boost::false_type&)
 {
@@ -311,6 +331,135 @@ public:
       return *this;
    }
 
+   template <class F>
+   test_data& insert(F func, const parameter_info<T>& arg1, const parameter_info<T>& arg2, const parameter_info<T>& arg3, const parameter_info<T>& arg4)
+   {
+      // generate data for 4-argument functor F
+
+      typedef typename std::set<T>::const_iterator it_type;
+
+      std::set<T> points1, points2, points3, points4;
+      create_test_points(points1, arg1);
+      create_test_points(points2, arg2);
+      create_test_points(points3, arg3);
+      create_test_points(points4, arg4);
+      it_type a = points1.begin();
+      it_type b = points1.end();
+      row_type row;
+      while(a != b)
+      {
+         it_type c = points2.begin();
+         it_type d = points2.end();
+         while(c != d)
+         {
+            it_type e = points3.begin();
+            it_type f = points3.end();
+            while(e != f)
+            {
+               it_type g = points4.begin();
+               it_type h = points4.end();
+               while (g != h)
+               {
+                  if ((arg1.type & dummy_param) == 0)
+                     row.push_back(*a);
+                  if ((arg2.type & dummy_param) == 0)
+                     row.push_back(*c);
+                  if ((arg3.type & dummy_param) == 0)
+                     row.push_back(*e);
+                  if ((arg4.type & dummy_param) == 0)
+                     row.push_back(*g);
+#ifndef BOOST_NO_EXCEPTIONS
+                  try {
+#endif
+                     // domain_error exceptions from func are swallowed
+                     // and this data point is ignored:
+                     detail::unpack_and_append(row, func(*a, *c, *e, *g));
+                     m_data.insert(row);
+#ifndef BOOST_NO_EXCEPTIONS
+                  }
+                  catch (const std::domain_error&) {}
+#endif
+                  row.clear();
+                  ++g;
+               }
+               ++e;
+            }
+            ++c;
+         }
+         ++a;
+      }
+      return *this;
+   }
+
+   template <class F>
+   test_data& insert(F func, const parameter_info<T>& arg1, const parameter_info<T>& arg2, const parameter_info<T>& arg3, const parameter_info<T>& arg4, const parameter_info<T>& arg5)
+   {
+      // generate data for 5-argument functor F
+
+      typedef typename std::set<T>::const_iterator it_type;
+
+      std::set<T> points1, points2, points3, points4, points5;
+      create_test_points(points1, arg1);
+      create_test_points(points2, arg2);
+      create_test_points(points3, arg3);
+      create_test_points(points4, arg4);
+      create_test_points(points5, arg5);
+      it_type a = points1.begin();
+      it_type b = points1.end();
+      row_type row;
+      while(a != b)
+      {
+         it_type c = points2.begin();
+         it_type d = points2.end();
+         while(c != d)
+         {
+            it_type e = points3.begin();
+            it_type f = points3.end();
+            while(e != f)
+            {
+               it_type g = points4.begin();
+               it_type h = points4.end();
+               while (g != h)
+               {
+                  it_type i = points5.begin();
+                  it_type j = points5.end();
+                  while (i != j)
+                  {
+                     if ((arg1.type & dummy_param) == 0)
+                        row.push_back(*a);
+                     if ((arg2.type & dummy_param) == 0)
+                        row.push_back(*c);
+                     if ((arg3.type & dummy_param) == 0)
+                        row.push_back(*e);
+                     if ((arg4.type & dummy_param) == 0)
+                        row.push_back(*g);
+                     if ((arg5.type & dummy_param) == 0)
+                        row.push_back(*i);
+#ifndef BOOST_NO_EXCEPTIONS
+                     try {
+#endif
+                        // domain_error exceptions from func are swallowed
+                        // and this data point is ignored:
+                        detail::unpack_and_append(row, func(*a, *c, *e, *g, *i));
+                        m_data.insert(row);
+#ifndef BOOST_NO_EXCEPTIONS
+                     }
+                     catch (const std::domain_error&) {}
+#endif
+                     row.clear();
+                     ++i;
+                  }
+                  ++g;
+               }
+               ++e;
+            }
+            ++c;
+         }
+         ++a;
+      }
+      return *this;
+   }
+
    void clear(){ m_data.clear(); }
 
    // access:
@@ -420,6 +569,17 @@ void test_data<T>::create_test_points(std::set<T>& points, const parameter_info<
          }
       }
       break;
+   case single_value:
+   {
+      points.insert(truncate_to_float(real_cast<float>(arg1.z1)));
+      break;
+   }
+   case plus_minus_value:
+   {
+      points.insert(truncate_to_float(real_cast<float>(arg1.z1)));
+      points.insert(truncate_to_float(-real_cast<float>(arg1.z1)));
+      break;
+   }
    default:
       BOOST_ASSERT(0 == "Invalid parameter_info object");
       // Assert will fail if get here.