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

An implementation of straight-line programs, implemented with strong inspiration from Bertini1's implementation. More...

#include <straight_line_program.hpp>

Public Types

using IntT = int
 The integer type used for the program's integer bank.

Public Member Functions

 StraightLineProgram (System const &sys)
 The constructor – how to make a SLP from a System.
 StraightLineProgram ()
template<typename Derived>
void Eval (Eigen::MatrixBase< Derived > const &variable_values) const
 Evaluate the program at the given variable values (no path variable).
template<typename Derived, typename ComplexT>
void Eval (Eigen::MatrixBase< Derived > const &variable_values, ComplexT const &time) const
 copies the variable values into the Matrix base and the path variables into the complex type time
template<typename T>
void EvalFunctions () const
 Evaluate the program's functions (currently a synonym for the full Eval).
template<typename T>
void EvalJacobian () const
 Evaluate the program's Jacobian (currently a synonym for the full Eval).
template<typename T>
void EvalTimeDeriv () const
 Evaluate the program's time derivative (currently a synonym for the full Eval).
std::shared_ptr< const SLPProgram > Program () const
 The immutable compiled program this facade runs.
size_t NumRealSlots () const
 Number of slots the compiler inferred as NumType::Real (ADR-0034).
template<typename NumT>
NumT ReadSlotAsComplex (size_t slot) const
 Read a slot's value as a complex NumT, pulling from its real or complex bank per its NumType.
template<typename NumT>
void GetFuncValsInPlace (Eigen::Ref< Vec< NumT > > result) const
 Copy the computed function values into the provided vector (does not resize it).
template<typename NumT>
void GetJacobianInPlace (Eigen::Ref< Mat< NumT > > result) const
 retrieves the computed values of jacobians
template<typename NumT>
void GetTimeDerivInPlace (Eigen::Ref< Vec< NumT > > result) const
 copies the values of the time derivatives into your given vector
template<typename NumT>
Vec< NumT > GetFuncVals () const
 creates the Vec<NumT> to be used in the overloaded function
template<typename NumT>
Mat< NumT > GetJacobian () const
 creates the Vec<NumT> to be used in the overloaded function
template<typename NumT>
Vec< NumT > GetTimeDeriv () const
 creates the Vec<NumT> to be used in the overloaded function
unsigned NumFunctions () const
 Get the number of functions in the program.
unsigned NumVariables () const
 Get the number of variables in the program.
size_t NumMemorySlots () const
 Number of memory slots: one per distinct value the program holds (inputs, constants, and one per compiled subexpression).
size_t FirstLiveInstructionOffset () const
 Word offset into the instruction tape where the live segment begins (== total word length of the frozen, constants-only prologue).
unsigned precision () const
 Get the current precision of the SLP.
void precision (unsigned new_precision) const
 change the precision of the SLP.
template<typename Derived>
void SyncPrecision (Eigen::MatrixBase< Derived > const &variable_values) const
 Materialize this program's memory at the precision of the point being evaluated.
bool HavePathVariable () const
 Does this SLP have a path variable?
template<typename Derived>
void SetVariableValues (Eigen::MatrixBase< Derived > const &variable_values) const
 Copy the values of the variables from the passed in vector to memory.
template<typename ComplexT>
void SetPathVariable (ComplexT const &time) const
 Copy the current time value to memory.

Friends

class boost::serialization::access
std::ostream & operator<< (std::ostream &out, const StraightLineProgram &s)
std::ostream & operator<< (std::ostream &out, const StraightLineProgram &s)
 Overloaded operator for printing to an arbirtary out stream.

Detailed Description

An implementation of straight-line programs, implemented with strong inspiration from Bertini1's implementation.

One constructs a SLP from a system, like

System my_system();
StraightLineProgram slp(my_system);
StraightLineProgram(System const &sys)
The constructor – how to make a SLP from a System.
The fundamental polynomial system class for Bertini2.
Definition system.hpp:106

