41# include <type_traits>
54 template <
typename Coeff>
68 template <
typename Poly>
79 std::cout <<
"{\"coeff\": " <<
coeff <<
", \"exponents\": [";
80 for (
size_t i = 0; i < idx.
size(); ++i)
83 if (i + 1 < idx.
size())
91 template <
typename TermList>
97 for (
auto it = terms.get_it(); it.has_curr(); it.next_ne())
102 const auto &
term = it.get_curr();
103 std::cout <<
"{\"multiplicity\": " <<
term.multiplicity <<
", \"factor\": ";
105 if constexpr (std::is_same_v<FactorType, IntPoly>)
132 std::cout <<
" \"univariate\": [\n"
134 <<
" \"name\": \"sum_mul_divmod\",\n"
147 <<
" \"quotient\": ";
150 <<
" \"remainder\": ";
155 <<
" \"name\": \"compose_sparse\",\n"
162 <<
" \"composed\": ";
167 <<
" \"name\": \"factorize_integer\",\n"
181 auto x = IntMultiPoly::variable(2, 0);
182 auto y = IntMultiPoly::variable(2, 1);
192 auto xlex = LexMultiPoly::variable(2, 0);
193 auto ylex = LexMultiPoly::variable(2, 1);
197 auto gb = LexMultiPoly::reduced_groebner_basis(
gens);
200 <<
" \"multivariate\": [\n"
202 <<
" \"name\": \"factorize_difference_of_squares\",\n"
203 <<
" \"nvars\": 2,\n"
212 <<
" \"name\": \"factorize_same_degree_non_monic\",\n"
213 <<
" \"nvars\": 2,\n"
222 <<
" \"name\": \"groebner_reduced_lex\",\n"
223 <<
" \"nvars\": 2,\n"
224 <<
" \"generators\": [";
225 for (
size_t i = 0; i <
gens.size(); ++i)
228 if (i + 1 <
gens.size())
233 for (
size_t i = 0; i <
gb.size(); ++i)
236 if (i + 1 <
gb.size())
248 for (
int i = 1; i <
argc; ++i)
250 const std::string
arg =
argv[i];
253 std::cout <<
"Usage: polynomial_reference_probe [--json]\n";
258 std::cerr <<
"Unknown option: " <<
arg <<
"\n";
264 <<
" \"mode\": \"reference\",\n";
267 std::cout <<
"\n}\n";
Simple dynamic array with automatic resizing and functional operations.
constexpr size_t size() const noexcept
Return the number of elements stored in the stack.
Sparse multivariate polynomial.
Univariate polynomial over a generic coefficient ring.
Gen_Polynomial compose(const Gen_Polynomial &q) const
Composition .
size_t degree() const noexcept
Degree of the polynomial.
DynList< SfdTerm > factorize() const
Main factorization over integers.
std::pair< Gen_Polynomial, Gen_Polynomial > divmod(const Gen_Polynomial &d) const
Polynomial long division: returns (quotient, remainder).
Coefficient get_coeff(size_t exp) const noexcept
Coefficient accessor (read-only at exponent).
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_exp_function > > exp(const __gmp_expr< T, U > &expr)
Main namespace for Aleph-w library functions.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
Sparse multivariate polynomial over an arbitrary coefficient ring.
Univariate polynomial ring arithmetic over generic coefficients.