Aerobus v1.2
Loading...
Searching...
No Matches
examples/make_polynomial.cpp

How to build your own sequence of known polynomials, here Abel polynomials

#include <iostream>
#include "../src/aerobus.h"
// let's build Abel polynomials from scratch using Aerobus
// note : it's now integrated in the main library, but still serves as an example
template<typename I = aerobus::i64>
struct AbelHelper {
private:
public:
// to keep recursion working, we need to operate on a*n and not just a
template<size_t deg, I::inner_type an>
struct Inner {
// abel(n, a) = (x-an) * abel(n-1, a)
using type = typename aerobus::mul_t<
typename Inner<deg-1, an>::type,
>;
};
// abel(0, a) = 1
template<I::inner_type an>
struct Inner<0, an> {
using type = P::one;
};
// abel(1, a) = X
template<I::inner_type an>
struct Inner<1, an> {
using type = P::X;
};
};
template<size_t n, auto a, typename I = aerobus::i64>
using AbelPolynomials = typename AbelHelper<I>::template Inner<n, a*n>::type;
using A2_3 = AbelPolynomials<3, 2>;
int main() {
std::cout << "expected = x^3 - 12 x^2 + 36 x" << std::endl;
std::cout << "aerobus = " << A2_3::to_string() << std::endl;
return 0;
}
typename X::enclosing_type::template mul_t< X, Y > mul_t
generic multiplication
Definition aerobus.h:2914
typename X::enclosing_type::template sub_t< X, Y > sub_t
generic subtraction
Definition aerobus.h:2906
Definition aerobus.h:1807