Maybe you don't need to know this, but in construction the SLP uses a helper class, the SLPCompiler

Patches are just functions in this framework. The variables appear at the front of the memory, then functions, then derivatives. This should make copying data out easy, because it's all in one place.

In contrast to Bertini1 SLP's, we don't put all the numbers at the front – they just get scattered through the SLP's memory.

The class is a thin facade (ADR-0027) over an immutable, shareable SLPProgram and a per-thread SLPMemory.

Member Typedef Documentation

◆ IntT

The integer type used for the program's integer bank.

Constructor & Destructor Documentation

◆ StraightLineProgram() [1/2]

bertini::StraightLineProgram::StraightLineProgram ( System const & sys)

The constructor – how to make a SLP from a System.

◆ StraightLineProgram() [2/2]

bertini::StraightLineProgram::StraightLineProgram ( )
inline

Member Function Documentation

◆ Eval() [1/2]

template<typename Derived>
void bertini::StraightLineProgram::Eval ( Eigen::MatrixBase< Derived > const & variable_values) const
inline

Evaluate the program at the given variable values (no path variable).

Template Parameters
DerivedThe Eigen expression type of the variable values.
Parameters
variable_valuesThe values of the variables.

◆ Eval() [2/2]

template<typename Derived, typename ComplexT>
void bertini::StraightLineProgram::Eval ( Eigen::MatrixBase< Derived > const & variable_values,
ComplexT const & time ) const
inline

copies the variable values into the Matrix base and the path variables into the complex type time

Template Parameters
Derivedderived type
ComplexTcomplex type
Parameters
variable_valuesdervied matrixBase of variable values
timecomplex type for time

◆ EvalFunctions()

template<typename T>
void bertini::StraightLineProgram::EvalFunctions ( ) const
inline

Evaluate the program's functions (currently a synonym for the full Eval).

◆ EvalJacobian()

template<typename T>
void bertini::StraightLineProgram::EvalJacobian ( ) const
inline

Evaluate the program's Jacobian (currently a synonym for the full Eval).

◆ EvalTimeDeriv()

template<typename T>
void bertini::StraightLineProgram::EvalTimeDeriv ( ) const
inline

Evaluate the program's time derivative (currently a synonym for the full Eval).

◆ FirstLiveInstructionOffset()

size_t bertini::StraightLineProgram::FirstLiveInstructionOffset ( ) const
inline

Word offset into the instruction tape where the live segment begins (== total word length of the frozen, constants-only prologue).

Zero means the program has no frozen prologue. Exposed for testing the freeze-set tape partition (ADR-0027).

◆ GetFuncVals()

template<typename NumT>
Vec< NumT > bertini::StraightLineProgram::GetFuncVals ( ) const
inline

creates the Vec<NumT> to be used in the overloaded function

Template Parameters
NumTnumeric type

◆ GetFuncValsInPlace()

template<typename NumT>
void bertini::StraightLineProgram::GetFuncValsInPlace ( Eigen::Ref< Vec< NumT > > result) const
inline

Copy the computed function values into the provided vector (does not resize it).

Template Parameters
NumTThe number type.
Parameters
[out]resultThe vector to write the function values into.

◆ GetJacobian()

template<typename NumT>
Mat< NumT > bertini::StraightLineProgram::GetJacobian ( ) const
inline

creates the Vec<NumT> to be used in the overloaded function

Template Parameters
NumTnumeric type

◆ GetJacobianInPlace()

template<typename NumT>
void bertini::StraightLineProgram::GetJacobianInPlace ( Eigen::Ref< Mat< NumT > > result) const
inline

retrieves the computed values of jacobians

Template Parameters
NumTnumeric type
Parameters
resultThe vector you're going to store the values into

the function will NOT automatically resize your vector for you to be the correct size

◆ GetTimeDeriv()

