Reputation: 47
When i try to write the expressions from the code to file, i receive an error:
MethodError: no method matching write(::IOStream, ::SymEngine.Basic)
The code i use is considered to write the expressions to file and then take it from there in other programs. Here's my code:
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
Maybe there is a way to convert SymEngine.Basic
objects to String
and inverse? I could write them as a String
and then convert them back into SymEngine
then.
Upvotes: 0
Views: 244
Reputation: 19132
Do ex = convert(Expr,b)
to change the SymEngine.Basic
into an Expr
. From there, you can convert(String,ex)
, or if you attempt to do things like write it to a file then it will automatically convert to a string.
Upvotes: 0