LMCAS
Lamina Computer Algebra System
载入中...
搜索中...
未找到
query_special_values.cpp
浏览该文件的文档.
2
3namespace LMCAS {
4
5
6bool QueryInterface::is_unhandled_type(const SymbolicExpr& expression) const {
7 const auto& node = LMCAS::detail::node(expression);
8 if (!node) return true;
9 if (std::dynamic_pointer_cast<const MatrixNode>(node)) return true;
10 if (std::dynamic_pointer_cast<const RelationalNode>(node)) return true;
11 if (std::dynamic_pointer_cast<const LogicalNode>(node)) return true;
12 return false;
13}
14
15bool QueryInterface::is_infinity_node(const SymbolicExpr& expression) const {
16 const auto& node = LMCAS::detail::node(expression);
17 if (auto func = std::dynamic_pointer_cast<const FunctionNode>(node)) {
18 return func->type() == FunctionNode::FuncType::Infinity;
19 }
20 if (auto mul = std::dynamic_pointer_cast<const MultiplyNode>(node)) {
21 if (mul->operands().size() == 2) {
22 for (const auto& op : mul->operands()) {
23 if (auto func = std::dynamic_pointer_cast<const FunctionNode>(op)) {
24 if (func->type() == FunctionNode::FuncType::Infinity) {
25 return true;
26 }
27 }
28 }
29 }
30 }
31 return false;
32}
33
34int QueryInterface::get_infinity_sign(const SymbolicExpr& expression) const {
35 const auto& node = LMCAS::detail::node(expression);
36 if (auto func = std::dynamic_pointer_cast<const FunctionNode>(node)) {
37 if (func->type() == FunctionNode::FuncType::Infinity) {
38 return +1;
39 }
40 }
41 if (auto mul = std::dynamic_pointer_cast<const MultiplyNode>(node)) {
42 bool has_infinity = false;
43 bool has_neg_one = false;
44 for (const auto& op : mul->operands()) {
45 if (auto func = std::dynamic_pointer_cast<const FunctionNode>(op)) {
46 if (func->type() == FunctionNode::FuncType::Infinity) {
47 has_infinity = true;
48 }
49 }
50 const auto number =
51 std::dynamic_pointer_cast<const NumberNode>(op);
52 if (number && number->is_negative_one()) has_neg_one = true;
53 }
54 if (has_infinity && has_neg_one) return -1;
55 if (has_infinity) return +1; /** @brief 无穷与正因子相乘仍为正无穷。 */
56 }
57 return 0; /** @brief 符号未定。 */
58}
59
60}
const SymbolicNodePtr & node(const ::LMCAS::SymbolicExpr &expression) noexcept
ExprResult mul(const ExprPtr &lhs, const ExprPtr &rhs, ComputationContext &context)
const ExprPtr RelationOp op