Bertini 2 d882924 (2026-10-06 19:56 UTC)
Numerical algebraic geometry library (C++ core)
Loading...
Searching...
No Matches
bertini::blocks::PolynomialBlock Class Reference

The polynomial evaluation block: function trees + derivatives + SLP. More...

#include <polynomial_block.hpp>

Public Types

using NE = std::shared_ptr<node::NamedExpression>
 Shorthand for a shared pointer to a named expression.
using Nd = std::shared_ptr<node::Node>
 Shorthand for a shared pointer to a generic node.
using Var = std::shared_ptr<node::Variable>
 Shorthand for a shared pointer to a variable node.

Public Member Functions

 PolynomialBlock ()
 Construct an empty polynomial block at the current default precision.
void AddFunction (Nd const &f)
 Add a function (one row of the block).
void AddConstant (NE const &f)
 Add a named constant subfunction.
void SetVariableOrdering (VariableGroup const &vars) const
 The variable ordering + path variable the function trees are evaluated against; the owning System keeps these in sync (they change as variable groups are added / the system is homogenized).
void SetPathVariable (Var const &t) const
 Set the path variable the function trees are evaluated against.
void ClearPathVariable () const
 Clear the path variable.
std::vector< Nd > & Functions ()
 Get mutable access to the block's functions.
std::vector< Nd > const & Functions () const
 Get const access to the block's functions.
std::vector< NE > const & ConstantSubfunctions () const
 Get the block's constant subfunctions.
size_t NumConstants () const
 Get the number of constant subfunctions.
bool IsDifferentiated () const
 Query whether the block's derivatives have been computed.
void Invalidate () const
 Mark the block's derivatives as stale (to be recomputed on next use).
std::vector< int > Degrees () const
 Per-function degrees (total, and with respect to a variable group).
std::vector< int > Degrees (VariableGroup const &vars) const
 Per-function degrees with respect to a given variable group.
void Homogenize (VariableGroup const &group, Var const &hom_var)
 Homogenize each function w.r.t.
bool IsHomogeneous (VariableGroup const &vars) const
 Query whether every function is homogeneous with respect to a variable group.
bool IsPolynomial (VariableGroup const &vars) const
 Query whether every function is polynomial in a variable group.
size_t NumFunctions () const
 Get the number of functions in the block.
bool DependsOnPathVariable () const
 Query whether the block depends on the path variable.
void Describe (std::ostream &out, size_t &row, VariableGroup const &, bool) const
 Human-facing description: one line per function, f_k = <expression>.
unsigned Precision () const
 Get the block's current working precision.
void Precision (unsigned new_precision) const
 Set the block's working precision (delegated to the compiled SLP).
template<typename T>
void EvalInPlace (Eigen::Ref< Vec< T > > result, Vec< T > const &vars, T const &path_value) const
 Evaluate the block's functions in place at the given variable and path-variable values.
template<typename T>
void JacobianInPlace (Eigen::Ref< Mat< T > > J, Vec< T > const &vars, T const &path_value) const
 Evaluate the block's Jacobian in place at the given variable and path-variable values.
template<typename T>
void TimeDerivInPlace (Eigen::Ref< Vec< T > > result, Vec< T > const &vars, T const &path_value) const
 Evaluate the block's time derivative in place (zero if there is no path variable).
VariableGroup const & VariableOrdering () const
 Get the variable ordering the functions are evaluated against.
bool HavePathVariable () const
 Query whether the block has a path variable.
Var GetPathVariable () const
 Get the block's path variable (may be null).
size_t NumNaturalFunctions () const
 Get the number of natural (pre-randomization) functions.
std::vector< Nd > const & GetNaturalFunctions () const
 Get the block's natural function trees.
std::vector< Nd > const & GetSpaceDerivatives () const
 Get the per-variable space-derivative trees (computing them if needed).
std::vector< Nd > const & GetTimeDerivatives () const
 Get the time-derivative trees (computing them if needed).
void Differentiate () const
 Build the symbolic derivatives (and, for SLP eval, compile the SLP from this block).
void SimplifyFunctions () const
 Simplify the function trees (and invalidate the derivatives, which must be rebuilt).
