Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
multi_polynomial_examples.cc
Go to the documentation of this file.
1/*
2 This file is part of Aleph-w system.
3
4 Copyright (c) 2002-2026 Leandro Rabindranath Leon
5
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 THE SOFTWARE.
23*/
24
38#include <iostream>
39#include <iomanip>
40#include "tpl_array.H"
42
43using namespace std;
44using namespace Aleph;
45
46// Convenience typedefs for readable examples
52
53// Helper function to print section headers
54void print_section(const string& title) {
55 cout << "\n" << string(70, '=') << "\n";
56 cout << " " << title << "\n";
57 cout << string(70, '=') << "\n";
58}
59
60// Helper function to print example result
61void print_result(const string& label, const Multipoly& poly) {
62 cout << "\n" << label << ": " << poly.to_str() << "\n";
63}
64
65int main() {
66 cout << "\n" << string(70, '*') << "\n";
67 cout << "* Gen_MultiPolynomial Examples\n";
68 cout << "* Demonstrating multivariate polynomial operations\n";
69 cout << string(70, '*') << "\n";
70
71 // ========================================================================
72 // Example 1: Basic Construction and Variable Definition
73 // ========================================================================
74 print_section("Example 1: Basic Construction");
75
76 // Create polynomials in 2 variables
77 const size_t nvars = 2;
78 Multipoly x = Multipoly::variable(nvars, 0); // x is variable 0
79 Multipoly y = Multipoly::variable(nvars, 1); // y is variable 1
80
81 cout << "Variable x: " << x.to_str() << "\n";
82 cout << "Variable y: " << y.to_str() << "\n";
83
84 // Create a monomial: 3*x^2*y
85 Multipoly mon = Multipoly::monomial(nvars, {2, 1}, 3.0);
86 print_result("Monomial 3*x^2*y", mon);
87
88 // ========================================================================
89 // Example 2: Polynomial Arithmetic
90 // ========================================================================
91 print_section("Example 2: Polynomial Arithmetic");
92
93 // (x + 2)
94 Multipoly p1 = x + 2.0;
95 print_result("p1 = x + 2", p1);
96
97 // (y - 3)
98 Multipoly p2 = y - 3.0;
99 print_result("p2 = y - 3", p2);
100
101 // (x + 2) * (y - 3) = xy - 3x + 2y - 6
102 Multipoly product = p1 * p2;
103 print_result("(x + 2) * (y - 3)", product);
104
105 // ========================================================================
106 // Example 3: Algebraic Identities - Difference of Squares
107 // ========================================================================
108 print_section("Example 3: Algebraic Identity - (a² - b²) = (a+b)(a-b)");
109
110 // Create (x + y) and (x - y)
111 Multipoly sum = x + y;
112 Multipoly diff = x - y;
113
114 // Compute (x + y)(x - y) = x² - y²
116 print_result("(x + y)(x - y) expansion", identity1);
117
118 // Direct computation: x² - y²
119 Multipoly identity2 = x * x - y * y;
120 print_result("x² - y² direct", identity2);
121
122 cout << "\nAre they equal? " << (identity1 == identity2 ? "YES" : "NO") << "\n";
123
124 // ========================================================================
125 // Example 4: Binomial Expansion - (x + y)²
126 // ========================================================================
127 print_section("Example 4: Binomial Expansion - (x + y)²");
128
129 Multipoly binomial = x + y;
131 print_result("(x + y)² expansion", expanded);
132
133 // Manual form: x² + 2xy + y²
134 Multipoly manual = x*x + 2.0*x*y + y*y;
135 print_result("x² + 2xy + y² manual", manual);
136
137 cout << "\nAre they equal? " << (expanded == manual ? "YES" : "NO") << "\n";
138
139 // ========================================================================
140 // Example 5: Using Polynomial Powers
141 // ========================================================================
142 print_section("Example 5: Polynomial Powers");
143
144 Multipoly base = x + y;
145 Multipoly pow2 = base.pow(2);
146 Multipoly pow3 = base.pow(3);
147
148 print_result("(x + y)^2", pow2);
149 print_result("(x + y)^3", pow3);
150
151 // (x + y)³ = x³ + 3x²y + 3xy² + y³
152 cout << "\nVerification: (x + y)³ expands correctly\n";
153
154 // ========================================================================
155 // Example 6: Evaluation and Substitution
156 // ========================================================================
157 print_section("Example 6: Evaluation at Points");
158
159 // Define a polynomial: f(x,y) = x² + xy + y²
160 Multipoly f = x*x + x*y + y*y;
161 print_result("f(x,y) = x² + xy + y²", f);
162
163 // Evaluate at several points
164 Array<double> pt1{1.0, 2.0};
165 Array<double> pt2{2.0, 3.0};
166 Array<double> pt3{0.0, 0.0};
167
168 double val1 = f(pt1); // f(1,2) = 1 + 2 + 4 = 7
169 double val2 = f(pt2); // f(2,3) = 4 + 6 + 9 = 19
170 double val3 = f(pt3); // f(0,0) = 0
171
172 cout << "f(1, 2) = " << val1 << "\n";
173 cout << "f(2, 3) = " << val2 << "\n";
174 cout << "f(0, 0) = " << val3 << "\n";
175
176 // ========================================================================
177 // Example 7: Algebraic Application - Distance Function
178 // ========================================================================
179 print_section("Example 7: Algebraic Application - Distance Metric");
180
181 // In optimization, we often work with squared distance to avoid sqrt
182 // ||v||² = x² + y² (magnitude squared for vector (x,y))
183 Multipoly distance_sq = x*x + y*y;
184 print_result("||v||² = x² + y²", distance_sq);
185
186 // Shifted origin: distance squared from point (a,b) is (x-a)² + (y-b)²
187 Multipoly x_centered = x - 1.0;
188 Multipoly y_centered = y - 2.0;
191 print_result("Distance² from (1,2): (x-1)² + (y-2)²", distance_from_point);
192
193 // ========================================================================
194 // Example 8: Monomial Ordering Effects
195 // ========================================================================
196 print_section("Example 8: Monomial Ordering Effects");
197
198 // Create polynomials with mixed degree terms using initializer_list
199 // This demonstrates how different orderings rank the same monomials differently
201 {Array<size_t>{2, 1}, 1.0}, // x²y
202 {Array<size_t>{1, 2}, 1.0}, // xy²
203 {Array<size_t>{0, 3}, 1.0} // y³
204 });
205
207 {Array<size_t>{2, 1}, 1.0},
208 {Array<size_t>{1, 2}, 1.0},
209 {Array<size_t>{0, 3}, 1.0}
210 });
211
213 {Array<size_t>{2, 1}, 1.0},
214 {Array<size_t>{1, 2}, 1.0},
215 {Array<size_t>{0, 3}, 1.0}
216 });
217
218 cout << "Polynomial: x²y + xy² + y³\n\n";
219 cout << "Lex ordering (x before y): "
220 << poly_lex.to_str() << "\n";
221 cout << "Grlex ordering (total deg): "
222 << poly_grlex.to_str() << "\n";
223 cout << "Grevlex ordering (std CAS): "
224 << poly_grevlex.to_str() << "\n";
225 cout << "\nNote: The orderings determine term precedence in Gröbner basis\n"
226 << "algorithms and polynomial division. Lex is used for elimination,\n"
227 << "Grevlex is the standard CAS choice.\n";
228
229 // ========================================================================
230 // Example 9: Working with Three Variables
231 // ========================================================================
232 print_section("Example 9: Three Variable Polynomial");
233
234 const size_t n3 = 3;
238
239 // Sphere equation: x² + y² + z² - 1 = 0
240 // (stored as polynomial x² + y² + z² - 1)
241 Multipoly sphere = x3*x3 + y3*y3 + z3*z3 - 1.0;
242 print_result("Sphere: x² + y² + z² - 1", sphere);
243
244 // Evaluate on sphere at point (0.6, 0.8, 0)
245 // Should be close to 0
246 Array<double> sphere_pt{0.6, 0.8, 0.0};
247 double sphere_val = sphere(sphere_pt);
248 cout << "Evaluation at (0.6, 0.8, 0): " << sphere_val << "\n";
249 cout << "(Expected ~0 for points on sphere)\n";
250
251 // ========================================================================
252 // Example 10: Polynomial Properties and Introspection
253 // ========================================================================
254 print_section("Example 10: Polynomial Properties");
255
256 // Example polynomial: 2x²y + 3xy² + 5
257 Multipoly p = 2.0 * x * x * y + 3.0 * x * y * y + 5.0;
258 print_result("Polynomial p", p);
259
260 cout << "\nPolynomial properties:\n";
261 cout << " Number of variables: " << p.num_vars() << "\n";
262 cout << " Number of terms: " << p.num_terms() << "\n";
263 cout << " Total degree: " << p.degree() << "\n";
264 cout << " Degree in x: " << p.degree_in(0) << "\n";
265 cout << " Degree in y: " << p.degree_in(1) << "\n";
266 cout << " Is zero? " << (p.is_zero() ? "YES" : "NO") << "\n";
267 cout << " Is constant? " << (p.is_constant() ? "YES" : "NO") << "\n";
268 cout << " Leading coefficient: " << p.leading_coeff() << "\n";
269
270 // ========================================================================
271 // Example 11: Cancellation and Simplification
272 // ========================================================================
273 print_section("Example 11: Cancellation of Opposite Terms");
274
275 // Build p = (x + 1) - (x + 1) which should be zero
276 Multipoly q = x + 1.0;
277 Multipoly cancellation = q - q;
278
279 print_result("(x + 1) - (x + 1)", cancellation);
280 cout << "\nResulting polynomial is zero? "
281 << (cancellation.is_zero() ? "YES" : "NO") << "\n";
282
283 // ========================================================================
284 // Example 12: Scalar Operations
285 // ========================================================================
286 print_section("Example 12: Scalar Multiplication and Division");
287
288 Multipoly base_poly = x*x + y*y;
289 print_result("Base polynomial: x² + y²", base_poly);
290
291 Multipoly scaled = base_poly * 2.5;
292 print_result("2.5 * (x² + y²)", scaled);
293
294 Multipoly divided = scaled / 2.5;
295 print_result("Result / 2.5 (back to original)", divided);
296
297 cout << "\nAre they equal? "
298 << (divided == base_poly ? "YES" : "NO") << "\n";
299
300 // ========================================================================
301 // Example 13: Iteration Over Terms
302 // ========================================================================
303 print_section("Example 13: Iterating Over Terms");
304
305 Multipoly iter_poly = 2.0*x*x + 3.0*x*y + 5.0*y*y + 1.0;
306 print_result("Polynomial", iter_poly);
307
308 cout << "\nTerms in descending order (by monomial ordering):\n";
309 size_t term_count = 0;
310 iter_poly.for_each_term_desc([&term_count](const Array<size_t>& idx,
311 double coeff) {
312 cout << " Term " << (++term_count) << ": coeff=" << coeff << ", ";
313 cout << "exponents=[" << idx[0] << ", " << idx[1] << "]\n";
314 });
315
316 // ========================================================================
317 // Example 14: Building Complex Expressions
318 // ========================================================================
319 print_section("Example 14: Complex Algebraic Expressions");
320
321 // Build Rosenbrock-like expression: (1 - x)² + 100(y - x²)²
322 // Simplified multivariate version: (1 - x)² + (y - x²)²
323 Multipoly one_minus_x = 1.0 - x;
324 Multipoly y_minus_x2 = y - x*x;
325
328 print_result("(1-x)² + (y-x²)²", rosenbrock);
329
330 // Evaluate at the optimum (1, 1)
331 Array<double> optimum{1.0, 1.0};
333 cout << "\nEvaluation at optimum (1, 1): " << val_at_optimum << "\n";
334
335 // ========================================================================
336 // Example 15: Relationship with Univariate Polynomials
337 // ========================================================================
338 print_section("Example 15: Univariate as Special Case");
339
340 // A multivariate polynomial in 1 variable behaves like univariate
341 const size_t n_uni = 1;
343
344 // Build x² + 2x + 1 = (x + 1)²
345 Multipoly uni_expr = uni_poly * uni_poly + 2.0 * uni_poly + 1.0;
346 print_result("Single variable: x² + 2x + 1", uni_expr);
347
348 // Evaluate
350 double uni_val = uni_expr(uni_pt);
351 cout << "Evaluation at x=3: " << uni_val << "\n";
352 cout << "(Expected: 9 + 6 + 1 = 16)\n";
353
354 // ========================================================================
355 // Example 16: Constant and Zero Polynomials
356 // ========================================================================
357 print_section("Example 16: Special Polynomials");
358
360 Multipoly const_poly = Multipoly(2, 42.0);
362
363 print_result("Zero polynomial", zero_poly);
364 print_result("Constant 42", const_poly);
365 print_result("Constant 1 (42/42)", one_poly);
366
367 cout << "\nzero_poly.is_zero() = " << (zero_poly.is_zero() ? "true" : "false") << "\n";
368 cout << "const_poly.is_constant() = " << (const_poly.is_constant() ? "true" : "false") << "\n";
369 cout << "one_poly.is_constant() = " << (one_poly.is_constant() ? "true" : "false") << "\n";
370
371 // ========================================================================
372 // Example 17: Gröbner Basis and Ideal Membership
373 // ========================================================================
374 print_section("Example 17: Groebner Basis and Ideal Membership");
375
378
380 gens(0) = xlex * xlex - ylex;
381 gens(1) = xlex * ylex - 1.0;
382
385
386 cout << "Generators:\n";
387 cout << " g1 = " << gens(0).to_str() << "\n";
388 cout << " g2 = " << gens(1).to_str() << "\n";
389 cout << "\nAutoreduced Groebner basis (Lex):\n";
390 for (size_t i = 0; i < gb_raw.size(); ++i)
391 cout << " H[" << i << "] = " << gb_raw(i).to_str() << "\n";
392 cout << "\nReduced Groebner basis (Lex):\n";
393 for (size_t i = 0; i < gb.size(); ++i)
394 cout << " G[" << i << "] = " << gb(i).to_str() << "\n";
395
398
399 cout << "\nNormal form of x^2*y - x: " << member.reduce_modulo(gb).to_str() << "\n";
400 cout << "ideal_member(x^2*y - x) = "
401 << (Multipoly_Lex::ideal_member(member, gens) ? "true" : "false") << "\n";
402 cout << "ideal_member(x + y) = "
403 << (Multipoly_Lex::ideal_member(not_member, gens) ? "true" : "false") << "\n";
404
405 // ========================================================================
406 // Example 18: Integer Factorization in an Ambient Multivariate Ring
407 // ========================================================================
408 print_section("Example 18: Integer Factorization with Inactive Variables");
409
412 (void) yi; // Explicitly keep the ambient ring at 2 variables.
413
414 IntMultipoly split = xi * xi - IntMultipoly(2, 1LL);
415 auto split_factors = split.factorize();
416
417 cout << "Factorization of x^2 - 1 in Z[x,y]:\n";
418 for (auto it = split_factors.get_it(); it.has_curr(); it.next_ne())
419 cout << " factor = " << it.get_curr().factor.to_str()
420 << ", multiplicity = " << it.get_curr().multiplicity << "\n";
421
422 IntMultipoly repeated = xi * xi + 2LL * xi + IntMultipoly(2, 1LL);
423 auto repeated_factors = repeated.factorize();
424
425 cout << "\nFactorization of (x + 1)^2 in Z[x,y]:\n";
426 for (auto it = repeated_factors.get_it(); it.has_curr(); it.next_ne())
427 cout << " factor = " << it.get_curr().factor.to_str()
428 << ", multiplicity = " << it.get_curr().multiplicity << "\n";
429
430 IntMultipoly diff_sq = xi * xi - yi * yi;
432
433 cout << "\nFactorization of x^2 - y^2 in Z[x,y]:\n";
434 for (auto it = diff_sq_factors.get_it(); it.has_curr(); it.next_ne())
435 cout << " factor = " << it.get_curr().factor.to_str()
436 << ", multiplicity = " << it.get_curr().multiplicity << "\n";
437
438 auto scaled_diff_sq_factors = (-6LL * diff_sq).factorize();
439
440 cout << "\nFactorization of -6*(x^2 - y^2) in Z[x,y]:\n";
441 for (auto it = scaled_diff_sq_factors.get_it(); it.has_curr(); it.next_ne())
442 cout << " factor = " << it.get_curr().factor.to_str()
443 << ", multiplicity = " << it.get_curr().multiplicity << "\n";
444
445 IntMultipoly embedded_univariate = 6LL * (xi * xi - IntMultipoly(2, 1LL));
447
448 cout << "\nFactorization of 6*(x^2 - 1) viewed in Z[x,y]:\n";
449 for (auto it = embedded_univariate_factors.get_it(); it.has_curr(); it.next_ne())
450 cout << " factor = " << it.get_curr().factor.to_str()
451 << ", multiplicity = " << it.get_curr().multiplicity << "\n";
452
453 IntMultipoly non_monic_affine_f1 = 2LL * xi + 3LL * yi + IntMultipoly(2, 1LL);
454 IntMultipoly non_monic_affine_f2 = 4LL * xi + 5LL * yi + IntMultipoly(2, 2LL);
456
457 cout << "\nFactorization of (2*x + 3*y + 1)(4*x + 5*y + 2) in Z[x,y]:\n";
458 for (auto it = non_monic_affine_factors.get_it(); it.has_curr(); it.next_ne())
459 cout << " factor = " << it.get_curr().factor.to_str()
460 << ", multiplicity = " << it.get_curr().multiplicity << "\n";
461
462 IntMultipoly non_monic_same_degree_f1 = 2LL * xi * xi + 3LL * yi + IntMultipoly(2, 1LL);
463 IntMultipoly non_monic_same_degree_f2 = 3LL * xi * xi + 5LL * yi + IntMultipoly(2, 2LL);
466
467 cout << "\nFactorization of (2*x^2 + 3*y + 1)(3*x^2 + 5*y + 2) in Z[x,y]:\n";
468 for (auto it = non_monic_same_degree_factors.get_it(); it.has_curr(); it.next_ne())
469 cout << " factor = " << it.get_curr().factor.to_str()
470 << ", multiplicity = " << it.get_curr().multiplicity << "\n";
471
474 auto nonlinear_factors = (nonlinear_f1 * nonlinear_f2).factorize();
475
476 cout << "\nFactorization of (x^2 + y + 1)(x + y^2 + 2) in Z[x,y]:\n";
477 for (auto it = nonlinear_factors.get_it(); it.has_curr(); it.next_ne())
478 cout << " factor = " << it.get_curr().factor.to_str()
479 << ", multiplicity = " << it.get_curr().multiplicity << "\n";
480
481 IntMultipoly same_degree_f1 = xi * xi + 2LL * yi + IntMultipoly(2, 1LL);
482 IntMultipoly same_degree_f2 = xi * xi + 2LL * yi + IntMultipoly(2, 3LL);
484
485 cout << "\nFactorization of (x^2 + 2*y + 1)(x^2 + 2*y + 3) in Z[x,y]:\n";
486 for (auto it = same_degree_factors.get_it(); it.has_curr(); it.next_ne())
487 cout << " factor = " << it.get_curr().factor.to_str()
488 << ", multiplicity = " << it.get_curr().multiplicity << "\n";
489
490 IntMultipoly cubic_same_degree_f1 = xi * xi * xi + xi + 2LL * yi + IntMultipoly(2, 1LL);
491 IntMultipoly cubic_same_degree_f2 = xi * xi * xi + xi + 2LL * yi + IntMultipoly(2, 3LL);
493
494 cout << "\nFactorization of (x^3 + x + 2*y + 1)(x^3 + x + 2*y + 3) in Z[x,y]:\n";
495 for (auto it = cubic_same_degree_factors.get_it(); it.has_curr(); it.next_ne())
496 cout << " factor = " << it.get_curr().factor.to_str()
497 << ", multiplicity = " << it.get_curr().multiplicity << "\n";
498
499 // ========================================================================
500 // Summary
501 // ========================================================================
502 print_section("Summary");
503
504 cout << "\nGen_MultiPolynomial supports:\n"
505 << " • Construction via variables, monomials, and initializer lists\n"
506 << " • Full arithmetic: +, -, *, scalar /, powers\n"
507 << " • Evaluation at points (Array<Coefficient>)\n"
508 << " • Degree queries and term inspection\n"
509 << " • Three monomial orderings (Lex, Grlex, Grevlex)\n"
510 << " • Promotion to higher variable counts\n"
511 << " • Groebner bases, ideal membership, and normal forms\n"
512 << " • Pretty-printing with automatic variable names\n"
513 << "\nUse cases:\n"
514 << " • Algebraic computation and symbolic manipulation\n"
515 << " • Polynomial interpolation and least-squares fitting\n"
516 << " • Optimization (Rosenbrock, quadratic forms)\n"
517 << " • Foundation for Gröbner bases and factorization\n";
518
519 cout << "\n" << string(70, '*') << "\n";
520 cout << "* End of Examples\n";
521 cout << string(70, '*') << "\n\n";
522
523 return 0;
524}
Simple dynamic array with automatic resizing and functional operations.
Definition tpl_array.H:139
Sparse multivariate polynomial.
static Array< Gen_MultiPolynomial > reduced_groebner_basis(const Array< Gen_MultiPolynomial > &generators)
Reduced Gröbner basis (minimized and normalized).
Gen_MultiPolynomial reduce_modulo(const Array< Gen_MultiPolynomial > &divisors) const
Polynomial reduction modulo an ideal (one-liner).
size_t degree_in(size_t var) const noexcept
Degree in a specific variable.
DynList< FactorTerm > factorize() const
Main multivariate factorization over the integers.
bool is_constant() const noexcept
True if constant or zero (total degree 0).
std::string to_str(const DynList< std::string > &names=DynList< std::string >()) const
Human-readable string.
static Gen_MultiPolynomial monomial(size_t nvars, const Array< size_t > &idx, const Coefficient &c=Coefficient(1))
A single monomial .
size_t num_terms() const noexcept
Number of non-zero terms.
bool is_zero() const noexcept
True if this is the zero polynomial.
Coefficient leading_coeff() const
Leading coefficient.
static Gen_MultiPolynomial variable(size_t nvars, const size_t var)
The polynomial (a single variable).
static Array< Gen_MultiPolynomial > groebner_basis(const Array< Gen_MultiPolynomial > &generators)
Gröbner basis computation via Buchberger's algorithm.
size_t num_vars() const noexcept
Number of variables.
Gen_MultiPolynomial pow(size_t n) const
Exponentiation by repeated squaring.
static bool ideal_member(const Gen_MultiPolynomial &f, const Array< Gen_MultiPolynomial > &generators)
Test membership in an ideal via Gröbner basis.
size_t degree() const noexcept
Total degree (maximum sum of exponents over all terms).
static mpfr_t y
Definition mpfr_mul_d.c:3
Gen_MultiPolynomial< long long > IntMultipoly
void print_result(const string &label, const Multipoly &poly)
void print_section(const string &title)
Gen_MultiPolynomial< double, Lex_Order > Multipoly_Lex
Gen_MultiPolynomial< double > Multipoly
Main namespace for Aleph-w library functions.
Definition ah-arena.H:89
DynList< T > repeated(const Container< T > &c)
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.
T product(const Container &container, const T &init=T{1})
Compute product of all elements.
bool diff(const C1 &c1, const C2 &c2, Eq e=Eq())
Check if two containers differ.
double pow2(const double x)
Return x^2.
Definition ahUtils.H:382
std::vector< std::string > & split(const std::string &s, const char delim, std::vector< std::string > &elems)
Split a std::string by a single delimiter character.
double pow3(const double x)
Return x^3.
Definition ahUtils.H:387
T sum(const Container &container, const T &init=T{})
Compute sum of all elements.
STL namespace.
Dynamic array container with automatic resizing.
Sparse multivariate polynomial over an arbitrary coefficient ring.