GithubHelp home page GithubHelp logo

symengine.jl's Introduction

SymEngine

Build and test symengine Build status codecov.io

SymEngine is a standalone fast C++ symbolic manipulation library. Optional thin wrappers allow usage of the library from other languages, e.g.:

Try SymEngine

Tutorials are at SymEngine.org.

Run an interactive C++ session with SymEngine using Binder.

License

All files are licensed under MIT license, see the LICENSE for more information. Third party code packaged are licensed under BSD 3-clause license (see the LICENSE file).

Mailinglist, Chat

SymEngine mailinglist: http://groups.google.com/group/symengine

Gitter

Installation

Conda package manager

conda install symengine -c conda-forge

Conan package manager

conan install symengine/<version>@

Building from source

Install prerequisites. For Debian based systems (Ubuntu etc.):

apt-get install cmake libgmp-dev

For RPM based systems (Fedora etc.):

yum install cmake gmp-devel

Install SymEngine:

mkdir build && cd build
cmake ..
make
make install

This will configure and build SymEngine in the default Release mode with all code and compiler optimizations on and then install it on your system.

Run tests:

ctest

Development

GitHub Actions checks the code in both Release and Debug mode with all possible checks, so just sending a GitHub pull request is enough and you can use any mode you want to develop it. However, the best way to develop SymEngine on Linux is to use the Debug mode with BFD support on:

cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_BFD=yes ..

This BFD support turns on nice Python-like stack traces on exceptions, assert errors or segfaults, and the Debug mode automatically turns on WITH_SYMENGINE_RCP=no (which uses Teuchos::RCP with full Debug time checking) and WITH_SYMENGINE_ASSERT=yes, so the code cannot segfault in Debug mode, as long as our style conventions (e.g. no raw pointers) are followed, which is easy to check by visual inspection of a given Pull Request. In Release mode, which is the default, the code is as performing a manual reference counting and raw pointers (and if there is a bug, it could segfault, in which case all you have to do is to turn Debug mode on and get a nice exception with a stack trace).

To make WITH_BFD=yes work, you need to install binutils-dev first, otherwise, you will get a CMake error during configuring. For Debian-based systems (Ubuntu etc.)

apt-get install binutils-dev

For RPM-based systems (Fedora etc.)

yum install binutils-devel

On OpenSuSE, you will additionally need glibc-devel.

CMake Options

Here are all the CMake options that you can use to configure the build, with their default values are indicated below:

cmake -DCMAKE_INSTALL_PREFIX:PATH="/usr/local" \  # Installation prefix
    -DCMAKE_BUILD_TYPE:STRING="Release" \         # Type of build, one of: Debug or Release
    -DWITH_BFD:BOOL=OFF \                         # Install with BFD library (requires binutils-dev)s
    -DWITH_SYMENGINE_ASSERT:BOOL=OFF \            # Test all SYMENGINE_ASSERT statements in the code
    -DWITH_SYMENGINE_RCP:BOOL=ON \                # Use our faster special implementation of RCP
    -DWITH_SYMENGINE_THREAD_SAFE:BOOL=OFF \       # Build with thread safety
    -DWITH_ECM:BOOL=OFF \                         # Build with GMP-ECM library for integer factorization
    -DWITH_PRIMESIEVE:BOOL=OFF \                  # Install with Primesieve library
    -DWITH_FLINT:BOOL=OFF \                       # Install with Flint library
    -DWITH_ARB:BOOL=OFF \                         # Install with ARB library
    -DWITH_TCMALLOC:BOOL=OFF \                    # Install with TCMalloc linked
    -DWITH_OPENMP:BOOL=OFF \                      # Install with OpenMP enabled
    -DWITH_PIRANHA:BOOL=OFF \                     # Install with Piranha library
    -DWITH_MPFR:BOOL=OFF \                        # Install with MPFR library
    -DWITH_MPC:BOOL=OFF \                         # Install with MPC library
    -DWITH_LLVM:BOOL=OFF \                        # Build with LLVM libraries
    -DWITH_SYSTEM_CEREAL:BOOL=OFF \               # Build with cereal headers from the system instead of
                                                    the vendored copy
    -DBUILD_TESTS:BOOL=ON \                       # Build with tests
    -DBUILD_BENCHMARKS:BOOL=ON \                  # Build with benchmarks
    -DBUILD_BENCHMARKS_GOOGLE:BOOL=OFF \          # Build with Google Benchmark benchmarks
    -DINTEGER_CLASS:STRING=gmp \                  # Choose storage type for Integer. one of gmp, gmpxx,
                                                    flint, piranha, boostmp
    -DBUILD_SHARED_LIBS:BOOL=OFF \                # Build a shared library.
    -DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=OFF\ # Add dependencies to rpath when a shared lib is built
    ..

If OpenMP is enabled, then SYMENGINE_THREAD_SAFE is also enabled automatically irrespective of the user input for WITH_SYMENGINE_THREAD_SAFE.

CMake prints the value of its options at the end of the run. If you want to use a different compiler, do:

CC=clang CXX=clang++ cmake ..

If you want to set additional compilation flags, do:

CXXFLAGS="$CXXFLAGS -march=native" cmake ..

These environment variables are checked only in the first run of cmake and you have to delete the build directory or CMakeCache.txt file for these environment variables to be picked up in subsequent runs.

Using INTEGER_CLASS=boostmp would remove the dependency on gmp and use boost's multiprecision integer and rational classes. This would make boost, the only dependency and all the code would be under permissive licenses, namely, MIT, BSD 3-clause and Boost License.

Piranha (WITH_PIRANHA) depends on Boost, so it is off by default. The benchmarked code seems to depend on the order in which you execute the benchmarks in a given executable, due to internal malloc implementation. We have found that this order dependence is reduced by enabling WITH_TCMALLOC=ON and since it also speeds the benchmarks up, we recommend to always use TCMalloc when benchmarking (and the Release mode of SymEngine, which is the default).

External Libraries

Use CMAKE_PREFIX_PATH to specify the prefixes of the external libraries.

cmake -DCMAKE_PREFIX_PATH=<prefix1>;<prefix2>

If the headers and libs are not in <prefix>/include and <prefix>/lib respectively, use CMAKE_LIBRARY_PATH and CMAKE_INCLUDE_PATH.

If CMake still cannot find the library, you can specify the path to the library by doing cmake -DPKG_LIBRARY=/path/libname.so ., where PKG should be replaced with the name of the external library (GMP, ARB, BFD, FLINT, MPFR, ...). Similarly, -DPKG_INCLUDE_DIR can be used for headers.

Recommended options to build

For package managers

For packaging symengine it is recommended to use GMP, MPFR, MPC, FLINT, LLVM as dependencies if they are available and built with thread safety on.

cmake -DWITH_GMP=on -DWITH_MPFR=on -DWITH_MPC=on -DINTEGER_CLASS=flint -DWITH_LLVM=on
-DWITH_SYMENGINE_THREAD_SAFE=on ..

Optimized build

To build with more optimizations, you can use the above dependencies and options, and also,

CXXFLAGS="-march=native -O3" cmake -DWITH_TCMALLOC=on -DWITH_SYMENGINE_THREAD_SAFE=no ..

Developer Documentation

Please follow the C++ Style Guide when developing.

The design decisions are documented in Design.

symengine.jl's People

Contributors

abelsiqueira avatar ahumenberger avatar certik avatar chrisrackauckas avatar djsegal avatar fatteneder avatar giggleliu avatar haozeke avatar isuruf avatar jeremiahpslewis avatar johanbluecreek avatar juliatagbot avatar jverzani avatar kunalsinx avatar matbesancon avatar mforets avatar oxinabox avatar performancecoder avatar pfitzseb avatar ranocha avatar saschatimme avatar sglyon avatar shikharj avatar staticfloat avatar sylvaticus avatar tkf avatar torque avatar wildart avatar yingboma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

