当我尝试将表达式从代码写入文件时,收到错误消息:
MethodError: no method matching write(::IOStream, ::SymEngine.Basic)
我使用的代码被认为是将表达式写入文件,然后在其他程序中从那里获取。这是我的代码:
using SymEngine
function Legendre(n)
@vars x
a = 1
Pn = (x^2-1)^n
for k = (1:n)
Pn = diff(Pn,x)
a = a*2*k
end
Pn = Pn/a
end
function Asos_Legendre(n,s)
@vars x
Pn=Legendre(n)
for l = (1:s)
Pn = diff(Pn,x)
end
a = (1-x^2)^(s/2)*(-1)^(s)
Pn = Pn*a
end
function Asos_Legendre_diff(n,s)
@vars x
Pn=Asos_Legendre(n,s)
Pn1 = diff(Pn,x)
d = (1-x^2)^(s/2)*(-1)^s
b = x*(-1)^(s+1)*s*(1-x^2)^(s/2-1)
a = Pn1*d + Pn*b
open("C:/stj/Julia/test3.txt", "w") do f
write(f,)
end
end
也许有一种方法可以将SymEngine.Basic
对象转换为String
并进行逆转换?我可以将它们写为String
,然后将它们转换回SymEngine
。
答案 0 :(得分:0)
执行mysql> select host, user from mysql.user;
+--------------+------+
| host | user |
+--------------+------+
| % | john |
| %.10.2.2 | john |
| * | john |
| 172.% | john |
| 172.10.* | john |
| 127.0.0.1 | root |
| 172.10.1.1 | john |
| ::1 | root |
| localhost | |
| localhost | john |
| localhost | root |
+--------------+------+
,将ex = convert(Expr,b)
更改为SymEngine.Basic
。从那里,您可以Expr
,或者如果尝试执行诸如将其写入文件的操作,则它将自动转换为字符串。