LMCAS
Lamina Computer Algebra System
Toggle main menu visibility
载入中...
搜索中...
未找到
rewrite_budget.hpp
浏览该文件的文档.
1
#pragma once
2
3
#include "
computation_context.hpp
"
4
5
#include <cstddef>
6
#include <memory>
7
#include <string>
8
#include <unordered_map>
9
10
namespace
LMCAS
{
11
class
SymbolicNode
;
12
}
13
14
namespace
LMCAS::detail
{
15
class
RewriteBudget
{
16
public
:
17
RewriteBudget
(
ComputationContext
&
context
, std::size_t max_depth,
18
std::size_t
max_nodes
,
const
char
*
operation
);
19
RewriteBudget
(
ComputationContext
&
context
, std::size_t max_steps,
20
std::size_t max_depth, std::size_t
max_nodes
,
21
const
char
*
operation
);
22
RewriteBudget
(
const
RewriteBudget
&) =
delete
;
23
RewriteBudget
&
operator=
(
const
RewriteBudget
&) =
delete
;
24
ComputationContext
&
context
() const noexcept {
return
context_
; }
25
std::size_t
max_nodes
() const noexcept {
return
max_nodes_
; }
26
void
consume
();
27
28
void
enter
();
29
void
leave
() noexcept;
30
void
require_nodes
(std::
size_t
nodes) const;
31
std::
size_t
measure
(const std::shared_ptr<const
SymbolicNode
>&
node
);
32
std::
size_t
measure_result
(const std::shared_ptr<const
SymbolicNode
>&
node
);
33
std::
size_t
append_size
(std::
size_t
current, std::
size_t
child);
34
static std::
size_t
input_nodes
(
35
const std::shared_ptr<const
SymbolicNode
>& lhs,
36
const std::shared_ptr<const
SymbolicNode
>&
rhs
,
37
ComputationContext
&
context
, std::
size_t
max_depth, const
char
*
operation
);
38
39
private:
40
friend struct
RewriteBudgetTestAccess
;
41
struct
Shape
{
42
std::size_t
nodes
= 0;
43
std::size_t
height
= 0;
44
};
45
struct
Entry
{
46
std::weak_ptr<const SymbolicNode>
owner
;
47
Shape
shape
;
48
};
49
class
Measurement
;
50
Shape
measure_shape
(
const
std::shared_ptr<const SymbolicNode>&
node
,
51
std::size_t path_depth, std::size_t active_depth);
52
void
require_shape
(
const
Shape
& shape, std::size_t path_depth,
53
std::size_t active_depth)
const
;
54
void
check_step_access
()
const
;
55
void
commit_step
();
56
57
ComputationContext
&
context_
;
58
std::size_t
remaining_steps_
;
59
std::size_t
max_depth_
;
60
std::size_t
max_nodes_
;
61
std::size_t
depth_
= 0;
62
bool
limit_steps_
;
63
const
std::string
operation_
;
64
std::unordered_map<const SymbolicNode*, Entry>
shapes_
;
65
};
66
class
RewriteScope
{
67
public
:
68
explicit
RewriteScope
(
RewriteBudget
*
budget
) :
budget_
(
budget
) {
69
if
(
budget_
) {
budget_
->
enter
(); }
70
}
71
~RewriteScope
() {
72
if
(
budget_
) {
budget_
->
leave
(); }
73
}
74
RewriteScope
(
const
RewriteScope
&) =
delete
;
75
RewriteScope
&
operator=
(
const
RewriteScope
&) =
delete
;
76
77
private
:
78
RewriteBudget
*
budget_
;
79
};
80
81
}
LMCAS::ComputationContext
定义
computation_context.hpp:99
LMCAS::SymbolicNode
定义
base.hpp:147
LMCAS::detail::RewriteBudget::Measurement
定义
rewrite_budget.cpp:29
LMCAS::detail::RewriteBudget
定义
rewrite_budget.hpp:15
LMCAS::detail::RewriteBudget::max_nodes_
std::size_t max_nodes_
定义
rewrite_budget.hpp:60
LMCAS::detail::RewriteBudget::operation_
const std::string operation_
定义
rewrite_budget.hpp:63
LMCAS::detail::RewriteBudget::shapes_
std::unordered_map< const SymbolicNode *, Entry > shapes_
定义
rewrite_budget.hpp:64
LMCAS::detail::RewriteBudget::enter
void enter()
定义
rewrite_budget.cpp:103
LMCAS::detail::RewriteBudget::context
ComputationContext & context() const noexcept
定义
rewrite_budget.hpp:24
LMCAS::detail::RewriteBudget::measure
std::size_t measure(const std::shared_ptr< const SymbolicNode > &node)
定义
rewrite_budget.cpp:179
LMCAS::detail::RewriteBudget::Shape::nodes
std::size_t nodes
定义
rewrite_budget.hpp:42
LMCAS::detail::RewriteBudget::max_depth_
std::size_t max_depth_
定义
rewrite_budget.hpp:59
LMCAS::detail::RewriteBudget::require_nodes
void require_nodes(std::size_t nodes) const
定义
rewrite_budget.cpp:119
LMCAS::detail::RewriteBudget::operator=
RewriteBudget & operator=(const RewriteBudget &)=delete
LMCAS::detail::RewriteBudget::consume
void consume()
定义
rewrite_budget.cpp:98
LMCAS::detail::RewriteBudget::append_size
std::size_t append_size(std::size_t current, std::size_t child)
定义
rewrite_budget.cpp:188
LMCAS::detail::RewriteBudget::RewriteBudget
RewriteBudget(ComputationContext &context, std::size_t max_depth, std::size_t max_nodes, const char *operation)
定义
rewrite_budget.cpp:70
LMCAS::detail::RewriteBudget::measure_result
std::size_t measure_result(const std::shared_ptr< const SymbolicNode > &node)
定义
rewrite_budget.cpp:183
LMCAS::detail::RewriteBudget::depth_
std::size_t depth_
定义
rewrite_budget.hpp:61
LMCAS::detail::RewriteBudget::context_
ComputationContext & context_
定义
rewrite_budget.hpp:57
LMCAS::detail::RewriteBudget::Entry::owner
std::weak_ptr< const SymbolicNode > owner
定义
rewrite_budget.hpp:46
LMCAS::detail::RewriteBudget::RewriteBudget
RewriteBudget(const RewriteBudget &)=delete
LMCAS::detail::RewriteBudget::commit_step
void commit_step()
定义
rewrite_budget.cpp:92
LMCAS::detail::RewriteBudget::Shape::height
std::size_t height
定义
rewrite_budget.hpp:43
LMCAS::detail::RewriteBudget::max_nodes
std::size_t max_nodes() const noexcept
定义
rewrite_budget.hpp:25
LMCAS::detail::RewriteBudget::measure_shape
Shape measure_shape(const std::shared_ptr< const SymbolicNode > &node, std::size_t path_depth, std::size_t active_depth)
定义
rewrite_budget.cpp:139
LMCAS::detail::RewriteBudget::remaining_steps_
std::size_t remaining_steps_
定义
rewrite_budget.hpp:58
LMCAS::detail::RewriteBudget::input_nodes
static std::size_t input_nodes(const std::shared_ptr< const SymbolicNode > &lhs, const std::shared_ptr< const SymbolicNode > &rhs, ComputationContext &context, std::size_t max_depth, const char *operation)
定义
rewrite_budget.cpp:198
LMCAS::detail::RewriteBudget::limit_steps_
bool limit_steps_
定义
rewrite_budget.hpp:62
LMCAS::detail::RewriteBudget::require_shape
void require_shape(const Shape &shape, std::size_t path_depth, std::size_t active_depth) const
定义
rewrite_budget.cpp:127
LMCAS::detail::RewriteBudget::RewriteBudgetTestAccess
friend struct RewriteBudgetTestAccess
定义
rewrite_budget.hpp:40
LMCAS::detail::RewriteBudget::leave
void leave() noexcept
定义
rewrite_budget.cpp:114
LMCAS::detail::RewriteBudget::check_step_access
void check_step_access() const
定义
rewrite_budget.cpp:84
LMCAS::detail::RewriteBudget::Entry::shape
Shape shape
定义
rewrite_budget.hpp:47
LMCAS::detail::RewriteBudget::Shape
定义
rewrite_budget.hpp:41
LMCAS::detail::RewriteBudget::Entry
定义
rewrite_budget.hpp:45
LMCAS::detail::RewriteScope::RewriteScope
RewriteScope(RewriteBudget *budget)
定义
rewrite_budget.hpp:68
LMCAS::detail::RewriteScope::RewriteScope
RewriteScope(const RewriteScope &)=delete
LMCAS::detail::RewriteScope::budget_
RewriteBudget * budget_
定义
rewrite_budget.hpp:78
LMCAS::detail::RewriteScope::~RewriteScope
~RewriteScope()
定义
rewrite_budget.hpp:71
LMCAS::detail::RewriteScope::operator=
RewriteScope & operator=(const RewriteScope &)=delete
computation_context.hpp
LMCAS::detail
多元 Hensel 提升(单变量步)
定义
assumption_context.hpp:31
LMCAS::detail::node
const SymbolicNodePtr & node(const ::LMCAS::SymbolicExpr &expression) noexcept
定义
base.hpp:91
LMCAS::detail::rhs
ExactRealAlgebraic rhs
定义
exact_algebraic.hpp:43
LMCAS::detail::operation
ComputationContext const std::string & operation
定义
exact_algebraic.hpp:32
LMCAS::detail::budget
RewriteBudget & budget
定义
expression_transform.hpp:16
LMCAS::detail::context
std::size_t std::size_t ComputationContext & context
定义
exact_algebraic.hpp:27
LMCAS
定义
assumption.hpp:11
src
internal
rewrite_budget.hpp
生成于
, 为 LMCAS使用
1.18.0