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

Provides the bertini::StraightLineProgram class. More...

#include <assert.h>
#include <vector>
#include <map>
#include <memory>
#include <tuple>
#include "bertini2/mpfr_complex.hpp"
#include "bertini2/mpfr_extensions.hpp"
#include "bertini2/eigen_extensions.hpp"
#include "bertini2/function_tree/forward_declares.hpp"
#include "bertini2/detail/visitor.hpp"
#include <boost/serialization/utility.hpp>
#include <boost/serialization/split_member.hpp>
Include dependency graph for straight_line_program.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  bertini::SLPOutputLocations
 A struct encapsulating the starting locations of outputs in the SLP's memory layout. More...
struct  bertini::SLPInputLocations
 A struct encapsulating the starting locations of inputs in the SLP's memory layout. More...
struct  bertini::SLPNumberOf
 A struct encapsulating the numbers of things appearing in the SLP. More...
struct  bertini::ConstantRecipe
 An exact, node-independent description of a constant baked into the program: enough to (re)produce the constant's value at any working precision, without evaluating a function-tree node (ADR-0027; node evaluation is being retired). More...
class  bertini::SLPMemory
 The per-thread mutable working state of a straight-line program evaluation: the register file (one bank per number type), the working precision, and the freshness / frozen-prologue flags. More...
class  bertini::SLPProgram
 The immutable compiled straight-line program (ADR-0027): the instruction tape, the constant recipe (true values of numbers + integer bank), and the memory layout (numbers of / locations of things). More...
class  bertini::StraightLineProgram
 An implementation of straight-line programs, implemented with strong inspiration from Bertini1's implementation. More...
class  bertini::SLPCompiler
 Compiles a System (or polynomial block) into a StraightLineProgram by visiting its function-tree nodes and emitting tape instructions (with common-subexpression sharing). More...

Namespaces

namespace  bertini

Enumerations

enum class  bertini::NumType : uint8_t { bertini::Real = 0 , bertini::Complex = 1 }
 The numeric type a memory slot holds, orthogonal to working precision (ADR-0034). More...
enum  bertini::Operation {
  bertini::Add = 1 << 0 , bertini::Subtract = 1 << 1 , bertini::Multiply = 1 << 2 , bertini::Divide = 1 << 3 ,
  bertini::Power = 1 << 4 , bertini::Exp = 1 << 5 , bertini::Log = 1 << 6 , bertini::Negate = 1 << 7 ,
  bertini::Sqrt = 1 << 8 , bertini::Sin = 1 << 9 , bertini::Cos = 1 << 10 , bertini::Tan = 1 << 11 ,
  bertini::Asin = 1 << 12 , bertini::Acos = 1 << 13 , bertini::Atan = 1 << 14 , bertini::Assign = 1 << 15 ,
  bertini::IntPower = 1 << 16
}
 The opcodes for the operations a straight-line program instruction can perform. More...

Functions

constexpr bool bertini::IsUnary (Operation op)
 Query whether an operation takes a single operand.
constexpr bool bertini::IsBinary (Operation op)
 Query whether an operation takes two operands.
std::string bertini::OpcodeToString (Operation op)
 Get a human-readable name for an opcode.
bool bertini::SLPValueNumbering ()
 Whether the SLP compiler value-numbers (instruction-level CSE) while emitting the tape: an identical (op, operand-slots) computation reuses the earlier result slot instead of recomputing.
void bertini::SetSLPValueNumbering (bool on)
 Set whether the SLP compiler value-numbers while emitting the tape.
std::shared_ptr< const SLPProgram > bertini::InternProgram (std::shared_ptr< const SLPProgram > const &candidate)
 Hash-cons a freshly-compiled program: return an existing content-equal SLPProgram if one is live, otherwise register and return the candidate (ADR-0027 E4, ADR-0042).

Variables

const int bertini::BinaryOperations = Add|Subtract | Multiply|Divide | Power | IntPower
 Bit-mask of the two-operand operations.
const int bertini::TrigOperations = Sin|Cos|Tan | Asin|Acos|Atan
 Bit-mask of the trigonometric operations.
const int bertini::UnaryOperations = Exp|Log | Negate | Assign | TrigOperations | Sqrt
 Bit-mask of the one-operand operations.
constexpr size_t bertini::kOpcodeMask = (static_cast<size_t>(1) << 17) - 1
 Mask recovering the base opcode from an instruction word.
constexpr size_t bertini::kArg0Real = static_cast<size_t>(1) << 20
 High bit: first operand slot is NumType::Real.
constexpr size_t bertini::kArg1Real = static_cast<size_t>(1) << 21
 High bit: second operand slot is Real (binary, not IntPower).
constexpr size_t bertini::kOutReal = static_cast<size_t>(1) << 22
 High bit: result slot is NumType::Real.

Detailed Description

Provides the bertini::StraightLineProgram class.

The straight-line program is split (ADR-0027) into two collaborators:

SLPProgram -- the immutable compiled program: the instruction tape, the constant recipe,
and the memory layout.  Once compiled it never changes, so it is shareable read-only.

SLPMemory -- the per-thread mutable working state: the register file, the working precision,
and the freshness / frozen-prologue flags.  Cheap to allocate; never shared across threads.

StraightLineProgram is the facade owning one (shared) program and its (own) memory, presenting the historical API unchanged.