symengine.jl's Issues

Build error on OS X

Using julia v0.5, OS X 10.12 Sierra:

julia> Pkg.build("Symengine")
INFO: Building Conda
INFO: Building Symengine
Warning: 'conda-forge' already in 'channels' list, moving to the top
Warning: 'symengine' already in 'channels' list, moving to the top
====================================================[ ERROR: Symengine ]====================================================

LoadError: failed process: Process(setenv(`/Users/cbinz/.julia/v0.5/Symengine/deps/usr/bin/conda search symengine --json`,String["CLICOLOR=1","LSCOLORS=gxfxbEaEBxxEhEhBaDaCaD","COMMAND_MODE=unix2003","PATH=/Applications/Julia-0.5.app/Contents/Resources/julia/bin:/Applications/Julia-0.5.app/Contents/Resources/julia/bin:/Users/cbinz/anaconda/bin:/usr/local/bin:/user/local/bin://anaconda/bin:/usr/local/heroku/bin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/git/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/TeX/texbin","PWD=/Users/cbinz","XPC_FLAGS=0x0","DISPLAY=/private/tmp/com.apple.launchd.ExMCGUy1gP/org.macosforge.xquartz:0","XPC_SERVICE_NAME=0","TERM_PROGRAM=iTerm.app","SHELL=/bin/bash","ITERM_PREV_PS1=\\[\e]133;D;\$?\a\e]1337;[email protected]\a\e]1337;CurrentDir=/Users/cbinz\a\e]1337;SetUserVar=gitProjectDir=\a\e]133;A\a\\]\\h:\\W \\u\\\$ \\[\e]133;B\a\\]","__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0","COLORFGBG=12;8","TMPDIR=/var/folders/sm/j5dkyxzs38l0gp30b8wv78340000gn/T/","TK_LIBRARY=/System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts","CONDARC=/Users/cbinz/.julia/v0.5/Symengine/deps/usr/condarc-julia.yml","FONTCONFIG_PATH=/Applications/Julia-0.5.app/Contents/Resources/julia/etc/fonts","LANG=en_US.UTF-8","ITERM_PROFILE=Default","PS1=\\h:\\W \\u\\\$ ","SHLVL=1","LOGNAME=cbinz","CONDA_PREFIX=/Users/cbinz/.julia/v0.5/Symengine/deps/usr","OLDPWD=/Users/cbinz/org-notes","TERM_SESSION_ID=w0t1p0:485856A5-52FC-40D7-BD9C-96E41817368F","SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.8c3NvEVVWg/Listeners","_=/usr/local/bin/julia","CONDA_DEFAULT_ENV=/Users/cbinz/.julia/v0.5/Symengine/deps/usr","Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.no6DkFrRxv/Render","USER=cbinz","SECURITYSESSIONID=186a6","ITERM_ORIG_PS1=\\h:\\W \\u\\\$ ","ITERM_SESSION_ID=w0t1p0:485856A5-52FC-40D7-BD9C-96E41817368F","TERM=xterm-256color","HOME=/Users/cbinz","TERM_PROGRAM_VERSION=3.0.14","OPENBLAS_MAIN_FREE=1"]), ProcessExited(1)) [1]
while loading /Users/cbinz/.julia/v0.5/Symengine/deps/build.jl, in expression starting on line 19

============================================================================================================================

======================================================[ BUILD ERRORS ]======================================================

WARNING: Symengine had build errors.

 - packages with build errors remain installed in /Users/cbinz/.julia/v0.5
 - build the package(s) and all dependencies with `Pkg.build("Symengine")`
 - build a single package by running its `deps/build.jl` script

============================================================================================================================

"sin(x + PI/4)" gives "sin(x)"

Using SymEngine v0.1.5 on julia v0.6.0-rc1, I get

julia> using SymEngine
julia> @vars x
(x,)
julia> sin(x + PI/4)
sin(x)
# on the other hand
julia> sin(x + PI/2)
cos(x)
julia> sin(x + PI/8)
sin(x + (1/8)*pi)

Likewise for cos and with -PI/4.

Lambdify and BigInts

Hi,

I've been running into a problem with Lambdify. Specifically, that it produces BigInts inside the expressions it generates. For example, a derivative of one of the functions I am using is given by

0. + 1.01010101010101*c^(-0.684931506849315)*E^(-(0.0015 + ฯต_ฮ˜))/EUcM.

What Lambdify constructs an expression for the function it creates

0. + 1.01010101010101*c^(-0.684931506849315)*e^(-1*(0.0015 + ฯต_ฮ˜))*EUcM^(-1)

with both of the -1s being of type BigInt. The resulting lambda function runs 10 times slower than if I redid the expression converting the -1s to floats, i.e.

0. + 1.01010101010101*c^(-0.684931506849315)*e^(-1.0*(0.0015 + ฯต_ฮ˜))*EUcM^(-1.0)

Is there any way to tell SymEngine to convert to Int64 rather that BigInt? The extra precision is unnecessary for me, and the resulting code will be used in the innermost loop of my numeric simulations. This is a fantastic library. Thank you for all your work.

David

On creating an array of variables and pulling variables out of expressions

I have two questions:

  1. How to create an array of symbolic variables at one time? Say, "x1,x2,...,x100"
  2. How to pull out the list of symbolic variables that appears in an expressions? Say, pulling out ["x", "y"] from "x+y" where those are two symbols.
    I looked into test files but found nothing. I'd appreciate if you shed light on them,

Why the need to install Miniconda?

I have a anaconda version installed on my PC and in Julia the environment variable set
ENV["PYTHON"]="/anaconda3/bin/python"
and the Conda Package installed and build with this variable.

Why does the SymEngine then need to install Miniconda on my PC? Does it not work with Python 3?

CI failure on OSX

getting this error GMP library being linked is not supported by CMAKE_CXX_COMPILER
while running .travis.yml on osx

Could not load library "libsymengine"

Running simple commands error:

using SymEngine
x,y = symbols("x,y")
symfunc = 1.5 * x - 1 * x * y

error compiling *: error compiling convert: could not load library "libsymengine"
The specified module could not be found.

When I try to re-build, it seems like it already worked:

Pkg.build("SymEngine")
INFO: Building SymEngine
Warning: 'conda-forge' already in 'channels' list, moving to the front
Warning: 'symengine' already in 'channels' list, moving to the front
Fetching package metadata ...
.......
.
.
.
Solving package specifications: ..........

# All requested packages already installed.
# packages in environment at C:\Users\Chris\.julia\v0.6\Conda\deps\usr:
#
python                    3.5.2                         2    conda-forge

Some possible new methods to add to support generic programming

I'm not sure the following suggestions are the best way to do this, but it seems the following could be added to support generic programming:

isinf(x::SymbolicType) = isinf(N(x))

isfinite(x::SymbolicType) = isfinite(N(x))

isnan(x::SymbolicType) = isnan(N(x))

isless(x::SymbolicType, y::SymbolicType) = N(x) < N(y)

As well, there is no call method. Following SymPy.jl these could be defined by

function (ex::SymbolicType)(args...)
     xs = free_symbols(ex)
    subs(ex, collect(zip(xs, args))...)
end
(ex::SymbolicType)(x::Dict) = subs(ex, x)
(ex::SymbolicType)(x::Pair...) = subs(ex, x...)   

or for v0.4:

function Base.call{T <: SymbolicType}(ex::T, args...)
   xs = free_symbols(ex)
   subs(ex, collect(zip(xs, args))...)
