34#ifndef _GEOM_SL_MVPOLY_TOOLS_H_
35#define _GEOM_SL_MVPOLY_TOOLS_H_
50namespace Geom {
namespace SL {
63template <
typename CoeffT>
78template <
size_t N,
typename CoeffT>
92 lex_degree_impl<0>(p,
D);
110 THROW_RANGEERROR (
"multi-index with wrong length");
112 return max_degree_impl<0>(p,
D,
I);
130 THROW_RANGEERROR (
"multi-index with wrong length");
132 return real_degree_impl<0>(p,
D,
I);
142 THROW_RANGEERROR (
"multi-index with wrong length");
152 template <
typename T>
156 return evaluate_impl<T, 0>(p,
X);
166 for (
size_t k = 0; k < p.
size(); ++k)
182 typename std::enable_if_t<(M <
N)>* = 0)
186 mvpoly<
N-1, CoeffT>::template for_each<M>(p[k], op);
195 typename std::enable_if_t<(M ==
N)>* = 0)
213 mvpoly<
N-1, CoeffT>::template lex_degree_impl<i+1>(p[
D[i]],
D);
223 if (
I[i] >
D[i])
return false;
225 mvpoly<
N-1, CoeffT>::template max_degree_impl<i+1>(p[
I[i]],
D,
I);
235 if (
I[i] >
D[i])
return false;
237 mvpoly<
N-1, CoeffT>::template real_degree_impl<i+1>(p[
I[i]],
D,
I);
245 for (
size_t k = 0; k < p.
size(); ++k)
247 mvpoly<
N-1, CoeffT>::template shift_impl<i+1>(p[k],
I);
251 template <
typename T,
size_t i>
264 T r =
mvpoly<
N-1, CoeffT>::template evaluate_impl<T, i+1>(p[n],
X);
265 for (
int k = n - 1; k >= 0; --k)
268 r +=
mvpoly<
N-1, CoeffT>::template evaluate_impl<T, i+1>(p[k],
X);
273 template <
size_t M,
typename C>
282template<
typename CoeffT >
294 typename std::enable_if_t<(M == 0)>* = 0)
344 template <
typename T,
size_t i>
356 template <
size_t M,
typename C>
366template <
size_t N,
typename CoeffT>
375 THROW_RANGEERROR (
"multi-index with wrong length");
377 return make_impl<0>(
I,
c);
394 template <
size_t M,
typename C>
400template <
typename CoeffT>
411 template<
size_t N,
typename C>
445template <
size_t N,
typename T>
451template <
size_t N,
typename CoeffT>
463 THROW_RANGEERROR (
"multi-index with wrong length");
465 return get_impl<0>(p,
I);
472 THROW_RANGEERROR (
"multi-index with wrong length");
474 return get_impl<0>(p,
I);
481 THROW_RANGEERROR (
"multi-index with wrong length");
483 return get_safe_impl<0>(p,
I);
490 THROW_RANGEERROR (
"multi-index with wrong length");
492 return set_safe_impl<0>(p,
I,
c);
500 return coefficient<
N-1, CoeffT>::template get_impl<i+1>(p[
I[i]],
I);
507 return coefficient<
N-1, CoeffT>::template get_impl<i+1>(p[
I[i]],
I);
521 coefficient<
N-1, CoeffT>::template get_safe_impl<i+1>(p[
I[i]],
I);
541 template<
size_t M,
typename T>
547template <
size_t N,
typename CoeffT>
554template <
typename CoeffT>
566 THROW_RANGEERROR (
"multi-index with wrong length");
575 THROW_RANGEERROR (
"multi-index with wrong length");
584 THROW_RANGEERROR (
"multi-index with wrong length");
593 THROW_RANGEERROR (
"multi-index with wrong length");
627 template<
size_t M,
typename T>
632template <
typename CoeffT>
658template <
size_t N,
typename CoeffT,
typename OrderT = ordering::lex>
662template <
size_t N,
typename CoeffT>
Defines the different types of exceptions that 2geom can throw.
size_t real_degree() const
size_t max_degree() const
coeff_type const & coefficient(size_t i) const
std::valarray< size_t > multi_index_type
multi_index_type shift(multi_index_type const &I, size_t i=1)
Various utility functions.
static void set_safe(poly_type &p, multi_index_type const &I, type const &c)
static type & get_impl(poly_type &p, multi_index_type const &I)
static type const & get_safe_impl(poly_type const &p, multi_index_type const &I)
static type const & get(poly_type const &p, multi_index_type const &I)
Polynomial< CoeffT > poly_type
static void set_safe_impl(poly_type &p, multi_index_type const &I, type const &c)
static type const & get_impl(poly_type const &p, multi_index_type const &I)
static type const & get_safe(poly_type const &p, multi_index_type const &I)
static type & get(poly_type &p, multi_index_type const &I)
static type const & get(poly_type const &p, multi_index_type const &I)
static type & get_impl(poly_type &p, multi_index_type const &I)
static type const & get_safe_impl(poly_type const &p, multi_index_type const &I)
static void set_safe_impl(poly_type &p, multi_index_type const &I, type const &c)
coefficient< N-1, CoeffT >::type type
static type const & get_impl(poly_type const &p, multi_index_type const &I)
static type const & get_safe(poly_type const &p, multi_index_type const &I)
static type & get(poly_type &p, multi_index_type const &I)
static void set_safe(poly_type &p, multi_index_type const &I, type const &c)
Polynomial< CoeffT > poly_type
static CoeffT make_impl(multi_index_type const &, CoeffT c)
static poly_type make_impl(multi_index_type const &I, CoeffT c)
mvpoly< N, CoeffT >::type poly_type
static poly_type make(multi_index_type const &I, CoeffT c)
static multi_index_type value(poly_type const &p)
mvpoly< N, CoeffT >::type poly_type
static void lex_degree_impl(type const &, multi_index_type &)
static bool real_degree_impl(type const &, multi_index_type &, multi_index_type const &)
static void shift_impl(type &, multi_index_type const &)
static void normalize(type &)
static void multiply_to(type &p, type const &q)
static bool max_degree_impl(type const &, multi_index_type &, multi_index_type const &)
static T evaluate_impl(type const &p, std::array< T, i > const &)
static void divide_to(type &p, type const &c)
static void for_each(type &p, std::function< void(typename mvpoly< M, CoeffT >::type &)> const &op, typename std::enable_if_t<(M==0)> *=0)
static void for_each(type &p, std::function< void(typename mvpoly< M, CoeffT >::type &)> const &op, typename std::enable_if_t<(M< N)> *=0)
static bool real_degree_impl(type const &p, multi_index_type &D, multi_index_type const &I)
static void lex_degree_impl(type const &p, multi_index_type &D)
static bool real_degree(type const &p, multi_index_type &D, multi_index_type const &I)
static void normalize(type &p)
static T evaluate_impl(type const &p, std::array< T, N+i > const &X)
static multi_index_type lex_degree(type const &p)
static void shift_impl(type &p, multi_index_type const &I)
static T evaluate(type const &p, std::array< T, N > const &X)
static void multiply_to(type &p, type const &q)
static bool max_degree(type const &p, multi_index_type &D, multi_index_type const &I)
static bool max_degree_impl(type const &p, multi_index_type &D, multi_index_type const &I)
static void shift(type &p, multi_index_type const &I)
Polynomial< typename mvpoly< N-1, CoeffT >::type > type
static void for_each(type &p, std::function< void(typename mvpoly< M, CoeffT >::type &)> const &op, typename std::enable_if_t<(M==N)> *=0)
static const size_t value