These are chat archives for symengine/symengine

20th
Mar 2017
Isuru Fernando
@isuruf
Mar 20 2017 05:16
@prateeksingh0001, that's great. I wonder why cmake didn't give an error if there were dependencies missing
Nikolaus Sonnenschein
@phantomas1234
Mar 20 2017 10:45
@isuruf Will there maybe be a new symengine.py release soon? Don't really have the time to try to install symengine etc. from source but would really like to try symengine/symengine.py#124 by using conda to update symengine.py
Isuru Fernando
@isuruf
Mar 20 2017 10:48
@phantomas1234, we have to do a symengine release before that. We can upload binaries to the symengine/label/dev channel if you like
Send a PR to the dev branch of https://github.com/symengine/python-symengine-feedstock/blob/dev/recipe/meta.yaml#L1-L2 and change the highlighted lines
commit should be the commit you need and version should be the one that git describe --tag gives you with - replaced by .
Nikolaus Sonnenschein
@phantomas1234
Mar 20 2017 10:50
I see, is there a planned release for symengine in the next couple of weeks? If not, binaries would be appreciated. Though I am on a Mac ... maybe I'll give a build from source a quick try.
Isuru Fernando
@isuruf
Mar 20 2017 10:51
Above repo should build binaries for linux, osx and windows automatically through CI
Nikolaus Sonnenschein
@phantomas1234
Mar 20 2017 10:51
Ah I see, I was already wondering if conda somehow supports something like that. Ok, that sounds doable, thanks.
Nikolaus Sonnenschein
@phantomas1234
Mar 20 2017 11:30
@isuruf created symengine/python-symengine-feedstock#1, is that what you suggested?
Isuru Fernando
@isuruf
Mar 20 2017 11:30
Yes, looks good
Isuru Fernando
@isuruf
Mar 20 2017 11:44
@phantomas1234, I merged it, you should see the conda packages in a few minutes
Isuru Fernando
@isuruf
Mar 20 2017 11:49
they are available now.
Christopher Rackauckas
@ChrisRackauckas
Mar 20 2017 18:43
@isuruf what exactly is this warning for?
WARNING: eval from module SymEngine to ParameterizedFunctions:    
Expr(:block, Expr(:line, 60, :/home/crackauc/.julia/v0.5/SymEngine/src/mathops.jl)::Any, Expr(:ccall, Expr(:tuple, :basic_new_stack, :libsymengine)::Any, :Void, Expr(:tuple, Expr(:curly, :Ptr, :Basic)::Any)::Any, Expr(:&, :IM)::Any)::Any, Expr(:line, 61, :/home/crackauc/.julia/v0.5/SymEngine/src/mathops.jl)::Any, Expr(:ccall, (:basic_const_I, "/home/crackauc/.julia/v0.5/SymEngine/deps/usr/lib/libsymengine.so"), :Void, Expr(:tuple, Expr(:curly, :Ptr, :Basic)::Any)::Any, Expr(:&, :IM)::Any)::Any, Expr(:line, 62, :/home/crackauc/.julia/v0.5/SymEngine/src/mathops.jl)::Any, Expr(:call, :finalizer, :IM, :basic_free)::Any)::Any
  ** incremental compilation may be broken for this module **
it seems to work
Isuru Fernando
@isuruf
Mar 20 2017 18:51
How do I reproduce that?
Christopher Rackauckas
@ChrisRackauckas
Mar 20 2017 18:53
oh nevermind
that may be due to my calling of @eval on SymEngine calls.
Isuru Fernando
@isuruf
Mar 20 2017 18:55
let me know if there is anything to be done on the symengine side
Christopher Rackauckas
@ChrisRackauckas
Mar 20 2017 19:06
Is there a reason you can't build a SymEngine.Basic directly from an expression?
Isuru Fernando
@isuruf
Mar 20 2017 19:07
you can right?
Christopher Rackauckas
@ChrisRackauckas
Mar 20 2017 19:09
      for i in eachindex(funcs)
        funcex = funcs[i]
        println(funcex)
        tmp = @eval $funcex
        symfuncs[i] = SymEngine.Basic(tmp)
      end
