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

An affine chart on a product of projective spaces. More...

#include <patch.hpp>

Public Member Functions

 Patch ()
 Default constructor.
 Patch (Patch const &other)
 Custom copy constructor, ensuring the max-precision coefficients are copied in highest precision.
Patch & operator= (Patch const &other)=default
 Copy assignment.
 Patch (std::vector< unsigned > const &sizes)
 Constructor making a random complex patch on a space whose structure is described by the input argument.
 Patch (std::vector< unsigned > const &sizes, std::vector< Vec< complex_mp > > const &coefficients)
 Construct a patch from given coefficients – for a loader restoring an archived patch exactly (the canonical-encoding reader), never for making a fresh one (use Random).
unsigned Precision () const
 Get the current precision of the patch.
template<typename T>
void SyncPrecision (Vec< T > const &x) const
 Materialize the working coefficients at the precision of the point being evaluated.
void Precision (unsigned new_precision) const
 Set the precision of the patch.
template<typename Derived, typename T>
void EvalInPlace (Eigen::MatrixBase< Derived > &function_values, Vec< T > const &x) const
 Evaluate the patch at a point, in place.
template<typename T>
Vec< T > Eval (Vec< T > const &x) const
 Evaluate the patch at a point.
template<typename Derived, typename T>
void JacobianInPlace (Eigen::MatrixBase< Derived > &jacobian, Vec< T > const &x) const
 Evaluate the Jacobian matrix, in place.
template<typename T>
Mat< T > Jacobian (Vec< T > const &x) const
 Evaluate the Jacobian matrix, in place.
template<typename T>
void RescalePointToFitInPlace (Vec< T > &x) const
 Rescale a point so that it satisfies the patch equations herein contained.
template<typename T>
Vec< T > RescalePoint (Vec< T > const &x) const
 Rescale a point so that it satisfies the patch equations herein contained.
unsigned NumVariableGroups () const
 Get the number of variable groups.
unsigned NumVariables () const
 Get the number of variables in the patch.
std::vector< Vec< complex_mp > > const & Coefficients () const
 The patch's highest-precision coefficients, one vector per variable group.
std::vector< unsigned > const & VariableGroupSizes () const
 The number of variables in each variable group (homogenizing variable included).
bool operator== (Patch const &rhs) const
 Check whether two patches are the same.
bool operator!= (Patch const &rhs) const
 Check whether two patches are different.

Static Public Member Functions

static Patch Random (std::vector< unsigned > const &sizes)
 Construct a random complex patch on a space.
static Patch RandomReal (std::vector< unsigned > const &sizes)
 Construct random REAL patch on a space.

Friends

class boost::serialization::access
std::ostream & operator<< (std::ostream &out, Patch const &p)
 Stream-insertion for a Patch, summarizing its variable groups and coefficients.

Detailed Description

An affine chart on a product of projective spaces.

This class provides an adjustable-precision patch on a working space for solving a polynomial system using homotopy continuation.

The constant values for the patch are unity.

Example code, not using a bertini::System to generate the patch.

std::vector<unsigned> s{2,3};
Patch p(s);
auto v_rescaled = p.RescalePoint(v);
auto f = p.Eval(v_rescaled);
An affine chart on a product of projective spaces.
Definition patch.hpp:85
Eigen::Matrix< NumT, Eigen::Dynamic, 1 > Vec
A dynamically-sized column vector of NumT.
Definition eigen_extensions.hpp:296
bmp::number< mpc_complex_backend< 0 >, bmp::et_on > complex_mp
The arbitrary-precision complex number type.
Definition mpfr_complex.hpp:58

At the end of the above example, the patch evaluates to 0 in the container $f$.

Other ways of patching

Patches can also be applied to a system, which should first be homogenized.

Constructor & Destructor Documentation

◆ Patch() [1/4]

bertini::Patch::Patch ( )
inline

Default constructor.

Makes an empty patch.

◆ Patch() [2/4]

bertini::Patch::Patch ( Patch const & other)
inline

Custom copy constructor, ensuring the max-precision coefficients are copied in highest precision.

◆ Patch() [3/4]

bertini::Patch::Patch ( std::vector< unsigned > const & sizes)
inline

Constructor making a random complex patch on a space whose structure is described by the input argument.

The sizes input give the number of total variables, including homogenizing variables, for the product of spaces forming the total space to be patched. The patch has no idea whether the underlying space is projective or affine – that is handled somewhere else, likely in a bertini::System.

The initial precision of the patch is set to current default precision, and the precision of the highest precision coefficients are set to the current default as well.

Parameters
sizesThe sizes of the variable groups, including homogenizing variables if present.

◆ Patch() [4/4]

bertini::Patch::Patch ( std::vector< unsigned > const & sizes,
std::vector< Vec< complex_mp > > const & coefficients )
inline

Construct a patch from given coefficients – for a loader restoring an archived patch exactly (the canonical-encoding reader), never for making a fresh one (use Random).

Parameters
sizesThe sizes of the variable groups, including homogenizing variables.
coefficientsOne coefficient vector per group, each of that group's size; every entry is kept at its own precision.