void SimplifyDerivatives () const
 Simplify the derivative trees.
void Reintern (node::ReinternMemo &memo)
 Re-intern this block's nodes after deserialization (ADR-0042): functions, constant subfunctions, variable ordering, and path variable are rebuilt through the live intern tables via the shared memo; the derivative/SLP caches (which reference the old nodes) are dropped and recompute on demand.

Friends

class boost::serialization::access

Detailed Description

The polynomial evaluation block: function trees + derivatives + SLP.

Member Typedef Documentation

◆ Nd

Shorthand for a shared pointer to a generic node.

◆ NE

Shorthand for a shared pointer to a named expression.

◆ Var

Shorthand for a shared pointer to a variable node.

Constructor & Destructor Documentation

◆ PolynomialBlock()

bertini::blocks::PolynomialBlock::PolynomialBlock ( )
inline

Construct an empty polynomial block at the current default precision.

Member Function Documentation

◆ AddConstant()

void bertini::blocks::PolynomialBlock::AddConstant ( NE const & f)
inline

Add a named constant subfunction.

◆ AddFunction()

void bertini::blocks::PolynomialBlock::AddFunction ( Nd const & f)
inline

Add a function (one row of the block).

◆ ClearPathVariable()

void bertini::blocks::PolynomialBlock::ClearPathVariable ( ) const
inline

Clear the path variable.

◆ ConstantSubfunctions()

std::vector< NE > const & bertini::blocks::PolynomialBlock::ConstantSubfunctions ( ) const
inline

Get the block's constant subfunctions.

◆ Degrees() [1/2]

std::vector< int > bertini::blocks::PolynomialBlock::Degrees ( ) const
inline

Per-function degrees (total, and with respect to a variable group).

◆ Degrees() [2/2]

std::vector< int > bertini::blocks::PolynomialBlock::Degrees ( VariableGroup const & vars) const
inline

Per-function degrees with respect to a given variable group.

◆ DependsOnPathVariable()

bool bertini::blocks::PolynomialBlock::DependsOnPathVariable ( ) const
inline

Query whether the block depends on the path variable.

◆ Describe()

void bertini::blocks::PolynomialBlock::Describe ( std::ostream & out,
size_t & row,
VariableGroup const & ,
bool  ) const
inline

Human-facing description: one line per function, f_k = <expression>.

Polynomials are the content, so terse and verbose are the same (the expression is shown either way).

◆ Differentiate()

void bertini::blocks::PolynomialBlock::Differentiate ( ) const
inline

Build the symbolic derivatives (and, for SLP eval, compile the SLP from this block).

Derivatives are NOT simplified here; explicit simplification is System::Simplify (SimplifyDerivatives), an opt-in the user invokes.

◆ EvalInPlace()

template<typename T>
void bertini::blocks::PolynomialBlock::EvalInPlace ( Eigen::Ref< Vec< T > > result,
Vec< T > const & vars,
T const & path_value ) const
inline

Evaluate the block's functions in place at the given variable and path-variable values.

◆ Functions() [1/2]

std::vector< Nd > & bertini::blocks::PolynomialBlock::Functions ( )
inline

Get mutable access to the block's functions.

◆ Functions() [2/2]

std::vector< Nd > const & bertini::blocks::PolynomialBlock::Functions ( ) const
inline

Get const access to the block's functions.

◆ GetNaturalFunctions()

std::vector< Nd > const & bertini::blocks::PolynomialBlock::GetNaturalFunctions ( ) const
inline

Get the block's natural function trees.

◆ GetPathVariable()

Var bertini::blocks::PolynomialBlock::GetPathVariable ( ) const
inline

Get the block's path variable (may be null).

◆ GetSpaceDerivatives()

std::vector< Nd > const & bertini::blocks::PolynomialBlock::GetSpaceDerivatives ( ) const
inline

Get the per-variable space-derivative trees (computing them if needed).

◆ GetTimeDerivatives()

std::vector< Nd > const & bertini::blocks::PolynomialBlock::GetTimeDerivatives ( ) const
inline

Get the time-derivative trees (computing them if needed).

◆ HavePathVariable()