1x
-3 * y + 1 * x * y * t ^ 2
those are the expressions
when I change it to symfuncs[i] = SymEngine.Basic(funcex) it segfaults
Isuru Fernando
@isuruf
Mar 20 2017 19:11
Ah, I remember this one
1x is printed as 1x, that's why
SymEngine's parser can't handle that
Christopher Rackauckas
@ChrisRackauckas
Mar 20 2017 19:13
could this be added to the convert function?
Isuru Fernando
@isuruf
Mar 20 2017 19:14
I think, instead of converting an Expr to a string and then parsing that in C, it can be done by traversing the expression tree
Christopher Rackauckas
@ChrisRackauckas
Mar 20 2017 19:14
using SymEngine
funcex = :(-3 * y + 1 * x * y * t ^ 2)
SymEngine.Basic(funcex)
that also segfaults though
Isuru Fernando
@isuruf
Mar 20 2017 19:15
it's printed as -3y + 1 * x * y * t ^ 2
funcex = :(y * -3 + 1 * x * y * t ^ 2) doesn't segfault
I think the best option would be to traverse the Expr and replace symbols with symengine symbols
Christopher Rackauckas
@ChrisRackauckas
Mar 20 2017 19:19
that's my other problem though
is there a way to avoid symbols?
      depvar_to_sym_ex = Expr(:(=),depvar,symbols(string(depvar)))
      @eval $depvar_to_sym_ex
I am trying to make it
t = symbols("t")
from an array of symbols depvar
that works, but only with @eval
I'm trying to eliminate all @evals though
but that's not possible, because making that statement requires the runtime values of the depvar array
Isuru Fernando
@isuruf
Mar 20 2017 19:20
I'm not sure I understand
Christopher Rackauckas
@ChrisRackauckas
Mar 20 2017 19:21
depvar = :t 
depvar_to_sym_ex = Expr(:(=),depvar,symbols(string(depvar)))
@eval $depvar_to_sym_ex
because later I am going to want to diff(SymEngine.Basic(symfuncs[i]),depvar)
but can this be done without the @eval?
It seems like t = symbols("t") is going to require an @eval since it's built using runtime values (the symbol :t isn't known at compile-time generally)
Isuru Fernando
@isuruf
Mar 20 2017 19:23
diff(SymEngine.Basic(symfuncs[i]),:t)
does this work for you?
Christopher Rackauckas
@ChrisRackauckas
Mar 20 2017 19:24
not without making t a symbol
at least inside of this code
let me try it out more
I was getting a segfault
oh no, it seems related to the first problem
Christopher Rackauckas
@ChrisRackauckas
Mar 20 2017 19:58
function flip_mult!(ex)
  for (i,arg) in enumerate(ex.args)
    if isa(arg,Expr)
      if arg.args[1] == :(*) && length(arg.args) >= 3 && (isa(arg.args[2], Number) || (isa(arg.args[2], Expr) && arg.args[2].args[1] == :-))
        arg.args[3],arg.args[2] = arg.args[2], arg.args[3]
      else
        flip_mult!(arg)
      end
    end
  end
end
got them all flipped
Isuru Fernando
@isuruf
Mar 20 2017 20:08
Can you send a PR?
Christopher Rackauckas
@ChrisRackauckas
Mar 20 2017 20:08
I'll see if I get to it
trying to hammer this out right now
I will sooner or later
Isuru Fernando
@isuruf
Mar 20 2017 20:09
okay. going to sleep now. I'll have a try too if I get some time tomorrow.
Christopher Rackauckas
@ChrisRackauckas
Mar 20 2017 20:10
alright
Christopher Rackauckas
@ChrisRackauckas
Mar 20 2017 20:55
hmm, so you can differentiate erf now?
dang, need a new test
Christopher Rackauckas
@ChrisRackauckas
Mar 20 2017 21:32
@isuruf seems to do well now. But differentiating by symbols like this can do things like differentiate erf, but returns expressions that aren't Julia expressions
like erf -> E^ ...
is there a way to make that in terms of a Julia expression, like using exp?
Christopher Rackauckas
@ChrisRackauckas
Mar 20 2017 23:17
Expr(:block, Expr(:line, 60, :/home/crackauc/.julia/v0.5/SymEngine/src/mathops.jl)::Any, Expr(:ccall, Expr(:tuple, :basic_new_stack, :libsymengine)::Any, :Void, Expr(:tuple, Expr(:curly, :Ptr, :Basic)::Any)::Any, Expr(:&, :IM)::Any)::Any, Expr(:line, 61, :/home/crackauc/.julia/v0.5/SymEngine/src/mathops.jl)::Any, Expr(:ccall, (:basic_const_I, "/home/crackauc/.julia/v0.5/SymEngine/deps/usr/lib/libsymengine.so"), :Void, Expr(:tuple, Expr(:curly, :Ptr, :Basic)::Any)::Any, Expr(:&, :IM)::Any)::Any, Expr(:line, 62, :/home/crackauc/.julia/v0.5/SymEngine/src/mathops.jl)::Any, Expr(:call, :finalizer, :IM, :basic_free)::Any)::Any
  ** incremental compilation may be broken for this module **
still throws this error when precompilating a package with a SymEngine.jl dependency
I'm only using the Basic type for its dispatches, and the differentiation stuff.
and it seems fine