Bertini 2 d882924 (2026-10-06 19:56 UTC)
Numerical algebraic geometry library (C++ core)
Loading...
Searching...
No Matches
block.hpp
Go to the documentation of this file.
1//This file is part of Bertini 2.
2//
3//block.hpp is free software: you can redistribute it and/or modify
4//it under the terms of the GNU General Public License as published by
5//the Free Software Foundation, either version 3 of the License, or
6//(at your option) any later version.
7//
8//block.hpp is distributed in the hope that it will be useful,
9//but WITHOUT ANY WARRANTY; without even the implied warranty of
10//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11//GNU General Public License for more details.
12//
13//You should have received a copy of the GNU General Public License
14//along with block.hpp. If not, see <http://www.gnu.org/licenses/>.
15//
16// Copyright(C) Bertini2 Development Team
17//
18// See <http://www.gnu.org/licenses/> for a copy of the license,
19// as well as COPYING. Bertini2 is provided with permitted
20// additional terms in the b2/licenses/ directory.
21
61
62#pragma once
63
64#include <type_traits>
65#include <variant>
66
69
75
76namespace bertini {
77namespace blocks {
78
86template <typename, typename = void>
87struct is_block : std::false_type {};
88
89template <typename B>
90struct is_block<B, std::void_t<
91 decltype(std::declval<const B&>().NumFunctions()),
92 decltype(std::declval<const B&>().DependsOnPathVariable()),
93 decltype(std::declval<const B&>().Precision()),
94 decltype(std::declval<const B&>().Precision(0u)), // the precision setter
95 decltype(std::declval<const B&>().Degrees()),
96 decltype(std::declval<const B&>().Degrees(std::declval<VariableGroup const&>())),
97 decltype(std::declval<const B&>().IsHomogeneous(std::declval<VariableGroup const&>())),
98 decltype(std::declval<const B&>().IsPolynomial(std::declval<VariableGroup const&>())),
99 // Homogenize mutates (e.g. LinearFormsBlock folds its constant column onto the hom var), so
100 // it is detected on a non-const B&.
101 decltype(std::declval<B&>().Homogenize(
102 std::declval<VariableGroup const&>(), std::declval<std::shared_ptr<node::Variable> const&>())),
103 decltype(std::declval<const B&>().template EvalInPlace<complex_dbl>(
104 std::declval<Eigen::Ref<Vec<complex_dbl>>>(), std::declval<Vec<complex_dbl> const&>(), std::declval<complex_dbl const&>())),
105 decltype(std::declval<const B&>().template JacobianInPlace<complex_dbl>(
106 std::declval<Eigen::Ref<Mat<complex_dbl>>>(), std::declval<Vec<complex_dbl> const&>(), std::declval<complex_dbl const&>())),
107 decltype(std::declval<const B&>().template TimeDerivInPlace<complex_dbl>(
108 std::declval<Eigen::Ref<Vec<complex_dbl>>>(), std::declval<Vec<complex_dbl> const&>(), std::declval<complex_dbl const&>()))
109>> : std::true_type {};
110
112template <typename B>
113inline constexpr bool is_block_v = is_block<B>::value;
114
115// As blocks are added, extend this static_assert list (and, later, the Block variant).
116static_assert(is_block_v<PolynomialBlock>,
117 "PolynomialBlock must satisfy the evaluation-block contract");
119 "ProductsOfLinearsBlock must satisfy the evaluation-block contract");
120static_assert(is_block_v<LinearFormsBlock>,
121 "LinearFormsBlock must satisfy the evaluation-block contract");
122
123} // namespace blocks
124
125// Forward declaration: BlendBlock and RandomizationBlock hold their operands by
126// shared_ptr<System>, and a System contains Blocks -- the template parameter keeps System a
127// dependent name so the recursive type closes without System being complete here. (For the
128// same reason these two block types are absent from the is_block_v static_assert list above:
129// detecting the contract instantiates their templated eval entry points, which need System
130// complete; that check happens structurally at the std::visit site instead.)
131class System;
132
135using Block = std::variant<blocks::PolynomialBlock, blocks::ProductsOfLinearsBlock, blocks::LinearFormsBlock, blocks::BlendBlock<System>, blocks::RandomizationBlock<System>>;
136
137} // namespace bertini
A System evaluation block that linearly combines whole Systems with t-coefficients.
The fundamental polynomial system class for Bertini2.
Definition system.hpp:106
A block that randomizes an overdetermined operand system down to a square one (with a constant coeffi...
Definition randomization_block.hpp:80
Bertini extensions of the Eigen linear algebra library.
A System evaluation block whose functions are linear forms: f(x) = M x + b.
Definition blend_block.hpp:75
constexpr bool is_block_v
Convenience variable template: true iff B satisfies the polynomial-block evaluation interface.
Definition block.hpp:113
Definition algorithm_builder.hpp:36
std::variant< blocks::PolynomialBlock, blocks::ProductsOfLinearsBlock, blocks::LinearFormsBlock, blocks::BlendBlock< System >, blocks::RandomizationBlock< System > > Block
The closed set of evaluation blocks a System can be composed of.
Definition block.hpp:135
Provides an Eigen-like NumTraits struct for querying traits of a number type.
The evaluation block holding the classic polynomial path: function-tree functions (and their derivati...
A System evaluation block whose functions are each a product of linear forms.
A System evaluation block that randomizes an overdetermined operand system down to a square one,...
Detection trait: does B satisfy the evaluation-block contract?
Definition block.hpp:87