summaryrefslogtreecommitdiff
path: root/libs/math/test/functor.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/math/test/functor.hpp')
-rw-r--r--libs/math/test/functor.hpp100
1 files changed, 51 insertions, 49 deletions
diff --git a/libs/math/test/functor.hpp b/libs/math/test/functor.hpp
index 8da3b5c775..bb0f864553 100644
--- a/libs/math/test/functor.hpp
+++ b/libs/math/test/functor.hpp
@@ -9,12 +9,13 @@
#ifndef BOOST_MATH_TEST_FUNCTOR_HPP
#define BOOST_MATH_TEST_FUNCTOR_HPP
+template <class Real>
struct extract_result_type
{
extract_result_type(unsigned i) : m_location(i){}
template <class S>
- typename S::value_type operator()(const S& row)
+ Real operator()(const S& row)
{
return row[m_location];
}
@@ -22,18 +23,19 @@ private:
unsigned m_location;
};
-inline extract_result_type extract_result(unsigned i)
+template <class Real>
+inline extract_result_type<Real> extract_result(unsigned i)
{
- return extract_result_type(i);
+ return extract_result_type<Real>(i);
}
-template <class F>
+template <class Real, class F>
struct row_binder1
{
row_binder1(F _f, unsigned i) : f(_f), m_i(i) {}
template <class S>
- typename S::value_type operator()(const S& row)
+ Real operator()(const S& row)
{
return f(row[m_i]);
}
@@ -43,19 +45,19 @@ private:
unsigned m_i;
};
-template<class F>
-inline row_binder1<F> bind_func(F f, unsigned i)
+template<class Real, class F>
+inline row_binder1<Real, F> bind_func(F f, unsigned i)
{
- return row_binder1<F>(f, i);
+ return row_binder1<Real, F>(f, i);
}
-template <class F>
+template <class Real, class F>
struct row_binder2
{
row_binder2(F _f, unsigned i, unsigned j) : f(_f), m_i(i), m_j(j) {}
template <class S>
- typename S::value_type operator()(const S& row)
+ Real operator()(const S& row)
{
return f(row[m_i], row[m_j]);
}
@@ -65,19 +67,19 @@ private:
unsigned m_i, m_j;
};
-template<class F>
-inline row_binder2<F> bind_func(F f, unsigned i, unsigned j)
+template<class Real, class F>
+inline row_binder2<Real, F> bind_func(F f, unsigned i, unsigned j)
{
- return row_binder2<F>(f, i, j);
+ return row_binder2<Real, F>(f, i, j);
}
-template <class F>
+template <class Real, class F>
struct row_binder3
{
row_binder3(F _f, unsigned i, unsigned j, unsigned k) : f(_f), m_i(i), m_j(j), m_k(k) {}
template <class S>
- typename S::value_type operator()(const S& row)
+ Real operator()(const S& row)
{
return f(row[m_i], row[m_j], row[m_k]);
}
@@ -87,19 +89,19 @@ private:
unsigned m_i, m_j, m_k;
};
-template<class F>
-inline row_binder3<F> bind_func(F f, unsigned i, unsigned j, unsigned k)
+template<class Real, class F>
+inline row_binder3<Real, F> bind_func(F f, unsigned i, unsigned j, unsigned k)
{
- return row_binder3<F>(f, i, j, k);
+ return row_binder3<Real, F>(f, i, j, k);
}
-template <class F>
+template <class Real, class F>
struct row_binder4
{
row_binder4(F _f, unsigned i, unsigned j, unsigned k, unsigned l) : f(_f), m_i(i), m_j(j), m_k(k), m_l(l) {}
template <class S>
- typename S::value_type operator()(const S& row)
+ Real operator()(const S& row)
{
return f(row[m_i], row[m_j], row[m_k], row[m_l]);
}
@@ -109,21 +111,21 @@ private:
unsigned m_i, m_j, m_k, m_l;
};
-template<class F>
-inline row_binder4<F> bind_func(F f, unsigned i, unsigned j, unsigned k, unsigned l)
+template<class Real, class F>
+inline row_binder4<Real, F> bind_func(F f, unsigned i, unsigned j, unsigned k, unsigned l)
{
- return row_binder4<F>(f, i, j, k, l);
+ return row_binder4<Real, F>(f, i, j, k, l);
}
-template <class F>
+template <class Real, class F>
struct row_binder2_i1
{
row_binder2_i1(F _f, unsigned i, unsigned j) : f(_f), m_i(i), m_j(j) {}
template <class S>
- typename S::value_type operator()(const S& row)
+ Real operator()(const S& row)
{
- return f(boost::math::itrunc(row[m_i]), row[m_j]);
+ return f(boost::math::itrunc(Real(row[m_i])), row[m_j]);
}
private:
@@ -131,23 +133,23 @@ private:
unsigned m_i, m_j;
};
-template<class F>
-inline row_binder2_i1<F> bind_func_int1(F f, unsigned i, unsigned j)
+template<class Real, class F>
+inline row_binder2_i1<Real, F> bind_func_int1(F f, unsigned i, unsigned j)
{
- return row_binder2_i1<F>(f, i, j);
+ return row_binder2_i1<Real, F>(f, i, j);
}
-template <class F>
+template <class Real, class F>
struct row_binder3_i2
{
row_binder3_i2(F _f, unsigned i, unsigned j, unsigned k) : f(_f), m_i(i), m_j(j), m_k(k) {}
template <class S>
- typename S::value_type operator()(const S& row)
+ Real operator()(const S& row)
{
return f(
- boost::math::itrunc(row[m_i]),
- boost::math::itrunc(row[m_j]),
+ boost::math::itrunc(Real(row[m_i])),
+ boost::math::itrunc(Real(row[m_j])),
row[m_k]);
}
@@ -156,23 +158,23 @@ private:
unsigned m_i, m_j, m_k;
};
-template<class F>
-inline row_binder3_i2<F> bind_func_int2(F f, unsigned i, unsigned j, unsigned k)
+template<class Real, class F>
+inline row_binder3_i2<Real, F> bind_func_int2(F f, unsigned i, unsigned j, unsigned k)
{
- return row_binder3_i2<F>(f, i, j, k);
+ return row_binder3_i2<Real, F>(f, i, j, k);
}
-template <class F>
+template <class Real, class F>
struct row_binder4_i2
{
row_binder4_i2(F _f, unsigned i, unsigned j, unsigned k, unsigned l) : f(_f), m_i(i), m_j(j), m_k(k), m_l(l) {}
template <class S>
- typename S::value_type operator()(const S& row)
+ Real operator()(const S& row)
{
return f(
- boost::math::itrunc(row[m_i]),
- boost::math::itrunc(row[m_j]),
+ boost::math::itrunc(Real(row[m_i])),
+ boost::math::itrunc(Real(row[m_j])),
row[m_k],
row[m_l]);
}
@@ -182,30 +184,30 @@ private:
unsigned m_i, m_j, m_k, m_l;
};
-template<class F>
-inline row_binder4_i2<F> bind_func_int2(F f, unsigned i, unsigned j, unsigned k, unsigned l)
+template<class Real, class F>
+inline row_binder4_i2<Real, F> bind_func_int2(F f, unsigned i, unsigned j, unsigned k, unsigned l)
{
- return row_binder4_i2<F>(f, i, j, k, l);
+ return row_binder4_i2<Real, F>(f, i, j, k, l);
}
-template <class F>
+template <class Real, class F>
struct negate_type
{
negate_type(F f) : m_f(f){}
template <class S>
- typename S::value_type operator()(const S& row)
+ Real operator()(const S& row)
{
- return -m_f(row);
+ return -Real(m_f(row));
}
private:
F m_f;
};
-template <class F>
-inline negate_type<F> negate(F f)
+template <class Real, class F>
+inline negate_type<Real, F> negate(F f)
{
- return negate_type<F>(f);
+ return negate_type<Real, F>(f);
}
#endif