end
Base.call(ex::SymbolicType, x::Dict) = subs(ex, x)
Base.call(ex::SymbolicType, x::Pair...) = subs(ex, x...)

Finally, I was surprised that there is no conversion defined for Float64. Would something like this be reasonable:

Base.convert{T <: Real}(::Type{T}, x::Basic) = convert(T, N(x))
Base.convert{T}(::Type{Complex{T}}, x::Basic) = convert(Complex{T}, N(x))

Create SymEngine.Basic from julia Expr

I have a use case where I'm trying to create an instance of Basic from a Julia Expr and a vector of symbols.

I have something like this

syms = [:x, :y, :z]
ex = :(x * y  - x * z)

And I'd like to be able to do something like this:

using SymEngine
symengine_syms = map(symbols, syms)
eq = Basic(ex, symengine_syms)

The method Basic(::Expr, ::Vector{Basic}) doesn't exist. Any ideas how to create it?

Specifying Derivatives

I see that the derivative functionality is heavily increased! Using ParameterizedFunctions (which uses SymEngine in it), the differential equation

println("Test difficult differentiable")
NJ = @ode_def_nohes DiffDiff begin
  dx = a*x - b*x*y
  dy = -c*y + erf(x*y/d)
end a=>1.5 b=>1 c=3 d=4

is able to accurately build its Jacobian:

println(NJ.Jex)
# output
begin 
    J[1,1] = p.a - p.b * u[2]
    J[1,2] = -(p.b) * u[1]
    J[2,1] = ((1 / 2) * u[2] * E ^ ((-1 / 16) * u[1] ^ 2 * u[2] ^ 2)) / sqrt(pi)
    J[2,2] = -3 + ((1 / 2) * u[1] * E ^ ((-1 / 16) * u[1] ^ 2 * u[2] ^ 2)) / sqrt(pi)
    nothing
end

