LMCAS
Lamina Computer Algebra System
载入中...
搜索中...
未找到
LMCAS::FunctionNode类 参考

函数节点,表示数学函数调用(三角函数、对数、特殊函数等)。 更多...

#include </home/runner/work/docs/docs/LMCAS/src/internal/symbolic_ast/functions.hpp>

类 LMCAS::FunctionNode 继承关系图:
LMCAS::FunctionNode 的协作图:

Public 类型

enum class  FuncType {
  Sin , Cos , Tan , Cot ,
  Sec , Csc , ArcSin , ArcCos ,
  ArcTan , Sinh , Cosh , Tanh ,
  Ln , Log , Abs , Sqrt ,
  Exp , LambertW , Atan2 , Infinity ,
  Erf , Ei , Si , Ci ,
  Li , Max , Min , Sgn ,
  Floor , Ceil , Round , RealPart ,
  ImagPart , Conjugate , ComplexAbs , ComplexArg
}

Public 成员函数

void accept (LMCAS::detail::SymbolicVisitor &visitor) const override
const std::vector< std::shared_ptr< const SymbolicNode > > & arguments () const noexcept
std::shared_ptr< const SymbolicNode > clone () const override
int compare (const SymbolicNode &other) const
 与另一个节点进行全序比较.
bool equals (const SymbolicNode &other) const
 判断两个节点是否结构相等.
std::size_t hash () const
 获取节点哈希值(带缓存).
virtual bool is_number () const
virtual bool is_one () const
virtual bool is_positive () const
virtual bool is_zero () const
FuncType type () const noexcept
int type_priority () const override

Protected 成员函数

int compare_same_type (const SymbolicNode &other) const override
std::size_t compute_hash () const override

Protected 属性

std::atomic< std::size_t > cached_hash {0}
std::atomic< bool > hash_computed {false}

Private 成员函数

 FunctionNode (FuncType t, std::vector< std::shared_ptr< const SymbolicNode > > args)

Private 属性

const std::vector< std::shared_ptr< const SymbolicNode > > arguments_
 LMCAS_AST_NODE_FACTORY_FRIEND
const FuncType type_

详细描述

函数节点,表示数学函数调用(三角函数、对数、特殊函数等)。

在文件 functions.hpp 第 10 行定义.

成员枚举类型说明

◆ FuncType

enum class LMCAS::FunctionNode::FuncType
strong
枚举值
Sin 
Cos 
Tan 
Cot 
Sec 
Csc 

三角函数。

ArcSin 
ArcCos 
ArcTan 

反三角函数。

Sinh 
Cosh 
Tanh 

双曲函数。

Ln 
Log 
Abs 
Sqrt 

对数、绝对值、平方根。

Exp 

指数函数。

LambertW 

Lambert W 函数。

Atan2 

双参数反正切。

Infinity 

无穷大。

Erf 

误差函数 erf(x) = (2/√π)∫₀ˣ e^(-t²) dt。

Ei 

指数积分 Ei(x)。

Si 

正弦积分 Si(x) = ∫₀ˣ sin(t)/t dt。

Ci 

余弦积分 Ci(x)。

Li 

对数积分 Li(x) = ∫₀ˣ 1/ln(t) dt。

Max 

最大值 max(a, b)。

Min 

最小值 min(a, b)。

Sgn 

符号函数 sgn(x) ∈ {-1, 0, 1}。

Floor 

下取整 ⌊x⌋。

Ceil 

上取整 ⌈x⌉。

Round 

四舍五入 round(x)。

RealPart 

实部 Re(z)。

ImagPart 

虚部 Im(z)。

Conjugate 

共轭 conj(z)。

ComplexAbs 

复数模 |z|。

ComplexArg 

复数辐角 arg(z)。

在文件 functions.hpp 第 12 行定义.

12 {
13 Sin, Cos, Tan, Cot, Sec, Csc, /**< 三角函数。 */
14 ArcSin, ArcCos, ArcTan, /**< 反三角函数。 */
15 Sinh, Cosh, Tanh, /**< 双曲函数。 */
16 Ln, Log, Abs, Sqrt, /**< 对数、绝对值、平方根。 */
17 Exp, /**< 指数函数。 */
18 LambertW, /**< Lambert W 函数。 */
19 Atan2, /**< 双参数反正切。 */
20 Infinity, /**< 无穷大。 */
21 Erf, /**< 误差函数 erf(x) = (2/√π)∫₀ˣ e^(-t²) dt。 */
22 Ei, /**< 指数积分 Ei(x)。 */
23 Si, /**< 正弦积分 Si(x) = ∫₀ˣ sin(t)/t dt。 */
24 Ci, /**< 余弦积分 Ci(x)。 */
25 Li, /**< 对数积分 Li(x) = ∫₀ˣ 1/ln(t) dt。 */
26 Max, /**< 最大值 max(a, b)。 */
27 Min, /**< 最小值 min(a, b)。 */
28 Sgn, /**< 符号函数 sgn(x) ∈ {-1, 0, 1}。 */
29 Floor, /**< 下取整 ⌊x⌋。 */
30 Ceil, /**< 上取整 ⌈x⌉。 */
31 Round, /**< 四舍五入 round(x)。 */
32 RealPart, /**< 实部 Re(z)。 */
33 ImagPart, /**< 虚部 Im(z)。 */
34 Conjugate, /**< 共轭 conj(z)。 */
35 ComplexAbs, /**< 复数模 |z|。 */
36 ComplexArg /**< 复数辐角 arg(z)。 */
37 };