template<typename NumT>
Vec< NumT > bertini::StraightLineProgram::GetTimeDeriv ( ) const
inline

creates the Vec<NumT> to be used in the overloaded function

Template Parameters
NumTnumeric type

◆ GetTimeDerivInPlace()

template<typename NumT>
void bertini::StraightLineProgram::GetTimeDerivInPlace ( Eigen::Ref< Vec< NumT > > result) const
inline

copies the values of the time derivatives into your given vector

Template Parameters
NumTnumeric type
Parameters
resultThe vector you're going to store the values into

the function will automatically resize your vector for you to be the correct size

◆ HavePathVariable()

bool bertini::StraightLineProgram::HavePathVariable ( ) const
inline

Does this SLP have a path variable?

Returns
Well, does it?

◆ NumFunctions()

unsigned bertini::StraightLineProgram::NumFunctions ( ) const
inline

Get the number of functions in the program.

◆ NumMemorySlots()

size_t bertini::StraightLineProgram::NumMemorySlots ( ) const
inline

Number of memory slots: one per distinct value the program holds (inputs, constants, and one per compiled subexpression).

Shared subexpressions get a single slot, so this is a measure of the compiled (CSE'd) size of the program.

◆ NumRealSlots()

size_t bertini::StraightLineProgram::NumRealSlots ( ) const
inline

Number of slots the compiler inferred as NumType::Real (ADR-0034).

>0 means real-valued subexpressions are being evaluated in the cheaper real banks; used by tests to confirm the tier inference is live (not silently all-Complex).

◆ NumVariables()

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

Get the number of variables in the program.

◆ precision() [1/2]

unsigned bertini::StraightLineProgram::precision ( ) const
inline

Get the current precision of the SLP.

Returns
The number of digits

◆ precision() [2/2]

void bertini::StraightLineProgram::precision ( unsigned new_precision) const

change the precision of the SLP.

Downsamples from the true values.

Parameters
new_precisionThe new number of digits

◆ Program()

std::shared_ptr< const SLPProgram > bertini::StraightLineProgram::Program ( ) const
inline

The immutable compiled program this facade runs.

Interned (ADR-0027 E4): facades compiled from content-identical sources share one Program object (pointer equality is meaningful), each with its own SLPMemory.

◆ ReadSlotAsComplex()

template<typename NumT>
NumT bertini::StraightLineProgram::ReadSlotAsComplex ( size_t slot) const
inline

Read a slot's value as a complex NumT, pulling from its real or complex bank per its NumType.

◆ SetPathVariable()

template<typename ComplexT>
void bertini::StraightLineProgram::SetPathVariable ( ComplexT const & time) const
inline

Copy the current time value to memory.

Parameters
timeThe current time
Template Parameters
ComplexTthe complex numeric type.

If the SLP doesn't have a path variable, then this will throw.

◆ SetVariableValues()

template<typename Derived>
void bertini::StraightLineProgram::SetVariableValues ( Eigen::MatrixBase< Derived > const & variable_values) const
inline

Copy the values of the variables from the passed in vector to memory.

Parameters
variable_valuesThe vector of current variable values.

◆ SyncPrecision()

template<typename Derived>
void bertini::StraightLineProgram::SyncPrecision ( Eigen::MatrixBase< Derived > const & variable_values) const
inline

Materialize this program's memory at the precision of the point being evaluated.

Every evaluable type self-aligns under this name – the blocks, the patch, and here – 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, which carries no precision.

Parameters
variable_valuesThe point about to be evaluated at.

◆ boost::serialization::access

friend class boost::serialization::access
friend

◆ operator<< [1/2]

std::ostream & operator<< ( std::ostream & out,
const StraightLineProgram & s )
friend

Overloaded operator for printing to an arbirtary out stream.

◆ operator<< [2/2]

std::ostream & operator<< ( std::ostream & out,
const StraightLineProgram & s )
friend