Member Function Documentation

◆ Coefficients()

std::vector< Vec< complex_mp > > const & bertini::Patch::Coefficients ( ) const
inline

The patch's highest-precision coefficients, one vector per variable group.

Coefficient Coefficients()[ii](jj) multiplies the jj-th variable of group ii (in the system's variable ordering). The patch function for group ii is sum_jj Coefficients()[ii](jj) * x_jj - 1, so these are exactly the constant entries of the patch's (symbolic) Jacobian rows.

◆ Eval()

template<typename T>
Vec< T > bertini::Patch::Eval ( Vec< T > const & x) const
inline

Evaluate the patch at a point.

Returns
The values of the patch at the point.
Parameters
xThe current space point at which to evaluate.

◆ EvalInPlace()

template<typename Derived, typename T>
void bertini::Patch::EvalInPlace ( Eigen::MatrixBase< Derived > & function_values,
Vec< T > const & x ) const
inline

Evaluate the patch at a point, in place.

Parameters
function_valuesThe vector to populate. Must be at least as long as the number of variable groups.
xThe current space point at which to evaluate.

◆ Jacobian()

template<typename T>
Mat< T > bertini::Patch::Jacobian ( Vec< T > const & x) const
inline

Evaluate the Jacobian matrix, in place.

Parameters
xPoint at which to evaluate. Not technically needed, because the Jacobian is simply the matrix of coefficients.
Returns
Jacobian matrix, of size (NumVariableGroups x NumVariables).

◆ JacobianInPlace()

template<typename Derived, typename T>
void bertini::Patch::JacobianInPlace ( Eigen::MatrixBase< Derived > & jacobian,
Vec< T > const & x ) const
inline

Evaluate the Jacobian matrix, in place.

Parameters
jacobianMatrix to populate with the Jacobian. Must be large enough (NumVariableGroups x NumVariables).
xPoint at which to evaluate. Not technically needed, because the Jacobian is simply the matrix of coefficients.

◆ NumVariableGroups()

unsigned bertini::Patch::NumVariableGroups ( ) const
inline

Get the number of variable groups.

Returns
The number of variable groups in the problem.

◆ NumVariables()

unsigned bertini::Patch::NumVariables ( ) const
inline

Get the number of variables in the patch.

◆ operator!=()

bool bertini::Patch::operator!= ( Patch const & rhs) const
inline

Check whether two patches are different.

◆ operator=()

Patch & bertini::Patch::operator= ( Patch const & other)
default

Copy assignment.

Explicitly defaulted (memberwise), matching the previously-implicit behavior. Note this differs from the custom copy constructor, which re-downsamples at current default precision.

◆ operator==()

bool bertini::Patch::operator== ( Patch const & rhs) const
inline

Check whether two patches are the same.

Returns
true If have the same variable structure and coefficients. Otherwise, false.

◆ Precision() [1/2]

unsigned bertini::Patch::Precision ( ) const
inline

Get the current precision of the patch.

Returns
The current precision, in digits.

◆ Precision() [2/2]

void bertini::Patch::Precision ( unsigned new_precision) const
inline

Set the precision of the patch.

Copies the patch coefficients into correct precision for subsequent precision.

Parameters
new_precisionThe precision to change to.

◆ Random()

Patch bertini::Patch::Random ( std::vector< unsigned > const & sizes)
inlinestatic

Construct a random complex patch on a space.

◆ RandomReal()

Patch bertini::Patch::RandomReal ( std::vector< unsigned > const & sizes)
inlinestatic

Construct random REAL patch on a space.

◆ RescalePoint()

template<typename T>
Vec< T > bertini::Patch::RescalePoint ( Vec< T > const & x) const
inline

Rescale a point so that it satisfies the patch equations herein contained.

Returns
Point $x$ rescaled to fit the patch. $x$ cannot be the zero vector – zero is a degenerate point in projective space.
Parameters
xThe point to rescale.
Template Parameters
TThe number type.

◆ RescalePointToFitInPlace()

template<typename T>
void bertini::Patch::RescalePointToFitInPlace ( Vec< T > & x) const
inline

Rescale a point so that it satisfies the patch equations herein contained.

The point must be as long as there are total variables.

This function modifies the vector in place, so ensure you have a copy stored somewhere else if you feel it necessary to still have the pre-rescaled vector around.

Parameters
xThe point to rescale
Template Parameters
TThe number type.

◆ SyncPrecision()

template<typename T>
void bertini::Patch::SyncPrecision ( Vec< T > const & x) const
inline

Materialize the working coefficients at the precision of the point being evaluated.

Every evaluable type self-aligns this way, so no caller and no owning System has to fan a precision out beforehand – ADR-0057. Precision() short-circuits when already there, so the steady state is one integer compare. No-op for double.

◆ VariableGroupSizes()

std::vector< unsigned > const & bertini::Patch::VariableGroupSizes ( ) const
inline

The number of variables in each variable group (homogenizing variable included).

◆ boost::serialization::access

friend class boost::serialization::access
friend

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
Patch const & p )
friend

Stream-insertion for a Patch, summarizing its variable groups and coefficients.