10 const std::shared_ptr<SymbolicExpr>& f,
const std::string&
t,
const std::string& s) {
20 if (vn && !vn->is_constant() && vn->name() ==
v) { n = BigInt(1);
return true; }
25 auto bv = std::dynamic_pointer_cast<const VariableNode>(pw->base());
26 if (!bv || bv->is_constant() || bv->name() !=
v) {
32static bool te_is_hyp(
const std::shared_ptr<SymbolicExpr>&
e,
const std::string&
v,
33 bool& is_sinh, std::shared_ptr<SymbolicExpr>& freq) {
38 if (!fn || fn->arguments().empty()) {
46 return freq !=
nullptr;
49static bool te_extract_exp(
const std::shared_ptr<SymbolicExpr>&
e,
const std::string&
t,
50 std::shared_ptr<SymbolicExpr>& a_out, std::shared_ptr<SymbolicExpr>& rem_out) {
64 for (
size_t i = 0; i <
mul->operands().size(); ++i) {
66 std::shared_ptr<SymbolicExpr> at, rt;
68 std::vector<std::shared_ptr<const SymbolicNode>> rest =
mul->operands();
69 rest.erase(rest.begin() +
static_cast<std::ptrdiff_t
>(i));
72 a_out = at;
return true;
80 const std::shared_ptr<SymbolicExpr>& f,
const std::string&
t,
83 auto sv = SymbolicExpr::variable(s);
88 SymbolicExpr::power(sv, SymbolicExpr::number(n + BigInt(1))));
90 bool is_sin =
false; std::shared_ptr<SymbolicExpr> freq;
92 auto den = SymbolicExpr::add(SymbolicExpr::power(sv, SymbolicExpr::number(2)), SymbolicExpr::power(freq, SymbolicExpr::number(2)));
93 return is_sin ? SymbolicExpr::divide(freq, den) : SymbolicExpr::divide(sv, den);
95 bool is_sinh =
false; std::shared_ptr<SymbolicExpr> hf;
97 auto den = SymbolicExpr::add(SymbolicExpr::power(sv, SymbolicExpr::number(2)), SymbolicExpr::multiply(SymbolicExpr::number(-1), SymbolicExpr::power(hf, SymbolicExpr::number(2))));
98 return is_sinh ? SymbolicExpr::divide(hf, den) : SymbolicExpr::divide(sv, den);
100 std::shared_ptr<SymbolicExpr>
a, rem;
102 return SymbolicExpr::divide(rem, SymbolicExpr::add(sv, SymbolicExpr::multiply(SymbolicExpr::number(-1),
a)));
107 const std::shared_ptr<SymbolicExpr>& f,
108 const std::string&
t,
109 const std::string& s) {
111 auto sv = SymbolicExpr::variable(s);
114 return condition ? std::vector<std::shared_ptr<SymbolicExpr>>{condition}
115 : std::vector<std::shared_ptr<SymbolicExpr>>{};
120 return condition ? std::vector<std::shared_ptr<SymbolicExpr>>{condition}
121 : std::vector<std::shared_ptr<SymbolicExpr>>{};
124 std::shared_ptr<SymbolicExpr> freq;
127 return condition ? std::vector<std::shared_ptr<SymbolicExpr>>{condition}
128 : std::vector<std::shared_ptr<SymbolicExpr>>{};
130 std::shared_ptr<SymbolicExpr>
a;
131 std::shared_ptr<SymbolicExpr> rem;
134 return condition ? std::vector<std::shared_ptr<SymbolicExpr>>{condition}
135 : std::vector<std::shared_ptr<SymbolicExpr>>{};
141 const std::shared_ptr<SymbolicExpr>& f,
const AddNode& addition,
143 std::shared_ptr<SymbolicExpr> result;
144 for (
const auto& operand : addition.
operands()) {
148 result = result ? SymbolicExpr::add(result, transformed) : transformed;
154 const std::shared_ptr<SymbolicExpr>& f,
const std::string&
t,
157 (
context).limits().max_ast_nodes,
"transform");
158 auto step =
context.consume_steps(1,
"laplace_transform.recursive");
166 return SymbolicExpr::number(0);
169 return SymbolicExpr::divide(f, SymbolicExpr::variable(s));
176 if (!coeff->is_one()) {
179 return SymbolicExpr::multiply(coeff, lt_body);
182 std::shared_ptr<SymbolicExpr> a_shift, remainder;
190 return SymbolicExpr::divide(remainder, SymbolicExpr::add(SymbolicExpr::variable(s), SymbolicExpr::multiply(SymbolicExpr::number(-1), a_shift)));
201 const std::shared_ptr<SymbolicExpr>& f,
202 const std::string&
t,
203 const std::string& s,
205 const std::string operation =
"laplace_transform";
208 auto step =
context.consume_steps(8, operation);
212 auto final_access =
context.consume_steps(0, operation);
223 }
catch (
const std::bad_alloc&) {
225 "transform allocation failed",
227 }
catch (
const std::exception&
e) {
229 e.what(), operation);
234 const std::shared_ptr<SymbolicExpr>& f,
235 const std::string&
t,
236 const std::string& s) {
const std::vector< std::shared_ptr< const SymbolicNode > > & operands() const noexcept
static Result failure(CasErrc code, std::string message, std::string operation={})
static std::shared_ptr< const SymbolicNode > create_variable(const std::string &name)
static std::shared_ptr< const SymbolicNode > create_multiply(std::vector< std::shared_ptr< const SymbolicNode > > ops, detail::RewriteBudget *budget=nullptr)
创建乘法节点,自动扁平化嵌套乘法并消除单位元.
static std::shared_ptr< const SymbolicNode > create_number(const ::LMCAS::BigInt &v)
std::shared_ptr<::LMCAS::SymbolicExpr > make_expression_ptr(SymbolicNodePtr root)
const SymbolicNodePtr & node(const ::LMCAS::SymbolicExpr &expression) noexcept
std::shared_ptr< const Node > make_node(Args &&... args)
SymbolicNodePtr substitute_node(const SymbolicNodePtr &node, const std::string &variable, const SymbolicNodePtr &replacement, RewriteBudget &budget, const FactsQuery &facts, Domain domain)
TransformEngineResult laplace_transform_checked(const std::shared_ptr< SymbolicExpr > &f, const std::string &t, const std::string &s, ComputationContext &context)
static std::shared_ptr< SymbolicExpr > te_unevaluated_laplace(const std::shared_ptr< SymbolicExpr > &f, const std::string &t, const std::string &s)
__attribute__((visibility("default"))) VectorCalculusExprResult surface_integral_scalar_checked(const std __attribute__((visibility("default"))) VectorCalculusExprResult surface_integral_scalar_checked(const std __attribute__((visibility("default"))) std const VectorField const std::string const std::string & v
const std::vector< Polynomial< BigInt > > const BigInt ComputationContext & context
bool try_get_integer_value(const std::shared_ptr< const NumberNode > &node, BigInt &value)
static bool te_is_hyp(const std::shared_ptr< SymbolicExpr > &e, const std::string &v, bool &is_sinh, std::shared_ptr< SymbolicExpr > &freq)
ExprResult mul(const ExprPtr &lhs, const ExprPtr &rhs, ComputationContext &context)
ExprResult add(const ExprPtr &lhs, const ExprPtr &rhs, ComputationContext &context)
static bool te_extract_exp(const std::shared_ptr< SymbolicExpr > &e, const std::string &t, std::shared_ptr< SymbolicExpr > &a_out, std::shared_ptr< SymbolicExpr > &rem_out)
__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 const std::shared_ptr< SymbolicExpr > & a
static std::vector< std::shared_ptr< SymbolicExpr > > te_laplace_roc(const std::shared_ptr< SymbolicExpr > &f, const std::string &t, const std::string &s)
Result< Verified< EvaluatedTransform > > TransformEngineResult
static bool te_is_power_of_var(const std::shared_ptr< SymbolicExpr > &e, const std::string &v, BigInt &n)
static std::shared_ptr< SymbolicExpr > te_laplace_sum(const std::shared_ptr< SymbolicExpr > &f, const AddNode &addition, const std::string &t, const std::string &s, ComputationContext &context)
static std::shared_ptr< SymbolicExpr > te_laplace_lookup(const std::shared_ptr< SymbolicExpr > &f, const std::string &t, const std::string &s, ComputationContext &context)
__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