SymEngine is a fast symbolic manipulation library, written in C++

Overview

SymEngine

Build Status 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

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

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

The Travis-CI 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 as 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 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
    -DBUILD_TESTS:BOOL=ON \                       # Build with tests
    -DBUILD_BENCHMARKS:BOOL=ON \                  # Build with benchmarks
    -DBUILD_BENCHMARKS_NONIUS:BOOL=OFF \          # Build with Nonius 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.

The Nonius based benchmarks (BUILD_BENCHMARKS_NONIUS) and Piranha (WITH_PIRANHA) depend on Boost, so they are off by default. The benchmarked code (both with and without Nonius) seems to depend on the order of 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 build 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.

Issues
  • Ruby wrappers initial file structure and Basic class

    Ruby wrappers initial file structure and Basic class

    Addresses issue #413. Most of the files are empty. I have tried to use the standard tools like RSpec and bundler which I am not very familiar with, but believe will prove to be very useful during the development. The main reason for choosing RSpec was because SciRuby prefers RSpec.

    TODO list before we can merge this PR:

    • [x] Build the wrappers with CMake
    • [x] Test the wrappers on Travis (building + running Ruby tests)
    • [x] Expose some minimal functionality and test it using Ruby tests (make sure they are run by Travis)
    • [x] Remove unnecessary things and files from the wrappers (e.g. src/ruby/bin/htmldiff is probably not needed)

    After this is merged, we will then expose more functionality of SymEngine (both in the C wrappers as well as the Ruby wrappers).

    opened by abinashmeher999 57
  • New MatchPyCpp package in utilities

    New MatchPyCpp package in utilities

    I think symengine/utilities is the optimal location for this package. A Python file is included, which acts as code generator for the SymEngine.

    • [ ] ~~move SymEnginePrinter to SymPy.~~
    • [x] optional wildcards testing.
    • [ ] ~~sequence-matching wildcard~~ ==> not urgent, open separate issue
    • [x] check var.find(...) == var.end() for optimizations.
    • [x] add more const ... & to function parameters.
    • [ ] ~~add typedef map<string, RCP<const Basic>> SubstitutionBasic ?~~ ==> open separate issue
    opened by Upabjojr 54
  • Implemented Quadratic residue function

    Implemented Quadratic residue function

    • [x] Quadratic Residue function
    • [x] is_quad_residue function
    • [x] is_nthroot_mod_prime_power function
    • [x] is_nthroot_mod1() function
    • [x] is_nth_power_residue() function

    @isuruf @Sumith1896 Could you please review this?

    PR needs review 
    opened by CodeMaxx 47
  • MultivariateIntPolynomial

    MultivariateIntPolynomial

    This code currently does not build. Currently compilation stops at

    [ 7%] Building CXX object symengine/CMakeFiles/symengine.dir/basic.cpp.o

    with the errors

    In file included from /home/myluszcz/ECS193/SYMENGINE/symengine/symengine/basic.h:36:0, from /home/myluszcz/ECS193/SYMENGINE/symengine/symengine/basic.cpp:1: /home/myluszcz/ECS193/SYMENGINE/symengine/symengine/dict.h:30:38: error: invalid declarator before âumap_basic_numâ RCPBasicHash, RCPBasicKeyEq> umap_basic_num; ^ /home/myluszcz/ECS193/SYMENGINE/symengine/symengine/dict.h:202:62: error: âumap_basic_numâ in namespace âSymEngineâ does not name a type std::ostream& operator<<(std::ostream& out, const SymEngine::umap_basic_num& d); ^ In file included from /home/myluszcz/ECS193/SYMENGINE/symengine/symengine/basic.cpp:3:0: /home/myluszcz/ECS193/SYMENGINE/symengine/symengine/add.h:18:5: error: âumap_basic_numâ does not name a type umap_basic_num dict_; //! The dictionary of the rest (e.g. x+y in 2+x+y) ^ In file included from /home/myluszcz/ECS193/SYMENGINE/symengine/symengine/basic.cpp:3:0: /home/myluszcz/ECS193/SYMENGINE/symengine/symengine/add.h:25:40: error: âumap_basic_numâ has not been declared Add(const RCP &coef, umap_basic_num&& dict); ^ /home/myluszcz/ECS193/SYMENGINE/symengine/symengine/add.h:41:70: error: âumap_basic_numâ has not been declared static RCP from_dict(const RCP &coef, umap_basic_num &&d); ^ /home/myluszcz/ECS193/SYMENGINE/symengine/symengine/add.h:45:31: error: âumap_basic_numâ has not been declared static void dict_add_term(umap_basic_num &d, ^ /home/myluszcz/ECS193/SYMENGINE/symengine/symengine/add.h:51:72: error: âumap_basic_numâ has not been declared static void coef_dict_add_term(const Ptr<RCP> &coef, umap_basic_num &d, ^ /home/myluszcz/ECS193/SYMENGINE/symengine/symengine/add.h:61:19: error: âumap_basic_numâ does not name a type const umap_basic_num& dict) const; ^ In file included from /home/myluszcz/ECS193/SYMENGINE/symengine/symengine/printer.h:4:0, from /home/myluszcz/ECS193/SYMENGINE/symengine/symengine/basic.cpp:12: /home/myluszcz/ECS193/SYMENGINE/symengine/symengine/visitor.h: In member function âvoid SymEngine::CoeffVisitor::bvisit(const SymEngine::Add&)â: /home/myluszcz/ECS193/SYMENGINE/symengine/symengine/visitor.h:94:9: error: âumap_basic_numâ was not declared in this scope umap_basic_num dict; /home/myluszcz/ECS193/SYMENGINE/symengine/symengine/visitor.h:94:9: error: âumap_basic_numâ was not declared in this scope umap_basic_num dict; ^ /home/myluszcz/ECS193/SYMENGINE/symengine/symengine/visitor.h:96:25: error: âconst class SymEngine::Addâ has no member named âdict_â for (auto &p: x.dict_) { ^ /home/myluszcz/ECS193/SYMENGINE/symengine/symengine/visitor.h:99:55: error: âdictâ was not declared in this scope Add::coef_dict_add_term(outArg(coef), dict, p.second, coeff_); ^ /home/myluszcz/ECS193/SYMENGINE/symengine/symengine/visitor.h:102:49: error: âdictâ was not declared in this scope coeff_ = Add::from_dict(coef, std::move(dict)); ^ symengine/CMakeFiles/symengine.dir/build.make:86: recipe for target 'symengine/CMakeFiles/symengine.dir/basic.cpp.o' failed make[2]: *** [symengine/CMakeFiles/symengine.dir/basic.cpp.o] Error 1 CMakeFiles/Makefile2:93: recipe for target 'symengine/CMakeFiles/symengine.dir/all' failed make[1]: *** [symengine/CMakeFiles/symengine.dir/all] Error 2 Makefile:138: recipe for target 'all' failed make: *** [all] Error 2

    Our current goal WRT to this branch is to get the MultivariatePolynomial object to compile. Once this occurs, we will write functions for performing addition, subtraction, negation, and multiplication, probably using the naive algorithms at first. After this we will write testers and benchmarks against which to compare future improvements.

    @shivamvats @certik @isuruf

    opened by char-chen 45
  • Refactor Arb `visit` functions

    Refactor Arb `visit` functions

    Refactor some of the visit functions according to comments from Fredrik Johansson, author of Arb.

    • Minimize usage of temporary variables
    • Clear temporary variables after they have been used.
    opened by thilinarmtb 38
  • [WIP] Initial implementation of single dispatch

    [WIP] Initial implementation of single dispatch

    This PR is to figure out the right approach (and for benchmarking various designs, as different commits). Once we settle on a design, we'll create a nice new polished PR and close this one.

    opened by certik 35
  • Fixed TODO: Implement binary search in sparse_matrix.cpp

    Fixed TODO: Implement binary search in sparse_matrix.cpp

    Fixed TODO in sparse_matrix.cpp but this commit seems to break tests. There are two more binary search implementation TODOs, if we can fix this so that tests pass we can implement the other two. cc @thilinarmtb

    opened by Sumith1896 33
  • Support for Symbol in ruby wrappers

    Support for Symbol in ruby wrappers

    I guess the files cwrapper.h had sufficient functions to create a Symbol class in module SymEngine and use the expand method. These just contain the Ruby wrappers but they don't build now. TODO:

    • [x] Add #free_symbols method to basic
    • [x] Add #args method to basic
    • [x] Write tests for both
    opened by abinashmeher999 31
  • UnivariateSeries

    UnivariateSeries

    Resuming the work from #810. A new UnivariateSeries that uses SeriesBase as its base. Without external dependencies, UnivariateSeries uses the existing generic interface implementation to match those of Piranha and Flint.

    @shivamvats @certik @isuruf @Sumith1896

    opened by char-chen 29
  • Fix for UnivariatePolynomial::__eq__

    Fix for UnivariatePolynomial::__eq__

    The current implementation of UnivariatePolynomial::__eq__ checks if the dictionaries of the two polynomials are exactly equal, and will return false if comparing polynomials with the dictionaries {{0,0},{1,2}} and {{1,2}} representing 0 + 2x and 2x respectively. Since addition does not remove the entries of a dictionary corresponding to terms that have zero coefficients, this can lead to a situation where SymEngine tells us that (x+1) + (x-1) != 2x, as shown below. test.zip

    My implementation replaces the call to map_uint_mpz_eq with a call to poly_dict_map_uint_mpz_eq, which returns true if two dictionaries are the same (excluding those entries where the coefficient is zero.)

    opened by myluszczak 28
  • Fix `pow` to handle negative exponents. Fix for #179

    Fix `pow` to handle negative exponents. Fix for #179

    @certik @thilinarmtb I've updated pow more or less the way it was in SymPy version, atleast for the case of Number However, in some cases Mul gets a negative pow. Currently in case of Mul we just call power_all_terms So I added a check in power_all_terms. Can you review if this is the right way to go about fixing it?

    opened by sushant-hiray 28
  • Unresolved External Symbols: Windows CMake or WSL

    Unresolved External Symbols: Windows CMake or WSL

    The Issue

    In attempting to compile Symengine for a C++ project (written in Microsoft Visual Studio 2022), I followed the installation instructions to compile the symengine libraries in an Ubuntu 20.04 WSL terminal via: sudo cmake -DCMAKE_PREFIX_PATH="/mnt/c/Program Files/boost_1_79_0" -DINTEGER_CLASS=boostmp -DBUILD_SHARED_LIBS=OFF -DWITH_SYMENGINE_RCP=OFF .. && sudo make && sudo make install && sudo ctest. I opted for boost, instead of the default GMP, because I already had this from a different project. Visual Studio appears to have no issue including the appropriate header files nor any issue correctly linting: i.e. IntelliSense does not detect any issues in the source code. However, the project will compile due to unresolved external symbols (see picture below).

    image

    Call for more C++ documentation

    A couple issues have been opened (#1725 and #1905) asking for more C++ documentation. #1725 demonstrates that Symengine can be integrate to C++. Several other issues speak of interfacing with Windows: e.g. compiling for Windows appears to not be an issue for others.

    Bottomline

    Several other comments indicate that Symengine can be built in Windows, but all the installation instructions speak in terms of Linux commands and dependencies. I attempted to install by cmake (via a GUI in Windows and not WSL) and compile the Symengine libraries from the resultant Visual Studio solution, but also to no avail with the same result in unresolved external symbols. This was the same result as trying to compile the libraries in WSL. Compiling in WSL or by cmake in Windows appears to have generated the appropriate symenginelib.a and symengine.lib libraries, respectively. The issue also persists regardless of whether WITH_SYMENGINE_RCP is set to ON or OFF.

    • Is this not supported in Windows?
    • Is a full Linux environment required to compile?
    • If Linux is so required to compile, then why am I running into this issue with WSL?

    Configuration Summary from CMake in Windows

    Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044. Linker does not support --exclude-libs

    +-------------------------------+ | Configuration results SUMMARY | +-------------------------------+

    CMAKE_C_COMPILER: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe CMAKE_CXX_COMPILER: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe CMAKE_BUILD_TYPE: Release CMAKE_CONFIGURATION_TYPES: Debug;Release;MinSizeRel;RelWithDebInfo CMAKE_C_FLAGS: /DWIN32 /D_WINDOWS /W3 CMAKE_CXX_FLAGS: /DWIN32 /D_WINDOWS /W3 /GR /EHsc CMAKE_CXX_FLAGS_DEBUG: /MTd /Zi /Ob0 /Od /RTC1 /W1 CMAKE_CXX_FLAGS_RELEASE: /MT /O2 /Ob2 /DNDEBUG /W1 CMAKE_INSTALL_PREFIX: C:/Program Files (x86)/symengine BUILD_SHARED_LIBS: INTEGER_CLASS : BOOSTMP HAVE_SYMENGINE_GMP: no WITH_SYMENGINE_ASSERT: OFF WITH_SYMENGINE_RCP: ON WITH_SYMENGINE_TEUCHOS: OFF WITH_COTIRE: OFF WITH_GENERATE_PARSER: OFF HAVE_GCC_ABI_DEMANGLE: no HAVE_C_FUNCTION_NOT_FUNC: yes HAVE_DEFAULT_CONSTRUCTORS: no HAVE_SYMENGINE_NOEXCEPT: ON HAVE_SYMENGINE_IS_CONSTRUCTIBLE: ON HAVE_SYMENGINE_RESERVE: ON HAVE_SYMENGINE_STD_TO_STRING: TRUE WITH_SYMENGINE_THREAD_SAFE: OFF BUILD_TESTS: ON BUILD_BENCHMARKS: ON BUILD_BENCHMARKS_GOOGLE: OFF WITH_GMP: no WITH_BFD: OFF WITH_ECM: OFF WITH_PRIMESIEVE: OFF WITH_FLINT: OFF WITH_ARB: OFF WITH_MPFR: OFF WITH_PIRANHA: OFF WITH_LLVM: OFF WITH_BOOST: yes BOOST_INCLUDE_DIRS: C:/Program Files/boost_1_79_0 BOOST_LIBRARIES: WITH_PTHREAD: OFF WITH_MPC: OFF WITH_TCMALLOC: OFF WITH_OPENMP: OFF WITH_VIRTUAL_TYPEID: OFF LIBS:


    Configuring done Generating done

    My Visual Studio info

    Microsoft Visual Studio Community 2022 Version 17.2.5 VisualStudio.17.Release/17.2.5+32616.157 Microsoft .NET Framework Version 4.8.04084

    Installed Version: Community

    Visual C++ 2022 00482-90000-00000-AA747 Microsoft Visual C++ 2022

    ASP.NET and Web Tools 2019 17.2.393.26812 ASP.NET and Web Tools 2019

    Azure App Service Tools v3.0.0 17.2.393.26812 Azure App Service Tools v3.0.0

    C# Tools 4.2.0-4.22281.5+8d3180e5f00d42f0f0295165f756f368f0cbfa44 C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

    Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

    Cookiecutter 17.0.22089.1 Provides tools for finding, instantiating and customizing templates in cookiecutter format.

    Linux Core Dump Debugging 1.0.9.32408 Enables debugging of Linux core dumps.

    Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

    NuGet Package Manager 6.2.1 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

    Python - Django support 17.0.22089.1 Provides templates and integration for the Django web framework.

    Python - Profiling support 17.0.22089.1 Profiling support for Python projects.

    Python - VC Project Support 17.0.21344.1 Provides support for launching C++ projects with Python debugging enabled.

    Python with Pylance 17.0.22089.1 Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers.

    Test Adapter for Boost.Test 1.0 Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory.

    Test Adapter for Google Test 1.0 Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory.

    TypeScript Tools 17.0.10418.2001 TypeScript Tools for Microsoft Visual Studio

    Visual Basic Tools 4.2.0-4.22281.5+8d3180e5f00d42f0f0295165f756f368f0cbfa44 Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

    Visual C++ for Linux Development 1.0.9.32408 Visual C++ for Linux Development

    Visual Studio IntelliCode 2.2 AI-assisted development for Visual Studio.

    opened by jmanthony3 5
  • Subs doesn't work all the time with the imaginary unit

    Subs doesn't work all the time with the imaginary unit

    I noticed that in some case you cannot replace the imaginary unit with "subs", for example :

    J = Symbol('J')
    equation = I + 1
    print(equation.subs(I, J))
    

    Result : 1 + I

    I tried to do some tests and it looks like this happens when "i" is linked to an operation with a number.

    • Example 1 :
    x = Symbol('x')
    equation = I + x
    print(equation.subs(I, J))
    

    Result : J + x

    • Example 2 :
    equation = I / 3
    print(equation.subs(I, J))
    

    Result : 1/3*I

    • Example 3 :
    equation = I / x
    print(equation.subs(I, J))
    

    Result : J/x

    opened by MWalbecq 0
  • looking for c++ tutorial

    looking for c++ tutorial

    Hi, I have looked in many places but I could not find a systematic tutorial to the c++ version, is there any? If not, where can I find some hint on how to declare a complex variable and how to perform substitutions.

    opened by Arvendui 1
  • Inconsistent Styles

    Inconsistent Styles

    I noticed that in many places, SymEngine uses and and or, which are the alternative operator representations of && and ||. In other places, the standard && and || were used.

    Which one is best to use has been the subject of quite some discussion on Stack Overflow.

    However, many people suggest sticking to the standard && and || pair.

    Moreover, these alternative operator representations aren't even taught in most introductory C++ courses so it comes as a big surprise to newcomers. The Google Style Guide uses &&, as does the LLVM Style Guide.

    opened by wermos 1
  • Using symengine as a backend for sympy

    Using symengine as a backend for sympy

    In reading the FAQ at https://symengine.org/misc/faq.html, it says:

    What does this have to do with SymPy?
    SymEngine has a different structure (organizational and financial). 
    
    However, there are many developers in common, and sympy is able to use symengine as a back-end.
    

    How exactly do we swap the backend in sympy to symengine?

    opened by sremedios 3
Releases(v0.9.0)
  • v0.9.0(Feb 16, 2022)

    Build system changes

    • Cereal is a hard dependency now. By default, the vendored copy is used, but cmake option WITH_SYSTEM_CEREAL can be turned on to use an external installation.

    New Features

    • Serialization using cereal - #1704, #1867, #1871
    • Support Piecewise in parser - #1882
    • Add sets Naturals and Naturals0 - #1874
    • Add Tuple class - #1873
    • Product of n terms in cwrapper - #1880
    • Refine x**n**k => x**(n*k) in certain cases - #1863
    • Support set of complex numbers by assumptions - #1841
    • Refine log of integers which are perfect powers - #1864
    • Add function to decompose perfect powers - #1862
    • Add logarithm power rule to refine - #1861
    • Add sets to cwrapper - #1845
    • Add is_algebraic and is_transcendental - #1819
    • First version of simplify - #1831
    • Add ceiling and floor to cwrapper - #1851
    • Add polygonal numbers and polygonal roots functions - #1688
    • sbml parser: add support for zero arg function symbols - #1844
    • Add boundary, closure and interior of Set - #1834

    Bug Fixes

    • Fix building docs - #1856
    • Fix unicode printer for windows - #1872
    • Return NaN when subs results in 0/0 - #1853
    • Fixes for "static initialization order fiasco" - #1849

    People who contributed to the release:

    • Isuru Fernando
    • Björn Dahlgren
    • Rikard Nordgren
    • Alec Edgington
    • Liam Keegan
    • Pieter Eendebak
    • Rohit Goswami
    • Zgoda Iu.N
    Source code(tar.gz)
    Source code(zip)
    symengine-0.9.0.tar.gz(857.98 KB)
  • v0.8.1(Sep 6, 2021)

  • v0.8.0(Sep 4, 2021)

    Breaking changes

    • Let 0 * real be exactly 0 (fix #1559) - #1769
    • Return SYMENGINE_NOT_IMPLEMENTED in basic_solve_poly - #1668

    New Features

    • Add SBML infix parsing and printing - #1785
    • Add refine function - #1800
    • Add unicode printer - #1782
    • Allow assumptions in is_positive etc - #1795, #1765, #1793
    • Add is_polynomial, is_complex, is_integer, is_finite, is_infinite, is_nonzero, is_odd, is_even, is_rational and is_irrational - #1747, #1753, #1775, #1764, #1776, #1817, #1818
    • Add optional local_parser_constants to Parser - #1773
    • Add primorial, primepi function - #1762, #1771
    • Add rewrite_as_sin - #1778
    • Add floor, ceiling functions to parser - #1783
    • Add logical operators to subs - #1797
    • Add sup and inf for sets - #1813
    • Add set of complex numbers - #1811
    • Wrap add(vector) in C - #1829

    Bug Fixes

    • Check for libflint-arb as well as libarb - #1749
    • Fixes segfault when parsing long expressions - #1805
    • Fix compatibility with newer boost versions - #1803
    • fix naming of llvm intrinsics - #1751
    • Mark some RCP functions as const - #1756
    • Support parsing unary plus (fixes #1720) - #1767
    • Simplify floor(constant + integer) to integer - #1763
    • Add Assumptions class - #1759
    • Better symbols for number sets in LaTeX printing - #1760
    • Fix rationals not being canonicalized with boost - #1788
    • LLVM intrinsics fixes for new LLVM versions - #1810, #1823
    • Use SymEngine exceptions in LLVMVisitor - #1824
    • Fix building with cotire - #1825
    • Fix exp(x + num)/exp(x) not evaluating - #1828
    • Fix exception handling for basic_diff - #1830

    People who contributed to the release:

    • Jialin Ma
    • Naveen Sai
    • Liam Keegan
    • Isuru Fernando
    • Peter Schmitteckert
    • Rikard Nordgren
    • Alec Edgington
    • Björn Dahlgren
    • Tom Barrett
    Source code(tar.gz)
    Source code(zip)
    symengine-0.8.0.tar.gz(715.61 KB)
  • v0.7.0(Mar 12, 2021)

    Breaking changes

    • Rename typeID enums to avoid conflicts - #1656

    Build system changes

    • Support LLVM 11 - #1678, - #1691
    • Support Apple Silicon - #1735
    • Allow using symengine as a subdirectory in other CMake projects - #1670
    • Partial support for Oracle Development Studio - #1657

    New Features

    • Add Float & LongDouble LLVMVisitors to cwrapper - #1645
    • Add is_positive_definite for DenseMatrix - #1710
    • Add set of Rationals - #1713
    • Add trace for DenseMatrix - #1706
    • Add tests for diagonal dominance for DenseMatrix - #1707
    • Add is_positive, is_nonpositive, is_negative and is_nonnegative - #1705
    • Add test methods for zero, real, diagonal, symmetric and hermitian matrices - #1703
    • Add tribool type and update is_zero to return tribool - #1698
    • Add elementwise_mul_matrix method for Dense and CSR matrices - #1693
    • Add Integers set - #1695
    • Add conjugate, conjugate_transpose and is_square for matrices - #1690
    • Add function_symbols() method to get all function_symbols - #1687
    • Add Reals set - #1686
    • Parse atan2 in the string parser - #1664
    • Add UnevaluatedExpr - #1641

    Bug Fixes

    • Fix a segfault in lambda_double.h - #1734
    • Fix LambdaRealDoubleVisitor use-after-free issue - #1722
    • Fix subs with coefficient in Mul - #1655
    • Fix union of FiniteSet containing symbols and Interval - #1650
    • Faster determinant and Eigen Value Calculation - #1651
    • Fix a crash in CSRMatrix - #1700
    • Fix checking for float zero in matrix operations - #1683
    • Fix some warnings on windows - #1663
    • Fix return value of basic_solve_poly - #1635
    • Add support for newer versions of binutils - #1714

    People who contributed to the release:

    • Jialin Ma
    • Isuru Fernando
    • Björn Dahlgren
    • Rikard Nordgren
    • Ondřej Čertík
    • Will Simmons
    • myd7349
    • Fabian Köhler
    Source code(tar.gz)
    Source code(zip)
    symengine-0.7.0.tar.gz(783.50 KB)
  • v0.6.0(Feb 10, 2020)

    Bug Fixes

    • Use opt_level in code generation - #1615
    • Add const qualifier to call method in LLVM visitors - #1619
    • Update license for Bison parser code and cotire code - #1627, #1628
    • Hide LLVM symbols in osx - #1629
    • Fix linsolve segfault - #1632

    Build system changes

    • Support for LLVM 10 - #1636

    New Functionality

    • Add cancel method - #1625
    • Add opt_level to some init calls - #1615
    • Add Julia specialization for print calls - #1616

    People who contributed to the release:

    • Simon Stelter
    • Isuru Fernando
    • Roger Luo
    • Björn Dahlgren
    • Jogi Miglani
    • Ondřej Čertík
    • Jialin Ma
    • Liam Keegan
    Source code(tar.gz)
    Source code(zip)
    symengine-0.6.0.tar.gz(745.58 KB)
  • v0.5.0(Sep 10, 2019)

    Bug Fixes

    • Fix LLVMDoubleVisitor save->load->save->load bug - #1549
    • Fix coeff(x+1, x, 0) - #1564
    • Fix finding LLVM in SymEngineConfig.cmake - #1553
    • Fix path prefix in Binder-based environments - #1554
    • Add a virtual destructor to Visitor - #1580

    Build system changes

    • Modified parser to use re2c and bison - #1588, #1591, #1593, #1594
    • LLVM 8 support - #1531
    • Removed -march=native from default flags - #1569
    • Versioned the DLL - #1604

    New Functionality

    • Multi precision support for upper and lower gamma using MPFR 4 - #1544, #1545
    • 32-bit and 80-bit floating point support to LLVMVisitor - #1606
    • Option to cache intermediate expression in diff and subs - #1592, #1582
    • Add loggamma function to C wrapper API - #1556
    • Add truncate function - #1555
    • Avoid revisit in CountOpsVisitor - #1557
    • Add mathml, latex, ccode, jscode to cwrapper - #1562
    • Add kronecker_delta, lowergamma, uppergamma, beta, polygamma to cwrapper - #1603
    • Allow symengine rcp even in debug mode - #1548

    People who contributed to the release:

    • Björn Dahlgren
    • Ondřej Čertík
    • Isuru Fernando
    • Connor Behan
    • Jialin Ma
    • Brandon Bocklund
    • Marcello Mansueto
    • Steven Lee
    Source code(tar.gz)
    Source code(zip)
    symengine-0.5.0.tar.gz(743.47 KB)
  • v0.4.1(Jul 27, 2019)

  • v0.4.0(Mar 28, 2019)

    New Functionality

    • New parser based on bison and flex
    • Initial support to generate symengine code for a matchpy expression
    • Supporting symbols in evalf
    • Reduced row echelon form
    • count_ops to count operations of an expression
    • Latex and MathML printing
    • Saving and loading LLVM compiled functions
    • Common subexpression elimination
    • xeus-cling and binder support
    • xreplace method
    • New functions dense_matrix_row_del, dense_matrix_col_del in C Wrappers and row_insert and col_insert in class DenseMatrix- #1313
    • expand_as_exp() member function is removed from derived classes of TrigFunction and HyperbolicFunction and implemented using visitor design pattern - #1309
    • as_real_imag- #1310
    • Polynomial Solvers - #1296
    • Floor and Ceiling classes - #1297 and #1290
    • Conjugate class - #1295
    • ConditionSet - #1291
    • Sign class - #1287
    • Vector-specific methods dot and cross - #1286
    • Dummy class - #1284
    • Relationals - #1276, #1279, #1280
    • Flint wrappers for factorization - #1274
    • New functions dense_matrix_row_join, dense_matrix_col_join in C Wrappers - #1273
    • Functions column_exchange_dense, row_join, col_join, row_del and col_del in class DenseMatrix - #1269
    • New functions vecbasic_set, vecbasic_erase, setbasic_erase in CWrappers - #1264, #1272
    • New functions number_is_zero, number_is_positive, number_is_negative, number_is_complex in CWrappers - #1256

    Breaking Changes

    • SONAME updated to 0.4 (SONAME will pin to . for major version 0.)
    • complex_*real_part, complex_*imaginary_part are replaced by methods complex_base_real_part and complex_base_imaginary_part - #1263
    • real_mpfr_is_zero, complex_mpc_is_zero is replaced by method number_is_zero - #1256
    • basic_number_sign is replaced by methods number_is_zero, number_is_positive, number_is_negative - #1256

    Bug Fixes

    • Additional comparison clause in Dummy::compare - #1304
    • Add oo and zoo to the parser - #1261
    • Fix segmentation fault in LLVMDoubleVisitor - #1260
    • NaN and infs in JuliaStrPrinter - #1258
    • The base classes for inverse trigonometric and inverse hyperbolic functions are now InverseTrigFunction and InverseHyperbolicFunction respectively. Base class for TrigFunction and InverseTrigFunction is TrigBase. Similarly, base class for HyperbolicFunction and InverseHyperbolicFunction is HyperbolicBase. #1309

    And many other changes, here is a list of merged PRs not mentioned above:

    • https://github.com/symengine/symengine/pulls?utf8=%E2%9C%93&q=is%3Apr+merged%3A2017-07-25..2019-03-28

    People who contributed to the release:

    • Srajan Garg
    • Dirk Reusch
    • Ranjith Kumar
    • Isuru Fernando
    • Jean-Paul Pelteret
    • Shikhar Jaiswal
    • Sumith Kulal
    • Ondřej Čertík
    • Jialin Ma
    • Gerrit Ansmann
    • Björn Dahlgren
    • Nilay Pochhi
    • Eeshan Gupta
    • Ziyi Yan
    • Andreas Humenberger
    • Kieran Kaempen
    • Clouds Flowing
    • Sylvain Corlay
    • Alan Hu
    • Rajiv Ranjan Singh
    • Francesco Bonazzi
    • Simon Stelter
    Source code(tar.gz)
    Source code(zip)
    symengine-0.4.0.tar.gz(736.00 KB)
  • v0.3.0(May 8, 2017)

    Major changes

    • Version libsymengine.so - #1239

    New Features

    • Use LLVM for compiling an expression to a function - #1094, #1220, #1242, #1244, #1245
    • Completely permissive licensed build using Boost.multiprecision - #1121
    • Macros and functions for checking version and features - #1135, #1114
    • Julia printer #1246
    • Support for NaN #1178
    • Error functions - #1097
    • More logic functions - #1206, #1102, #1098

    Improvements

    • Cwrappers wrap more functions #1249, #1143, #1123, #1110
    • Parser Allow unicode and implicit multiplication, - #1231, #1235
    • More functions now immediately evaluate with floats - #1205, #1202, #1192, #1189, #1185, #1177, #1172
    • More derivatives - #1199, #1166, #1152, #1151
    • Complex numbers inherit from ComplexBase - #1171

    Bug Fixes / Minor changes

    • Printing E**x is changed to exp(x) - #1136
    • Fix bug in trigonometric functions - #1051
    • Make hash function platform independent - #1233
    • Dividing by zero returns zoo - #1170
    • Fix double printing #1248
    • Fix bug in mpc evaluation #1210
    • Fix bug in gamma functions #1204
    • Fix bug in abs, sinh that lead to infinite recursion #1198
    • Fix bug in pow #1229, #1165

    People who contributed to the release

    • Isuru Fernando
    • Ralf Stephan
    • Akash Trehan
    • Ritesh Kumar
    • Shikhar Jaiswal
    • Srajan Garg
    • Vishu Sidana
    • Ondřej Čertík
    • Siddharth Bhat
    • Tao He
    • Chad Mills
    • Abhimanyu Siwach
    • Jean-Paul Pelteret
    • Ranjith Kumar
    • Kv Manohar
    • Sumith Kulal
    • Kanchana Ruwanpathirana
    • Melanka Saroad
    Source code(tar.gz)
    Source code(zip)
    binaries-msvc-x86.tar.bz2(5.46 MB)
    binaries-msvc-x86_64.tar.bz2(6.14 MB)
    symengine-0.3.0-binaries-msvc-x86.tar.bz2(5.47 MB)
    symengine-0.3.0-binaries-msvc-x86_64.tar.bz2(6.17 MB)
    symengine-0.3.0.tar.gz(615.05 KB)
  • v0.2.0(Sep 1, 2016)

  • v0.1.0(Aug 10, 2015)

Owner
SymEngine is a fast symbolic manipulation library, written in C++
null
Fast math tool written on asm/c

math_tool fast math tool written on asm/c This project was created for easy use of mathematical / geometric rules and operations. This project contain

portable executable 3 Mar 8, 2022
Blazing-fast Expression Templates Library (ETL) with GPU support, in C++

Expression Templates Library (ETL) 1.3.0 ETL is a header only library for C++ that provides vector and matrix classes with support for Expression Temp

Baptiste Wicht 201 Jun 4, 2022
Kraken is an open-source modern math library that comes with a fast-fixed matrix class and math-related functions.

Kraken ?? Table of Contents Introduction Requirement Contents Installation Introduction Kraken is a modern math library written in a way that gives ac

yahya mohammed 24 Mar 28, 2022
LibTomMath is a free open source portable number theoretic multiple-precision integer library written entirely in C.

libtommath This is the git repository for LibTomMath, a free open source portable number theoretic multiple-precision integer (MPI) library written en

libtom 520 Jun 25, 2022
nml is a simple matrix and linear algebra library written in standard C.

nml is a simple matrix and linear algebra library written in standard C.

Andrei Ciobanu 33 Jun 4, 2022
SIMD (SSE) implementation of the infamous Fast Inverse Square Root algorithm from Quake III Arena.

simd_fastinvsqrt SIMD (SSE) implementation of the infamous Fast Inverse Square Root algorithm from Quake III Arena. Why Why not. How This video explai

Liam 7 Jan 28, 2022
Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON)

KFR - Fast, modern C++ DSP framework Compiler support: https://www.kfr.dev KFR is an open source C++ DSP framework that focuses on high performance (s

KFR 1.2k Jun 26, 2022
MIRACL Cryptographic SDK: Multiprecision Integer and Rational Arithmetic Cryptographic Library is a C software library that is widely regarded by developers as the gold standard open source SDK for elliptic curve cryptography (ECC).

MIRACL What is MIRACL? Multiprecision Integer and Rational Arithmetic Cryptographic Library – the MIRACL Crypto SDK – is a C software library that is

MIRACL 482 Jun 24, 2022
A C library for statistical and scientific computing

Apophenia is an open statistical library for working with data sets and statistical or simulation models. It provides functions on the same level as t

null 184 Jun 17, 2022
P(R*_{3, 0, 1}) specialized SIMD Geometric Algebra Library

Klein ?? ?? Project Site ?? ?? Description Do you need to do any of the following? Quickly? Really quickly even? Projecting points onto lines, lines t

Jeremy Ong 599 Jun 17, 2022
linalg.h is a single header, public domain, short vector math library for C++

linalg.h linalg.h is a single header, public domain, short vector math library for C++. It is inspired by the syntax of popular shading and compute la

Sterling Orsten 724 Jun 23, 2022
a lean linear math library, aimed at graphics programming. Supports vec3, vec4, mat4x4 and quaternions

linmath.h -- A small library for linear math as required for computer graphics linmath.h provides the most used types required for programming compute

datenwolf 684 Jun 12, 2022
OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.

OpenBLAS Travis CI: AppVeyor: Drone CI: Introduction OpenBLAS is an optimized BLAS (Basic Linear Algebra Subprograms) library based on GotoBLAS2 1.13

Zhang Xianyi 4.6k Jul 1, 2022
The QuantLib C++ library

QuantLib: the free/open-source library for quantitative finance The QuantLib project (http://quantlib.org) is aimed at providing a comprehensive softw

Luigi Ballabio 3.3k Jun 27, 2022
A C++ header-only library of statistical distribution functions.

StatsLib StatsLib is a templated C++ library of statistical distribution functions, featuring unique compile-time computing capabilities and seamless

Keith O'Hara 377 Jun 19, 2022
RcppFastFloat: Rcpp Bindings for the fastfloat C++ Header-Only Library

Converting ascii text into (floating-point) numeric values is a very common problem. The fast_float header-only C++ library by Daniel Lemire does this very well, and very fast at up to or over to 1 gigabyte per second as described in more detail in a recent arXiv paper.

Dirk Eddelbuettel 18 May 2, 2022
📽 Highly optimized 2D|3D math library, also known as OpenGL Mathematics (glm) for `C

Highly optimized 2D|3D math library, also known as OpenGL Mathematics (glm) for `C`. cglm provides lot of utils to help math operations to be fast and quick to write. It is community friendly, feel free to bring any issues, bugs you faced.

Recep Aslantas 1.4k Jun 22, 2022
✨sigmatch - Modern C++ 20 Signature Match / Search Library

sigmatch Modern C++ 20 Signature Match / Search Library ✨ Features ?? Header-only, no dependencies, no exceptions. ☕ Compile-time literal signature st

Sprite 35 Jun 22, 2022
C++ library for solving large sparse linear systems with algebraic multigrid method

AMGCL AMGCL is a header-only C++ library for solving large sparse linear systems with algebraic multigrid (AMG) method. AMG is one of the most effecti

Denis Demidov 528 Jun 22, 2022