The Julia function it creates (has that body, with the signature (t,u,J) doesn't currently work, but that sounds like it will be solved by symengine/symengine#1225. Wondering how far this new derivative engine goes, I tested what happens when I wrap something in a function:

test_fail(x,y,d) = erf(x*y/d)
println("Test non-differentiable")
NJ = @ode_def NoJacTest begin
  dx = a*x - b*x*y
  dy = -c*y + test_fail(x,y,d)
end a=>1.5 b=>1 c=3 d=4
NJ(t,u,du)
@test du == [-3.0;-3*3.0 + erf(2.0*3.0/4)]
@test du == NJ(t,u)

and it gives

println(NJ.Jex)
# output
begin 
    J[1,1] = p.a - p.b * u[2]
    J[1,2] = -(p.b) * u[1]
    J[2,1] = Derivative(test_fail(u[1],u[2],4),u[1])
    J[2,2] = -3 + Derivative(test_fail(u[1],u[2],4),u[2])
    nothing
end

This derivative is unknown, but now it looks like a function? How do we overload that Derivative function? It would be nice to document that, and I'll pass my users onto those docs.

Error when building SymEngine, saying that "conda is doing something else"

Error message:

julia> Pkg.update()
INFO: Updating METADATA...
INFO: Updating DifferentialEquations master...
INFO: Updating OrdinaryDiffEq master...
INFO: Updating Plots master...
INFO: Computing changes...
INFO: Installing SymEngine v0.1.2
INFO: Building Conda
INFO: Building SymEngine
Fetching package metadata: ....
Solving package specifications: .........

Package plan for installation in environment C:\Users\migos\.julia\v0.5\SymEngine\deps\usr:

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    zlib-1.2.8                 |                0         116 KB

The following NEW packages will be INSTALLED:

    zlib: 1.2.8-0

Fetching packages ...
    LOCKERROR: It looks like conda is already doing something.
    The lock [u'C:\\Users\\migos\\.julia\\v0.5\\Conda\\deps\\usr\\pkgs\\.conda_lock-9344'] was found. Wait for it to finish before continuing.
    If you are sure that conda is not running, remove it and try again.
    You can also use: $ conda clean --lock
Sleeping for 1 seconds
    LOCKERROR: It looks like conda is already doing something.
    The lock [u'C:\\Users\\migos\\.julia\\v0.5\\Conda\\deps\\usr\\pkgs\\.conda_lock-9344'] was found. Wait for it to finish before continuing.
    If you are sure that conda is not running, remove it and try again.
    You can also use: $ conda clean --lock
Sleeping for 2 seconds
    LOCKERROR: It looks like conda is already doing something.
    The lock [u'C:\\Users\\migos\\.julia\\v0.5\\Conda\\deps\\usr\\pkgs\\.conda_lock-9344'] was found. Wait for it to finish before continuing.
    If you are sure that conda is not running, remove it and try again.
    You can also use: $ conda clean --lock
Sleeping for 4 seconds
    LOCKERROR: It looks like conda is already doing something.
    The lock [u'C:\\Users\\migos\\.julia\\v0.5\\Conda\\deps\\usr\\pkgs\\.conda_lock-9344'] was found. Wait for it to finish before continuing.
    If you are sure that conda is not running, remove it and try again.
    You can also use: $ conda clean --lock
Sleeping for 8 seconds
    LOCKERROR: It looks like conda is already doing something.
    The lock [u'C:\\Users\\migos\\.julia\\v0.5\\Conda\\deps\\usr\\pkgs\\.conda_lock-9344'] was found. Wait for it to finish before continuing.
    If you are sure that conda is not running, remove it and try again.
    You can also use: $ conda clean --lock
Sleeping for 16 seconds
    LOCKERROR: It looks like conda is already doing something.
    The lock [u'C:\\Users\\migos\\.julia\\v0.5\\Conda\\deps\\usr\\pkgs\\.conda_lock-9344'] was found. Wait for it to finish before continuing.
    If you are sure that conda is not running, remove it and try again.
    You can also use: $ conda clean --lock
Sleeping for 32 seconds
    LOCKERROR: It looks like conda is already doing something.
    The lock [u'C:\\Users\\migos\\.julia\\v0.5\\Conda\\deps\\usr\\pkgs\\.conda_lock-9344'] was found. Wait for it to finish before continuing.
    If you are sure that conda is not running, remove it and try again.
    You can also use: $ conda clean --lock
Sleeping for 64 seconds
Traceback (most recent call last):
  File "C:\Users\migos\.julia\v0.5\Conda\deps\usr\Scripts\conda-script.py", line 5, in <module>
    sys.exit(main())
  File "C:\Users\migos\.julia\v0.5\Conda\deps\usr\lib\site-packages\conda\cli\main.py", line 139, in main
    args_func(args, p)
  File "C:\Users\migos\.julia\v0.5\Conda\deps\usr\lib\site-packages\conda\cli\main.py", line 146, in args_func
    args.func(args, p)
  File "C:\Users\migos\.julia\v0.5\Conda\deps\usr\lib\site-packages\conda\cli\main_create.py", line 49, in execute
    install.install(args, parser, 'create')
  File "C:\Users\migos\.julia\v0.5\Conda\deps\usr\lib\site-packages\conda\cli\install.py", line 424, in install
    plan.execute_actions(actions, index, verbose=not args.quiet)
  File "C:\Users\migos\.julia\v0.5\Conda\deps\usr\lib\site-packages\conda\plan.py", line 539, in execute_actions
    inst.execute_instructions(plan, index, verbose)
  File "C:\Users\migos\.julia\v0.5\Conda\deps\usr\lib\site-packages\conda\instructions.py", line 149, in execute_instructions
    cmd(state, arg)
  File "C:\Users\migos\.julia\v0.5\Conda\deps\usr\lib\site-packages\conda\instructions.py", line 52, in FETCH_CMD
    fetch(state['index'], arg)
  File "C:\Users\migos\.julia\v0.5\Conda\deps\usr\lib\site-packages\conda\instructions.py", line 48, in fetch
    fetch_pkg(index[fn])
  File "C:\Users\migos\.julia\v0.5\Conda\deps\usr\lib\site-packages\conda\fetch.py", line 296, in fetch_pkg
    download(url, path, session=session, md5=info['md5'], urlstxt=True)
  File "C:\Users\migos\.julia\v0.5\Conda\deps\usr\lib\site-packages\conda\fetch.py", line 329, in download
    with Locked(dst_dir):
  File "C:\Users\migos\.julia\v0.5\Conda\deps\usr\lib\site-packages\conda\lock.py", line 58, in __enter__
    sleep(sleeptime)
KeyboardInterrupt
==================================================[ ERROR: SymEngine ]==================================================

LoadError: InterruptException:
while loading C:\Users\migos\.julia\v0.5\SymEngine\deps\build.jl, in expression starting on line 9

========================================================================================================================
ERROR: InterruptException:
 in process_events(::Bool) at .\libuv.jl:82
 in wait() at .\event.jl:147
 in wait(::Condition) at .\event.jl:27
 in stream_wait(::Base.Process, ::Condition, ::Vararg{Condition,N}) at .\stream.jl:44
 in wait(::Base.Process) at .\process.jl:716
 in build!(::Array{String,1}, ::Dict{Any,Any}, ::Set{Any}) at .\pkg\entry.jl:621
 in build(::Array{String,1}) at .\pkg\entry.jl:641
 in resolve(::Dict{String,Base.Pkg.Types.VersionSet}, ::Dict{String,Dict{VersionNumber,Base.Pkg.Types.Available}}, ::Dict{String,Tuple{VersionNumber,Bool}}, ::Dict{String,Base.Pkg.Types.Fixed}, ::Dict{String,VersionNumber}, ::Set{String}) at .\pkg\entry.jl:557
 in update(::String, ::Set{String}) at .\pkg\entry.jl:458
 in (::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#update,Tuple{String,Set{String}}})() at .\pkg\dir.jl:31
 in cd(::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#update,Tuple{String,Set{String}}}, ::String) at .\file.jl:48
 in #cd#1(::Array{Any,1}, ::Function, ::Function, ::String, ::Vararg{Any,N}) at .\pkg\dir.jl:31
 in update() at .\pkg\pkg.jl:210

I can assure you the following two:

  1. When this error occurs, there is not instance of python, or any other instance of Julia running.
  2. This error is thrown when I do a package update. However, in a what seems a random way, sometimes the error happens, sometimes not... ALL times I do pkg.update, I have no other instance of python or julia running!

Segfault converting equations

Hello SymEngine developers,
Is it possible to define symbolic equations with SymEngine? In the trace shown below, i get a segfault when i try to convert the expression y = x+1 to a Basic object. Is this a bug?

On a separate note, is there a notion of symbolic derivative in SymEngine? Again, convert(Basic, :(x')) breaks with a segfault in my machine.

julia> versioninfo()
Julia Version 0.6.1
Commit 0d7248e (2017-10-24 22:15 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, haswell)

julia> using SymEngine

julia> Pkg.installed("SymEngine")
v"0.3.0"

julia> convert(Basic, :(y)) # ok
y

julia> convert(Basic, :(x+1)) # ok
1 + x

julia> convert(Basic, :(y = x+1)) # error

signal (11): Segmentation fault: 11
while loading no file, in expression starting on line 0
_ZN9SymEngine10StrPrinter5applyERKNS_3RCPIKNS_5BasicEEE at /Users/forets/.julia/v0.6/Conda/deps/usr/lib/libsymengine.0.3.dylib (unknown line)
basic_str_julia at /Users/forets/.julia/v0.6/Conda/deps/usr/lib/libsymengine.0.3.dylib (unknown line)
toString at /Users/forets/.julia/v0.6/SymEngine/src/display.jl:4
show at /Users/forets/.julia/v0.6/SymEngine/src/display.jl:10
unknown function (ip: 0x123a77876)
display at ./REPL.jl:122
unknown function (ip: 0x123a774c6)
display at ./REPL.jl:125
unknown function (ip: 0x123a77176)
display at ./multimedia.jl:194
unknown function (ip: 0x123a76f62)
do_call at /Users/vagrant/buildbot/worker/package_osx64/build/src/interpreter.c:75
eval at /Users/vagrant/buildbot/worker/package_osx64/build/src/interpreter.c:242
eval_body at /Users/vagrant/buildbot/worker/package_osx64/build/src/interpreter.c:539
jl_toplevel_eval_body at /Users/vagrant/buildbot/worker/package_osx64/build/src/interpreter.c:511
jl_toplevel_eval_flex at /Users/vagrant/buildbot/worker/package_osx64/build/src/toplevel.c:571
jl_toplevel_eval_in at /Users/vagrant/buildbot/worker/package_osx64/build/src/builtins.c:496
eval at ./boot.jl:235
jlcall_eval_18068 at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
print_response at ./REPL.jl:144
unknown function (ip: 0x123a764d8)
print_response at ./REPL.jl:129
unknown function (ip: 0x123a75e48)
do_respond at ./REPL.jl:646
unknown function (ip: 0x123a74df1)
do_call at /Users/vagrant/buildbot/worker/package_osx64/build/src/interpreter.c:75
eval at /Users/vagrant/buildbot/worker/package_osx64/build/src/interpreter.c:242
eval_body at /Users/vagrant/buildbot/worker/package_osx64/build/src/interpreter.c:539
jl_toplevel_eval_body at /Users/vagrant/buildbot/worker/package_osx64/build/src/interpreter.c:511
jl_toplevel_eval_flex at /Users/vagrant/buildbot/worker/package_osx64/build/src/toplevel.c:571
jl_toplevel_eval_in at /Users/vagrant/buildbot/worker/package_osx64/build/src/builtins.c:496
eval at ./boot.jl:235
jlcall_eval_18068 at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
run_interface at ./LineEdit.jl:1583
jlcall_run_interface_20155 at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
run_frontend at ./REPL.jl:945
run_repl at ./REPL.jl:180
unknown function (ip: 0x123a483d2)
_start at ./client.jl:413
jlcall__start_18944 at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
true_main at /Applications/Julia-0.6.app/Contents/Resources/julia/bin/julia (unknown line)
main at /Applications/Julia-0.6.app/Contents/Resources/julia/bin/julia (unknown line)
Allocations: 3053903 (Pool: 3052611; Big: 1292); GC: 4
Segmentation fault: 11

Get a list of variables from an expression

For example,

@vars x1 x2
X = x1^2 + (x2 + 1)^2 
Y = diff(X, x1) # involves only x1
X = x2 * x1^2 + (x2 + 1)^2 
Y = diff(X, x1) # involves both x1 and x2

Y is a partial derivative of X, but the number of variables in Y depends on how X is formulated. For the realization of Y, one needs to know what variables it contains.

Build Error

I just installed JuliaPRO and I am getting this error, not sure why it is trying to access Users\julia since that directory doesn't exist. Do I need to install 7-zip?

julia> Pkg.update()
INFO: Updating METADATA...
INFO: Computing changes...
INFO: Installing SymEngine v0.2.0
INFO: Building Conda
INFO: Building SymEngine
INFO: Attempting to Create directory C:\Users\frommet\AppData\Local\JuliaPro-0.5
.2.2\pkgs-0.5.2.2\v0.5\SymEngine\deps\downloads
INFO: Downloading file https://github.com/symengine/symengine/releases/download/
v0.3.0/symengine-0.3.0-binaries-msvc-x86_64.tar.bz2
INFO: Done downloading file https://github.com/symengine/symengine/releases/down
load/v0.3.0/symengine-0.3.0-binaries-msvc-x86_64.tar.bz2
INFO: Attempting to Create directory C:\Users\frommet\AppData\Local\JuliaPro-0.5
.2.2\pkgs-0.5.2.2\v0.5\SymEngine
INFO: Directory C:\Users\frommet\AppData\Local\JuliaPro-0.5.2.2\pkgs-0.5.2.2\v0.
5\SymEngine already created
==============================[ ERROR: SymEngine ]==============================


LoadError: could not spawn `'C:\Users\julia\AppData\Local\Julia-0.5.2\bin\7z.exe
' x 'C:\Users\frommet\AppData\Local\JuliaPro-0.5.2.2\pkgs-0.5.2.2\v0.5\SymEngine
\deps\downloads\symengine-0.3.0-binaries-msvc-x86_64.tar.bz2' -y -so`: no such f
ile or directory (ENOENT)
while loading C:\Users\frommet\AppData\Local\JuliaPro-0.5.2.2\pkgs-0.5.2.2\v0.5\
SymEngine\deps\build.jl, in expression starting on line 50

================================================================================


================================[ BUILD ERRORS ]================================


WARNING: SymEngine had build errors.

 - packages with build errors remain installed in C:\Users\frommet\AppData\Local
\JuliaPro-0.5.2.2\pkgs-0.5.2.2\v0.5
 - build the package(s) and all dependencies with `Pkg.build("SymEngine")`
 - build a single package by running its `deps/build.jl` script

================================================================================

Tag a version?

Some v0.6 compatibility commits haven't been tagged. I would like a tag so I can start testing the DiffEq stack. It seems all the tests pass with SymEngine master, so a new tag will be required before DiffEq can start tagging for v0.6

Operation on Complex Numbers

Hi,
I am trying to use SymEngine with complex numbers but somehow I am not really managing to get started. Something I am wondering about is: In the following, should the second line either result simply in a (if a and be are assumed to be real from the beginning) or something like real(a) - imag(b) (if they are assumed to be complex from the beginngin). Is there a special way to treat complex numbers in SymEngine?

julia> @vars a b
(a, b)

julia> a + im*b |> real
a + I*b

Thank you,
Tim

More predictable order of parameters

For example here is a toy implementation of deepest descent algorithm:

using SymEngine
using Roots

x1, x2 = symbols("x1, x2")
x1_val = 1
x2_val = 1
@vars s t
F(x1, x2) = (x1 - 1)^2 + x2^3 - x1 * x2
dFx1 = diff(F(x1, x2), x1)
dFx2 = diff(F(x1, x2), x2)
dFx1(x1_val, x2_val)
dFx2(x1_val, x2_val)
newx1 = x1 - s * dFx1
newx2 = x2 - s * dFx2
newx1(s, x2_val, x1_val)
newx2(s, x2_val, x1_val)
ฯ• = F(newx1, newx2)
dฯ• = diff(ฯ•, s)
dฯ•(s, x2_val, x1_val)

while true 
  s_val = fzero(dฯ•(s, x2_val, x1_val), 0.1)
  tmp1 = newx1(s_val, x2_val, x1_val)
  tmp2 = newx2(s_val, x2_val, x1_val)
  if abs(tmp1 - x1_val) < 1e-8 && abs(tmp2 - x2_val) < 1e-8 
    break
  else 
    x1_val = tmp1 
    x2_val = tmp2
  end
end

As you can see, the expression dFx1 takes x1, x2 as parameters, while newx1 takes s, x2, x1 as parameters, in that order. There is no logic in this and it is awkward to use.

Would be nice if the parameters are ordered by a certain rule.

Install fails due to missing file or directory

While installing julia 0.6.2 on Mac OS 10.12.6, I got the following error:

LoadError: could not spawn setenv(
`/Users/user/.julia/v0.6/SymEngine/deps/usr/bin/conda config --add channels conda-forge --force`<...>
): no such file or directory (ENOENT)

There is no bin directory in the SymEngine package at the specified folder.
The Conda package is installed and works (tested with using Conda).
Conda.runconda(info) return for the channels:

channel URLs : https://conda.anaconda.org/conda-forge/osx-64
                          https://conda.anaconda.org/conda-forge/noarch

I therefore see no reason to add the forge channel.
It looks to me like the install is not using the actual Conda package.
CONDARC , CONDA_DEFAULT_ENV and CONDA_PREFIX all point to the SymEngine package and not the actual Conda package.

Build error

Not sure if this is due to SymEngine or due to the fact that Conda.jl has been causing lots of problems for me recently with every library. @isuruf

INFO: Building Conda
INFO: Building SymEngine
Warning: 'conda-forge' already in 'channels' list, moving to the top
Warning: 'symengine' already in 'channels' list, moving to the top
Fetching package metadata .............
Solving package specifications: .
...UnsatisfiableError: The following specifications were found to be in conflict:
  - enum34 -> python 2.6*|2.7*|3.3*
  - python 3.5*
Use "conda info <package>" to see the dependencies for each package.


==============================[ ERROR: SymEngine ]==============================

LoadError: failed process: Process(setenv(`'C:\Users\Chris\.julia\v0.5\Conda\deps\usr\Scripts\conda.exe' install -y python=3.5`,String["PATH=C:\\Users\\Chris\\AppData\\Local\\Julia-0.5.0\\bin;C:\\Users\\Chris\\.julia\\v0.5\\Conda\\deps\\usr\\Library\\bin;C:\\Users\\Chris\\AppData\\Local\\Julia-0.5.0\\bin;C:\\Users\\Chris\\.julia\\v0.5\\Conda\\deps\\usr\\Library\\bin;C:\\Users\\Chris\\.julia\\v0.5\\Conda\\deps\\usr\\Scripts;C:\\Users\\Chris\\.julia\\v0.5\\Conda\\deps\\usr\\Library\\bin;C:\\Users\\Chris\\AppData\\Local\\Julia-0.5.0\\bin;C:\\Program Files\\ImageMagick-6.9.5-Q16;C:\\Program Files\\ImageMagick-7.0.2-Q16;C:\\Program Files\\ImageMagick-7.0.1-Q16;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.5\\bin;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.5\\libnvvp;C:\\Program Files (x86)\\Razer Chroma SDK\\bin;C:\\Program Files\\Razer Chroma SDK\\bin;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\MiKTeX 2.9\\miktex\\bin\\;C:\\Program Files\\MATLAB\\R2015b\\bin;C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\Users\\Chris\\.dnx\\bin;C:\\Program Files\\Microsoft DNX\\Dnvm\\;C:\\Program Files (x86)\\Windows Kits\\8.1\\Windows Performance Toolkit\\;C:\\Program Files\\Microsoft SQL Server\\110\\Tools\\Binn\\;C:\\Program Files (x86)\\Microsoft SDKs\\TypeScript\\1.0\\;C:\\Program Files (x86)\\Skype\\Phone\\;C:\\Program Files (x86)\\CMake\\bin;C:\\Users\\Chris\\AppData\\Local\\Julia-0.4.5;C:\\Program Files\\MATLAB\\R2015b\\bin\\win64;C:\\Program Files\\cURL\\bin;C:\\Program Files (x86)\\LyX 2.2\\Perl\\bin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\HashiCorp\\Vagrant\\bin;c:\\users\\chris\\appdata\\local\\enthought\\canopy\\user\\scripts;C:\\Users\\Chris\\AppData\\Local\\Enthought\\Canopy\\User;C:\\Program Files\\mingw-w64\\x86_64-6.1.0-posix-seh-rt_v5-rev0\\mingw64\\bin;C:\\Users\\Chris\\AppData\\Local\\atom\\bin","USERDOMAIN_ROAMINGPROFILE=CHRISRACKBED","HOMEPATH=\\Users\\Chris","PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC","SESSIONNAME=Console","TK_LIBRARY=C:\\Users\\Chris\\.julia\\v0.5\\Conda\\deps\\usr\\tcl\\tk8.5","SYSTEMROOT=C:\\WINDOWS","PSMODULEPATH=C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules\\","APPDATA=C:\\Users\\Chris\\AppData\\Roaming","COMMONPROGRAMW6432=C:\\Program Files\\Common Files","PROGRAMDATA=C:\\ProgramData","USERDOMAIN=CHRISRACKBED","PUBLIC=C:\\Users\\Public","OS=Windows_NT","TMP=C:\\Users\\Chris\\AppData\\Local\\Temp","PROCESSOR_REVISION=3c03","COMSPEC=C:\\WINDOWS\\system32\\cmd.exe","NVTOOLSEXT_PATH=C:\\Program Files\\NVIDIA Corporation\\NvToolsExt\\","ALLUSERSPROFILE=C:\\ProgramData","COMPUTERNAME=CHRISRACKBED","FP_NO_HOST_CHECK=NO","USERNAME=Chris","COLUMNS=80","IPY_INTERRUPT_EVENT=1632","CUDA_PATH=C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.5","USERPROFILE=C:\\Users\\Chris","CONDARC=C:\\Users\\Chris\\.julia\\v0.5\\Conda\\deps\\usr\\condarc-julia.yml","TCL_LIBRARY=C:\\Users\\Chris\\.julia\\v0.5\\Conda\\deps\\usr\\tcl\\tcl8.5","PROCESSOR_LEVEL=6","LINES=30","=C:=C:\\Users\\Chris\\.julia\\v0.5\\SymEngine\\deps","PROGRAMW6432=C:\\Program Files","HOME=C:\\Users\\Chris","TEMP=C:\\Users\\Chris\\AppData\\Local\\Temp","HOMEDRIVE=C:","WINDIR=C:\\WINDOWS","JPY_INTERRUPT_EVENT=1632","LOCALAPPDATA=C:\\Users\\Chris\\AppData\\Local","VS120COMNTOOLS=C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\Tools\\","PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 60 Stepping 3, GenuineIntel","NUMBER_OF_PROCESSORS=8","VS140COMNTOOLS=C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools\\","COMMONPROGRAMFILES(X86)=C:\\Program Files (x86)\\Common Files","TIX_LIBRARY=C:\\Users\\Chris\\.julia\\v0.5\\Conda\\deps\\usr\\tcl\\tix8.4.3","CUDA_PATH_V7_5=C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.5","CONDA_DEFAULT_ENV=C:\\Users\\Chris\\.julia\\v0.5\\Conda\\deps\\usr","=D:=D:\\OneDrive\\Computer\\Desktop\\RIPSTalk","COMMONPROGRAMFILES=C:\\Program Files\\Common Files","PROGRAMFILES(X86)=C:\\Program Files (x86)","NVCUDASAMPLES7_5_ROOT=C:\\ProgramData\\NVIDIA Corporation\\CUDA Samples\\v7.5","PROGRAMFILES=C:\\Program Files","VS110COMNTOOLS=C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\Common7\\Tools\\","JPY_PARENT_PID=1364","LOGONSERVER=\\\\CHRISRACKBED","__KMP_REGISTERED_LIB_27116=00007FFB793B7954-cafebc46-libiomp5md.dll","CONDA_PREFIX=C:\\Users\\Chris\\.julia\\v0.5\\Conda\\deps\\usr","FPS_BROWSER_USER_PROFILE_STRING=Default","MATLAB_HOME=C:\\Program Files\\MATLAB\\R2015b","ASL.LOG=Destination=file","SYSTEMDRIVE=C:","FPS_BROWSER_APP_PROFILE_STRING=Internet Explorer","NVCUDASAMPLES_ROOT=C:\\ProgramData\\NVIDIA Corporation\\CUDA Samples\\v7.5","PROCESSOR_ARCHITECTURE=AMD64","OPENBLAS_MAIN_FREE=1"]), ProcessExited(1)) [1]
while loading C:\Users\Chris\.julia\v0.5\SymEngine\deps\build.jl, in expression starting on line 12

================================================================================

================================[ BUILD ERRORS ]================================

WARNING: SymEngine had build errors.

 - packages with build errors remain installed in C:\Users\Chris\.julia\v0.5
 - build the package(s) and all dependencies with `Pkg.build("SymEngine")`
 - build a single package by running its `deps/build.jl` script

================================================================================

Warnings on executing Pkg.test("SymEngine")

WARNING: Union(args...) is deprecated, use Union{args...} instead.
in depwarn at deprecated.jl:73
in call at deprecated.jl:50
in include at ./boot.jl:261
in include_from_node1 at ./loading.jl:304
in require at ./loading.jl:243
in include at ./boot.jl:261
in include_from_node1 at ./loading.jl:304
in process_options at ./client.jl:280
in _start at ./client.jl:378
while loading /home/kunal/.julia/v0.4/SymEngine/src/SymEngine.jl, in expression starting on line 57
WARNING: Base.Uint8 is deprecated, use UInt8 instead.
likely near /home/kunal/.julia/v0.4/SymEngine/src/SymEngine.jl:58
WARNING: Base.Uint16 is deprecated, use UInt16 instead.
likely near /home/kunal/.julia/v0.4/SymEngine/src/SymEngine.jl:58
WARNING: Base.Uint32 is deprecated, use UInt32 instead.
likely near /home/kunal/.julia/v0.4/SymEngine/src/SymEngine.jl:58
WARNING: Base.Uint64 is deprecated, use UInt64 instead.
likely near /home/kunal/.julia/v0.4/SymEngine/src/SymEngine.jl:58
WARNING: Union(args...) is deprecated, use Union{args...} instead.
in depwarn at deprecated.jl:73
in call at deprecated.jl:50
in include at ./boot.jl:261
in include_from_node1 at ./loading.jl:304
in require at ./loading.jl:243
in include at ./boot.jl:261
in include_from_node1 at ./loading.jl:304
in process_options at ./client.jl:280
in _start at ./client.jl:378
while loading /home/kunal/.julia/v0.4/SymEngine/src/SymEngine.jl, in expression starting on line 58
WARNING: module SymEngine should explicitly import + from Base
WARNING: module SymEngine should explicitly import / from Base
WARNING: module SymEngine should explicitly import * from Base
WARNING: module SymEngine should explicitly import ^ from Base
WARNING: module SymEngine should explicitly import - from Base
WARNING: module SymEngine should explicitly import \ from Base
WARNING: module SymEngine should explicitly import == from Base
WARNING: Union(args...) is deprecated, use Union{args...} instead.
in depwarn at deprecated.jl:73
in call at deprecated.jl:50
in include at ./boot.jl:261
in include_from_node1 at ./loading.jl:304
in require at ./loading.jl:243
in include at ./boot.jl:261
in include_from_node1 at ./loading.jl:304
in process_options at ./client.jl:280
in _start at ./client.jl:378
while loading /home/kunal/.julia/v0.4/SymEngine/src/SymEngine.jl, in expression starting on line 112
WARNING: module SymEngine should explicitly import == from Base
WARNING: module SymEngine should explicitly import == from Base

Install SymEngine without C++ tests

So that only the library itself is compiled, but no tests, since those are not needed and just waste compilation time.

We might need to add some CMake option in SymEngine to allow that.

Add support for unknown functions

Python wrappers support using Python functions and using callbacks.

For example, airyai is a function not supported, but Calculus.jl has a list that we can use.

This requires additions to libsymengine.

Identifiers cannot be used as local var once declared as symbols

using SymEngine
using Roots


@vars x1 x2
SymF = x1^2 + x1 * x2 + x2^2 / 2
dFx1 = diff(SymF, x1)
dFx2 = diff(SymF, x2)
F(x) = begin
  x1 = x[1]
  x2 = x[2]
  res = SymF(x1 => x1, x2 => x2)
  convert(Float64, res)
end
F([1, 1])

I got the following error:


MethodError: no method matching subs(::SymEngine.Basic, ::Tuple{Int64,Int64}, ::Tuple{Int64,Int64})
Closest candidates are:
  subs(::T<:Union{SymEngine.Basic, SymEngine.BasicType}, !Matched::S<:Union{SymEngine.Basic, SymEngine.BasicType}, ::Any) where {T<:Union{SymEngine.Basic, SymEngine.BasicType}, S<:Union{SymEngine.Basic, SymEngine.BasicType}} at /home/kaiyin/.julia/v0.6/SymEngine/src/subs.jl:19
  subs(::T<:Union{SymEngine.Basic, SymEngine.BasicType}, !Matched::Tuple{S<:Union{SymEngine.Basic, SymEngine.BasicType},Any}, ::Any...) where {T<:Union{SymEngine.Basic, SymEngine.BasicType}, S<:Union{SymEngine.Basic, SymEngine.BasicType}} at /home/kaiyin/.julia/v0.6/SymEngine/src/subs.jl:31
  subs(::T<:Union{SymEngine.Basic, SymEngine.BasicType}, !Matched::SymEngine.CMapBasicBasic) where T<:Union{SymEngine.Basic, SymEngine.BasicType} at /home/kaiyin/.julia/v0.6/SymEngine/src/subs.jl:24
  ...
in F at test.jl:703
in Basic at SymEngine/src/subs.jl:53
in subs at SymEngine/src/subs.jl:32

The code runs fine if I make the following changes:

F(x) = begin
  x1_val = x[1]
  x2_val = x[2]
  res = SymF(x1 => x1_val, x2 => x2_val)
  convert(Float64, res)
end

Problem building SymEngine

This is Windows 10 on a new install

julia> Pkg.build("SymEngine")
INFO: Building Conda
INFO: Building SymEngine
Warning: 'conda-forge' already in 'channels' list, moving to the top
Warning: 'symengine' already in 'channels' list, moving to the top
Fetching package metadata ...............
Solving package specifications: .

# All requested packages already installed.
# packages in environment at C:\Users\ChrisRack\.julia\v0.5\SymEngine\deps\usr:
#
python                    3.5.3                         0    conda-forge
=============================[ ERROR: SymEngine ]=============================

LoadError: failed process: Process(setenv(`'C:\Users\ChrisRack\.julia\v0.5\SymEngine\deps\usr\Scripts\conda.bat' search symengine --json`,String["USERDOMAIN_ROAMINGPROFILE=CHRISRACKTAB","HOMEPATH=\\Users\\ChrisRack","ProgramData=C:\\ProgramData","ProgramW6432=C:\\Program Files","PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC","SESSIONNAME=Console","APPDATA=C:\\Users\\ChrisRack\\AppData\\Roaming","PUBLIC=C:\\Users\\Public","USERDOMAIN=CHRISRACKTAB","OS=Windows_NT","PROCESSOR_REVISION=4501","TMP=C:\\Users\\CHRISR~1\\AppData\\Local\\Temp","ALLUSERSPROFILE=C:\\ProgramData","Path=C:\\Users\\ChrisRack\\AppData\\Local\\Julia-0.5.0\\bin;C:\\Users\\ChrisRack\\AppData\\Local\\Julia-0.5.0\\bin;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\windows\\system32;C:\\windows;C:\\windows\\System32\\Wbem;C:\\windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\MATLAB\\R2015b\\bin;C:\\Program Files (x86)\\CMake\\bin;C:\\Users\\ChrisRack\\AppData\\Local\\Julia-0.4.5\\bin;C:\\Program Files (x86)\\LyX 2.2\\Perl\\bin;C:\\Program Files\\MiKTeX 2.9\\miktex\\bin\\x64\\;C:\\Users\\ChrisRack\\Anaconda2;C:\\Users\\ChrisRack\\Anaconda2\\Scripts;C:\\Users\\ChrisRack\\Anaconda2\\Library\\bin;C:\\Users\\ChrisRack\\AppData\\Local\\atom\\bin","COMPUTERNAME=CHRISRACKTAB","FP_NO_HOST_CHECK=NO","USERNAME=ChrisRack","CommonProgramFiles(x86)=C:\\Program Files (x86)\\Common Files","CommonProgramFiles=C:\\Program Files\\Common Files","CONDARC=C:\\Users\\ChrisRack\\.julia\\v0.5\\SymEngine\\deps\\usr\\condarc-julia.yml","USERPROFILE=C:\\Users\\ChrisRack","PSModulePath=C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules\\","PROCESSOR_LEVEL=6","=C:=C:\\Users\\ChrisRack\\.julia\\v0.5\\SymEngine\\deps","TEMP=C:\\Users\\CHRISR~1\\AppData\\Local\\Temp","SystemDrive=C:","HOMEDRIVE=C:","LOCALAPPDATA=C:\\Users\\ChrisRack\\AppData\\Local","PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 69 Stepping 1, GenuineIntel","NUMBER_OF_PROCESSORS=4","=::=::\\","ComSpec=C:\\WINDOWS\\system32\\cmd.exe","SystemRoot=C:\\WINDOWS","CONDA_DEFAULT_ENV=C:\\Users\\ChrisRack\\.julia\\v0.5\\SymEngine\\deps\\usr","ProgramFiles(x86)=C:\\Program Files (x86)","LOGONSERVER=\\\\MicrosoftAccount","CONDA_PREFIX=C:\\Users\\ChrisRack\\.julia\\v0.5\\SymEngine\\deps\\usr","windir=C:\\WINDOWS","FPS_BROWSER_USER_PROFILE_STRING=Default","CommonProgramW6432=C:\\Program Files\\Common Files","ProgramFiles=C:\\Program Files","FPS_BROWSER_APP_PROFILE_STRING=Internet Explorer","PROCESSOR_ARCHITECTURE=AMD64","OPENBLAS_MAIN_FREE=1"]), ProcessExited(1)) [1]
while loading C:\Users\ChrisRack\.julia\v0.5\SymEngine\deps\build.jl, in expression starting on line 19

==============================================================================

===============================[ BUILD ERRORS ]===============================

WARNING: SymEngine had build errors.

 - packages with build errors remain installed in C:\Users\ChrisRack\.julia\v0.5
 - build the package(s) and all dependencies with `Pkg.build("SymEngine")`
 - build a single package by running its `deps/build.jl` script

==============================================================================

Realize CDenseMatrix

For example:

using SymEngine
using Roots
CDenseMatrix = SymEngine.CDenseMatrix

@vars s t x1 x2
F(x1, x2) = x1^4 + 2x2^2 + x1 - x2
dFx1 = diff(F(x1, x2), x1)
dFx2 = diff(F(x1, x2), x2)
dFx1x1 = diff(dFx1, x1)
dFx1x2 = diff(dFx1, x2)
dFx2x1 = diff(dFx2, x1)
dFx2x2 = diff(dFx2, x2)
G = CDenseMatrix([dFx1x1 dFx1x2; dFx2x1 dFx2x2])

G is something like this:

If I set x1 to 1, what would happen?

One would expect to get

12 0
 0 4

Problem building the package. Issue with miniconda

I have a problem while building the package.

This is my full error window.

julia> Pkg.build("SymEngine")
INFO: Building Conda
INFO: Building SymEngine
INFO: Downloading miniconda installer ...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (77) error setting certificate verify locations:
CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
============================[ ERROR: SymEngine ]============================

LoadError: failed process: Process(curl -o /home/jivifair/.julia/v0.5/Conda/deps/usr/installer.sh -L http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh, ProcessExited(77)) [77]
while loading /home/jivifair/.julia/v0.5/SymEngine/deps/build.jl, in expression starting on line 9

============================================================================

==============================[ BUILD ERRORS ]==============================

WARNING: SymEngine had build errors.

  • packages with build errors remain installed in /home/jivifair/.julia/v0.5
  • build the package(s) and all dependencies with Pkg.build("SymEngine")
  • build a single package by running its deps/build.jl script

============================================================================`

Conversion of matrix to expressions

This doesn't work so well.

SymEngine.jl/src/subs.jl

Lines 76 to 87 in 9c393c3

function convert(::Type{Expr}, m::AbstractArray{Basic, 2})
col_args = []
for i = 1:size(m, 1)
row_args = []
for j = 1:size(m, 2)
push!(row_args, convert(Expr, m[i, j]))
end
row = Expr(:hcat, row_args...)
push!(col_args, row)
end
Expr(:vcat, col_args...)
end
converts it to the Python form.

symjac_ex = :([[1 0]; [d * t ^ 2 * y -1c + d * t ^ 2 * x]])

Broadcasting doesn't guarantee and expression so you get something odd

symjac_ex = Any[1 0; :(d * t ^ 2 * y) :(-1c + d * t ^ 2 * x)]

It should be an array of expressions, but 1 and 0 are integer literals and not expressions here.

isa(x,Number)

It seems undesirable that a variable of type SymEngine.Basic is a Number but throws an error when coerced to that type. The type SymPy.Sym does not have this issue.

julia> using SymEngine
julia> @vars x
julia> isa(x,Number)
true
julia> Number[1,2,3,x]
ERROR: ArgumentError: Object can have no free symbols
 in N(::SymEngine.BasicType{Val{:Symbol}}) at /Users/sswatson/.julia/v0.5/SymEngine/src/numerics.jl:122
 in setindex!(::Array{Number,1}, ::SymEngine.Basic, ::Int64) at ./array.jl:415
 in getindex(::Type{Number}, ::Int64, ::Int64, ::Int64, ::SymEngine.Basic, ::Vararg{SymEngine.Basic,N}) at ./array.jl:132
julia> using SymPy; @syms y
(y,)

julia> Number[1,2,3,y]
4-element Array{Number,1}:
 1
 2
 3
 y

v0.7 upgrading

Julia's v0.7 is going to alpha sooner rather than later, so I was wondering if SymEngine could get its upgrade. Right now it segfaults. using ParameterizedFunctions just segfaults and it seems to be SymEngine related, plus SymEngine.jl's tests fail.

Safer Build Failure

I would like to be able to use this library for some features in a larger package, but at present it can have build issues which cause an entire other project to be unusable. Is there a way to "tame" the errors so that way it doesn't crash dependents if unavailable? Maybe @tkelman has an answer. I am trying to avoid conditional dependencies, but something like this, it's hard to use SymEngine to provide additional features if it can cause the entire package to be unusable. Hopefully we can find a better option.

julia> using DifferentialEquations
ERROR: LoadError: LoadError: LoadError: could not open file C:\Users\Chris\.julia\v0.5\SymEngine\src\../deps/deps.jl
 in include_from_node1(::String) at .\loading.jl:488 (repeats 2 times)
 in eval(::Module, ::Any) at .\boot.jl:234
 in require(::Symbol) at .\loading.jl:415
 in include_from_node1(::String) at .\loading.jl:488
 in eval(::Module, ::Any) at .\boot.jl:234
 in require(::Symbol) at .\loading.jl:415
 in include_from_node1(::String) at .\loading.jl:488
 in eval(::Module, ::Any) at .\boot.jl:234
 in require(::Symbol) at .\loading.jl:415
while loading C:\Users\Chris\.julia\v0.5\SymEngine\src\SymEngine.jl, in expression starting on line 13
while loading C:\Users\Chris\.julia\v0.5\ParameterizedFunctions\src\ParameterizedFunctions.jl, in expression starting on line 2
while loading C:\Users\Chris\.julia\v0.5\DifferentialEquations\src\DifferentialEquations.jl, in expression starting on line 5

Use basic_str_julia instead of basic_str

exp is more optimized, and E^ is only a SymEngine variable. If the E^ expression is used to generate a Julia function, and this is run in a scope without SymEngine.jl in the namespace, then it will fail.

lambdify on matrix

Hi,

I was wondering if there's a way to lambdify a symbolic matrix. Something like:

using SymEngine

@vars x1 x2 x3 x4

x = [x1, x2, x3, x4]

A = [[x1 x2];[x3 x4]]

f1 = lambdify(A[1,1]) #works, but not really what I'm looking for

f2 = lambdify(x,A) #does not work
f3 = lambdify(A) #does not work

In sympy I can do (with equivalent setup):

f = lambdify(x,A)

Thanks.

Test error

I encountered an error while running runtests.jl file. It was on Win10 with Julia 0.5.0. Error messages are the following:

(1/2)x - 5xy + x^2
1/2 + 2
x - 5*y
Error During Test
Test threw an exception of type MethodError
Expression:
N(Basic(val)) == val
MethodError: objects of type Int64 are not callable
in macro expansion; at tmp.jl:118 [inlined]
in anonymous at .<missing>:?
in include_string(::String, ::String) at .\loading.jl:441
in include_string(::Module, ::String, ::String) at C:\Program Files\Julia-0.5.0\juliapackages\v0.5\CodeTools\src\eval.jl:32
in (::Atom.##61#64{String,String})() at C:\Program Files\Julia-0.5.0\juliapackages\v0.5\Atom\src\eval.jl:81
in withpath(::Atom.##61#64{String,String}, ::String) at C:\Program Files\Julia-0.5.0\juliapackages\v0.5\CodeTools\src\utils.jl:30
in withpath(::Function, ::String) at C:\Program Files\Julia-0.5.0\juliapackages\v0.5\Atom\src\eval.jl:46
in macro expansion at C:\Program Files\Julia-0.5.0\juliapackages\v0.5\Atom\src\eval.jl:79 [inlined]
in (::Atom.##60#63{String,String})() at .\task.jl:60

Fail to recongnise equivalence of two forms of the sigmoid function

The following two equations should be equivalent
(for using SymEngine; @vars z)
exp(z)/(1+exp(z)) and 1/(1+exp(-z))

This is what my hand-math tells me, and it is listed on wikipedia.

But does not work

  • exp(z)/(1+exp(z)) == 1/(1+exp(-z)) --> false
  • expand(exp(z)/(1+exp(z))) == expand(1/(1+exp(-z))) --> false

Similar expression involving multiplication instread of division work -- if you call expand

  • exp(-z)*(1+exp(z)) == 1 + exp(-z) --> false
  • expand(exp(-z)*(1+exp(z))) == expand(1 + exp(-z))

I guess this could be broken into two issues.

  1. divisions don't "expand" for correct equality
  2. expansion should be called before equality is checked.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.