构造及析构函数说明

◆ FunctionNode()

LMCAS::FunctionNode::FunctionNode ( FuncType t,
std::vector< std::shared_ptr< const SymbolicNode > > args )
inlineprivate

在文件 functions.hpp 第 45 行定义.

46 : type_(t), arguments_(std::move(args)) {
47 for (const auto& arg : arguments_) {
48 if (!arg) {
49 throw std::invalid_argument("FunctionNode argument cannot be null");
50 }
51 }
52 }
const std::vector< std::shared_ptr< const SymbolicNode > > arguments_
__attribute__((visibility("default"))) VectorCalculusExprResult curve_integral_scalar_checked(const std __attribute__((visibility("default"))) VectorCalculusExprResult curve_integral_scalar_checked(const std __attribute__((visibility("default"))) std const VectorField const std::string & t

引用了 arguments_, LMCAS::t , 以及 type_.

被这些函数引用 compare_same_type().

这是这个函数的调用关系图:

成员函数说明

◆ accept()

void LMCAS::FunctionNode::accept ( LMCAS::detail::SymbolicVisitor & visitor) const
inlineoverridevirtual

实现了 LMCAS::SymbolicNode.

在文件 functions.hpp 第 89 行定义.

89{ LMCAS::detail::SymbolicVisitor::DepthGuard guard(visitor); visitor.visit(*this); }
virtual void visit(const NumberNode &node)=0

引用了 LMCAS::detail::SymbolicVisitor::visit().

函数调用图:

◆ arguments()

◆ clone()

std::shared_ptr< const SymbolicNode > LMCAS::FunctionNode::clone ( ) const
inlineoverridevirtual

实现了 LMCAS::SymbolicNode.

在文件 functions.hpp 第 90 行定义.

90 {
91 std::vector<std::shared_ptr<const SymbolicNode>> new_args;
92 for (const auto& arg : arguments_) new_args.push_back(arg->clone());
93 return LMCAS::detail::make_node<FunctionNode>(type_, std::move(new_args));
94 }
std::shared_ptr< const Node > make_node(Args &&... args)

引用了 arguments_, LMCAS::detail::make_node() , 以及 type_.

函数调用图:

◆ compare()

int LMCAS::SymbolicNode::compare ( const SymbolicNode & other) const
inlineinherited

与另一个节点进行全序比较.

参数
other待比较的节点
返回
小于返回 -1,等于返回 0,大于返回 1

在文件 base.hpp 第 183 行定义.

183 {
184 if (type_priority() != other.type_priority()) {
185 return type_priority() < other.type_priority() ? -1 : 1;
186 }
187 return compare_same_type(other);
188 }
virtual int compare_same_type(const SymbolicNode &other) const =0
virtual int type_priority() const =0

引用了 SymbolicNode(), compare_same_type() , 以及 type_priority().

被这些函数引用 LMCAS::anonymous_namespace{symbolic_cancel.cpp}::combine_fraction_terms() , 以及 LMCAS::endpoints_equivalent().

函数调用图:
这是这个函数的调用关系图:

◆ compare_same_type()

int LMCAS::FunctionNode::compare_same_type ( const SymbolicNode & other) const
inlineoverrideprotectedvirtual

实现了 LMCAS::SymbolicNode.

在文件 functions.hpp 第 73 行定义.

73 {
74 const auto& o = static_cast<const FunctionNode&>(other);
75 if (type_ != o.type_) {
76 return static_cast<int>(type_) < static_cast<int>(o.type_) ? -1 : 1;
77 }
78 if (arguments_.size() != o.arguments_.size()) {
79 return arguments_.size() < o.arguments_.size() ? -1 : 1;
80 }
81 for (size_t i = 0; i < arguments_.size(); ++i) {
82 int cmp = arguments_[i]->compare(*o.arguments_[i]);
83 if (cmp != 0) return cmp;
84 }
85 return 0;
86 }
FunctionNode(FuncType t, std::vector< std::shared_ptr< const SymbolicNode > > args)

引用了 FunctionNode(), LMCAS::SymbolicNode::SymbolicNode(), arguments_ , 以及 type_.

函数调用图:

◆ compute_hash()

std::size_t LMCAS::FunctionNode::compute_hash ( ) const
inlineoverrideprotectedvirtual

实现了 LMCAS::SymbolicNode.

在文件 functions.hpp 第 63 行定义.

63 {
64 std::size_t seed = 0;
66 hash_combine(seed, static_cast<size_t>(type_));
67 for (const auto& arg : arguments_) {
68 hash_combine(seed, arg->hash());
69 }
70 return seed;
71 }
int type_priority() const override
void hash_combine(std::size_t &seed, std::size_t value)
将一个哈希值混合到种子中,用于组合多个字段的哈希.

引用了 arguments_, LMCAS::hash_combine(), type_ , 以及 type_priority().

函数调用图:

◆ equals()

bool LMCAS::SymbolicNode::equals ( const SymbolicNode & other) const
inlineinherited

判断两个节点是否结构相等.

参数
other待比较的节点
返回
相等返回 true

在文件 base.hpp 第 195 行定义.

195 {
196 if (this == &other) return true;
197 if (hash() != other.hash()) return false;
198 if (type_priority() != other.type_priority()) return false;
199 return compare_same_type(other) == 0;
200 }
std::size_t hash() const
获取节点哈希值(带缓存).

引用了 SymbolicNode(), compare_same_type(), hash() , 以及 type_priority().

被这些函数引用 LMCAS::complementary_square(), LMCAS::anonymous_namespace{relation_store.cpp}::expr_equals(), LMCAS::match_recursive(), LMCAS::tf_remove_exp_factor() , 以及 LMCAS::tf_substitute_expr().

函数调用图:
这是这个函数的调用关系图:

◆ hash()

std::size_t LMCAS::SymbolicNode::hash ( ) const
inlineinherited

获取节点哈希值(带缓存).

返回
哈希值

在文件 base.hpp 第 168 行定义.

168 {
169 if (!hash_computed.load(std::memory_order_acquire)) {
170 std::size_t h = compute_hash();
171 cached_hash.store(h, std::memory_order_relaxed);
172 hash_computed.store(true, std::memory_order_release);
173 return h;
174 }
175 return cached_hash.load(std::memory_order_relaxed);
176 }
virtual std::size_t compute_hash() const =0
std::atomic< std::size_t > cached_hash
std::atomic< bool > hash_computed

引用了 cached_hash, compute_hash() , 以及 hash_computed.

被这些函数引用 LMCAS::MatrixNode::compute_hash(), LMCAS::VariableNode::compute_hash() , 以及 equals().

函数调用图:
这是这个函数的调用关系图:

◆ is_number()

virtual bool LMCAS::SymbolicNode::is_number ( ) const
inlinevirtualinherited

被 LMCAS::NumberNode 重载.

在文件 base.hpp 第 201 行定义.

201{ return false; }

◆ is_one()

virtual bool LMCAS::SymbolicNode::is_one ( ) const
inlinevirtualinherited

被 LMCAS::NumberNode 重载.

在文件 base.hpp 第 202 行定义.

202{ return false; }

◆ is_positive()

virtual bool LMCAS::SymbolicNode::is_positive ( ) const
inlinevirtualinherited

被 LMCAS::NumberNode 重载.

在文件 base.hpp 第 204 行定义.

204{ return false; }

◆ is_zero()

virtual bool LMCAS::SymbolicNode::is_zero ( ) const
inlinevirtualinherited

◆ type()

◆ type_priority()

int LMCAS::FunctionNode::type_priority ( ) const
inlineoverridevirtual

实现了 LMCAS::SymbolicNode.

在文件 functions.hpp 第 60 行定义.

60{ return 2; }

被这些函数引用 compute_hash().

这是这个函数的调用关系图:

类成员变量说明

◆ arguments_

const std::vector<std::shared_ptr<const SymbolicNode> > LMCAS::FunctionNode::arguments_
private

在文件 functions.hpp 第 43 行定义.

被这些函数引用 FunctionNode(), arguments(), clone(), compare_same_type() , 以及 compute_hash().

◆ cached_hash

std::atomic<std::size_t> LMCAS::SymbolicNode::cached_hash {0}
mutableprotectedinherited

在文件 base.hpp 第 149 行定义.

被这些函数引用 SymbolicNode() , 以及 hash().

◆ hash_computed

std::atomic<bool> LMCAS::SymbolicNode::hash_computed {false}
mutableprotectedinherited

在文件 base.hpp 第 150 行定义.

被这些函数引用 SymbolicNode() , 以及 hash().

◆ LMCAS_AST_NODE_FACTORY_FRIEND

LMCAS::FunctionNode::LMCAS_AST_NODE_FACTORY_FRIEND
private

在文件 functions.hpp 第 40 行定义.

◆ type_

const FuncType LMCAS::FunctionNode::type_
private

在文件 functions.hpp 第 42 行定义.

被这些函数引用 FunctionNode(), clone(), compare_same_type(), compute_hash() , 以及 type().


该类的文档由以下文件生成: