Dedekind 0.0.0
A structuralist C++23 Module Library
Loading...
Searching...
No Matches
dedekind::algebra::Polynomial< R, M > Class Template Referenceexport

The monoid algebra R[M]: a finitely supported function from the monomials to the coefficients, stored as its support sorted along the monomials' chain, no coefficient zero. A net (Domain the monomials, Codomain the coefficients, p(m) the coefficient of m), a commutative rig over a commutative rig, a ring over a ring (- where R has additive inverses). More...

Public Types

using coefficient_type = R
using monomial_type = M
using Domain = M
using Codomain = R
using term_type = std::pair<M, R>

Public Member Functions

constexpr Polynomial ()=default
 The zero polynomial.
constexpr Polynomial (R scalar)
 A constant.
constexpr Polynomial (std::vector< term_type > terms)
 The sum of the given terms, in any order: combined, sorted, zero coefficients dropped.
constexpr R operator() (const M &m) const
 The net: the coefficient of m, zero off the support.
constexpr const std::vector< term_type > & support () const noexcept
 The support with its coefficients: the finite function this polynomial is, sorted along the monomials' chain.
constexpr bool is_zero () const
constexpr auto degree () const
 The total degree of the leading monomial; 0 for the zero polynomial.
constexpr const R & leading_coefficient () const
constexpr Polynomial derive (std::size_t slot=0) const
 The formal partial derivative by the variable of slot: ∂(c·m) = e·c·m/π, the factor e by repeated doubling, so no more than R's addition is asked (a rig suffices).

Static Public Member Functions

static constexpr Polynomial zero ()
static constexpr Polynomial one ()
static constexpr Polynomial variable (std::size_t slot)
 The variable of slot, as a polynomial.

Friends

constexpr bool operator== (const Polynomial &, const Polynomial &)=default
constexpr Polynomial operator+ (const Polynomial &a, const Polynomial &b)
 Pointwise: the merge of two sorted supports.
constexpr Polynomial operator- (const Polynomial &a)
 Coefficientwise additive inverse, where R has one.
constexpr Polynomial operator- (const Polynomial &a, const Polynomial &b)
constexpr Polynomial inverse (const Polynomial &a, std::plus< Polynomial >)
 The additive inverse under the category's inverse_v bridge, so is_invertible_v<Polynomial, std::plus<Polynomial>> follows from R's.
constexpr Polynomial operator* (const Polynomial &a, const Polynomial &b)
 The convolution: every pair of terms multiplied, then combined.

Detailed Description

template<typename R, typename M = Monomial<1>>
requires std::equality_comparable<R> && dedekind::category::IsCommutativeMonoid<M, std::multiplies<M>> && dedekind::order::IsTotallyOrdered<M>
class dedekind::algebra::Polynomial< R, M >

The monoid algebra R[M]: a finitely supported function from the monomials to the coefficients, stored as its support sorted along the monomials' chain, no coefficient zero. A net (Domain the monomials, Codomain the coefficients, p(m) the coefficient of m), a commutative rig over a commutative rig, a ring over a ring (- where R has additive inverses).

Template Parameters
Rthe coefficients.
Mthe monomials: a commutative monoid that is a chain.

Constructor & Destructor Documentation

◆ Polynomial()

template<typename R, typename M = Monomial<1>>
dedekind::algebra::Polynomial< R, M >::Polynomial ( std::vector< term_type > terms)
inlineexplicitconstexpr

The sum of the given terms, in any order: combined, sorted, zero coefficients dropped.

Parameters
termsmonomial and coefficient pairs.

Member Function Documentation

◆ leading_coefficient()

template<typename R, typename M = Monomial<1>>
const R & dedekind::algebra::Polynomial< R, M >::leading_coefficient ( ) const
inlineconstexpr
Exceptions
std::domain_erroron the zero polynomial.

The documentation for this class was generated from the following file: