mirror of
https://github.com/boostorg/math.git
synced 2026-01-27 19:12:08 +00:00
Merge branch 'polynomial_initializer_list' into gcd_perf
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
polynomial(I first, I last);
|
||||
template <class U>
|
||||
explicit polynomial(const U& point);
|
||||
polynomial(std::initializer_list<T> l); // C++11
|
||||
|
||||
// access:
|
||||
size_type size()const;
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#include <vector>
|
||||
#include <ostream>
|
||||
#include <algorithm>
|
||||
#if __cplusplus >= 201103L
|
||||
#include <initializer_list>
|
||||
#endif
|
||||
|
||||
namespace boost{ namespace math{ namespace tools{
|
||||
|
||||
@@ -276,6 +279,20 @@ public:
|
||||
m_data.push_back(boost::math::tools::real_cast<T>(p[i]));
|
||||
}
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
polynomial(std::initializer_list<T> l) : polynomial(std::begin(l), std::end(l))
|
||||
{
|
||||
}
|
||||
|
||||
polynomial&
|
||||
operator=(std::initializer_list<T> l)
|
||||
{
|
||||
m_data.assign(std::begin(l), std::end(l));
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// access:
|
||||
size_type size()const { return m_data.size(); }
|
||||
|
||||
@@ -47,6 +47,26 @@ boost::array<int, 3> const d2 = {{-6, 0, 9}};
|
||||
boost::array<int, 6> const d5 = {{-9, 0, 3, 0, -15}};
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_construction )
|
||||
{
|
||||
polynomial<double> const a(d3a.begin(), d3a.end());
|
||||
polynomial<double> const b(d3a.begin(), 3);
|
||||
BOOST_CHECK_EQUAL(a, b);
|
||||
}
|
||||
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
BOOST_AUTO_TEST_CASE( test_initializer_list_construction )
|
||||
{
|
||||
polynomial<double> a(begin(d3a), end(d3a));
|
||||
polynomial<double> b = {10, -6, -4, 3};
|
||||
polynomial<double> c{10, -6, -4, 3};
|
||||
BOOST_CHECK_EQUAL(a, b);
|
||||
BOOST_CHECK_EQUAL(b, c);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_degree )
|
||||
{
|
||||
polynomial<double> const zero = zero_element(std::multiplies< polynomial<double> >());
|
||||
|
||||
Reference in New Issue
Block a user