bool bertini::blocks::PolynomialBlock::HavePathVariable ( ) const
inline

Query whether the block has a path variable.

◆ Homogenize()

void bertini::blocks::PolynomialBlock::Homogenize ( VariableGroup const & group,
Var const & hom_var )
inline

Homogenize each function w.r.t.

the group + its homogenizing var, functionally: each function is rebound to a freshly homogenized copy, so any external holder of the original function node never observes it change (shared variables are preserved).

◆ Invalidate()

void bertini::blocks::PolynomialBlock::Invalidate ( ) const
inline

Mark the block's derivatives as stale (to be recomputed on next use).

◆ IsDifferentiated()

bool bertini::blocks::PolynomialBlock::IsDifferentiated ( ) const
inline

Query whether the block's derivatives have been computed.

◆ IsHomogeneous()

bool bertini::blocks::PolynomialBlock::IsHomogeneous ( VariableGroup const & vars) const
inline

Query whether every function is homogeneous with respect to a variable group.

◆ IsPolynomial()

bool bertini::blocks::PolynomialBlock::IsPolynomial ( VariableGroup const & vars) const
inline

Query whether every function is polynomial in a variable group.

◆ JacobianInPlace()

template<typename T>
void bertini::blocks::PolynomialBlock::JacobianInPlace ( Eigen::Ref< Mat< T > > J,
Vec< T > const & vars,
T const & path_value ) const
inline

Evaluate the block's Jacobian in place at the given variable and path-variable values.

◆ NumConstants()

size_t bertini::blocks::PolynomialBlock::NumConstants ( ) const
inline

Get the number of constant subfunctions.

◆ NumFunctions()

size_t bertini::blocks::PolynomialBlock::NumFunctions ( ) const
inline

Get the number of functions in the block.

◆ NumNaturalFunctions()

size_t bertini::blocks::PolynomialBlock::NumNaturalFunctions ( ) const
inline

Get the number of natural (pre-randomization) functions.

◆ Precision() [1/2]

unsigned bertini::blocks::PolynomialBlock::Precision ( ) const
inline

Get the block's current working precision.

◆ Precision() [2/2]

void bertini::blocks::PolynomialBlock::Precision ( unsigned new_precision) const
inline

Set the block's working precision (delegated to the compiled SLP).

◆ Reintern()

void bertini::blocks::PolynomialBlock::Reintern ( node::ReinternMemo & memo)
inline

Re-intern this block's nodes after deserialization (ADR-0042): functions, constant subfunctions, variable ordering, and path variable are rebuilt through the live intern tables via the shared memo; the derivative/SLP caches (which reference the old nodes) are dropped and recompute on demand.

Content is unchanged.

◆ SetPathVariable()

void bertini::blocks::PolynomialBlock::SetPathVariable ( Var const & t) const
inline

Set the path variable the function trees are evaluated against.

◆ SetVariableOrdering()

void bertini::blocks::PolynomialBlock::SetVariableOrdering ( VariableGroup const & vars) const
inline

The variable ordering + path variable the function trees are evaluated against; the owning System keeps these in sync (they change as variable groups are added / the system is homogenized).

◆ SimplifyDerivatives()

void bertini::blocks::PolynomialBlock::SimplifyDerivatives ( ) const
inline

Simplify the derivative trees.

Simplification is functional and purely structural (Node::Simplified, ADR-0011), so it needs no point and no node evaluation. Requires the derivatives to already exist.

◆ SimplifyFunctions()

void bertini::blocks::PolynomialBlock::SimplifyFunctions ( ) const
inline

Simplify the function trees (and invalidate the derivatives, which must be rebuilt).

◆ TimeDerivInPlace()

template<typename T>
void bertini::blocks::PolynomialBlock::TimeDerivInPlace ( Eigen::Ref< Vec< T > > result,
Vec< T > const & vars,
T const & path_value ) const
inline

Evaluate the block's time derivative in place (zero if there is no path variable).

◆ VariableOrdering()

VariableGroup const & bertini::blocks::PolynomialBlock::VariableOrdering ( ) const
inline

Get the variable ordering the functions are evaluated against.

◆ boost::serialization::access

friend class boost::serialization::access
friend