Skip to content

Commit

Permalink
Merge pull request #145 from isuruf/compat
Browse files Browse the repository at this point in the history
Make symengine.lib.symengine_wrapper compatible with sympy
  • Loading branch information
certik authored Jun 11, 2017
2 parents 4c73dc4 + 245ccab commit bf388b5
Show file tree
Hide file tree
Showing 10 changed files with 618 additions and 945 deletions.
2 changes: 1 addition & 1 deletion symengine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ add_subdirectory(lib)
add_subdirectory(tests)

set(PY_PATH ${PYTHON_INSTALL_PATH}/symengine)
install(FILES __init__.py utilities.py compatibility.py sympy_compat.py
install(FILES __init__.py utilities.py compatibility.py sympy_compat.py functions.py
DESTINATION ${PY_PATH}
)
19 changes: 11 additions & 8 deletions symengine/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from .lib.symengine_wrapper import (Symbol, Integer, sympify, SympifyError,
Add, Mul, Pow, exp, log, gamma, sqrt, function_symbol, I, E, pi,
have_mpfr, have_mpc, have_flint, have_piranha, have_llvm,
RealDouble, ComplexDouble, MutableDenseMatrix, ImmutableDenseMatrix,
DenseMatrix, Matrix, sin, cos, tan, cot, csc, sec, asin, acos, atan,
acot, acsc, asec, sinh, cosh, tanh, coth, asinh, acosh, atanh, acoth,
Lambdify, LambdifyCSE, DictBasic, series, symarray, diff, zeros, eye,
diag, ones, zeros, add, expand, has_symbol, UndefFunction)
from .lib.symengine_wrapper import (Symbol, sympify as S, sympify,
SympifyError, Add, Mul, Pow, function_symbol, I, E, pi,
have_mpfr, have_mpc, have_flint, have_piranha, have_llvm,
Integer, Rational, Float, Number, RealNumber, RealDouble,
ComplexDouble, Max, Min, DenseMatrix, Matrix, ImmutableMatrix,
ImmutableDenseMatrix, MutableDenseMatrix, MatrixBase, Basic,
Lambdify, LambdifyCSE, Lambdify as lambdify, DictBasic, symarray,
series, diff, zeros, eye, diag, ones, Derivative, Subs,
add, expand, has_symbol, UndefFunction, Function,
FunctionSymbol as AppliedUndef)
from .utilities import var, symbols
from .functions import *

if have_mpfr:
from .lib.symengine_wrapper import RealMPFR
Expand Down
5 changes: 5 additions & 0 deletions symengine/functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .lib.symengine_wrapper import (sin, cos, tan, cot, csc, sec,
asin, acos, atan, acot, acsc, asec,
sinh, cosh, tanh, coth, sech, csch,
asinh, acosh, atanh, acoth, asech, acsch,
gamma, log, atan2, sqrt, exp, Abs)
32 changes: 17 additions & 15 deletions symengine/lib/symengine.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ cdef extern from "<symengine/symengine_rcp.h>" namespace "SymEngine":
RCP[const Add] rcp_static_cast_Add "SymEngine::rcp_static_cast<const SymEngine::Add>"(RCP[const Basic] &b) nogil
RCP[const Mul] rcp_static_cast_Mul "SymEngine::rcp_static_cast<const SymEngine::Mul>"(RCP[const Basic] &b) nogil
RCP[const Pow] rcp_static_cast_Pow "SymEngine::rcp_static_cast<const SymEngine::Pow>"(RCP[const Basic] &b) nogil
RCP[const TrigFunction] rcp_static_cast_TrigFunction "SymEngine::rcp_static_cast<const SymEngine::TrigFunction>"(RCP[const Basic] &b) nogil
RCP[const HyperbolicFunction] rcp_static_cast_HyperbolicFunction "SymEngine::rcp_static_cast<const SymEngine::HyperbolicFunction>"(RCP[const Basic] &b) nogil
RCP[const OneArgFunction] rcp_static_cast_OneArgFunction "SymEngine::rcp_static_cast<const SymEngine::OneArgFunction>"(RCP[const Basic] &b) nogil
RCP[const FunctionSymbol] rcp_static_cast_FunctionSymbol "SymEngine::rcp_static_cast<const SymEngine::FunctionSymbol>"(RCP[const Basic] &b) nogil
RCP[const FunctionWrapper] rcp_static_cast_FunctionWrapper "SymEngine::rcp_static_cast<const SymEngine::FunctionWrapper>"(RCP[const Basic] &b) nogil
RCP[const Abs] rcp_static_cast_Abs "SymEngine::rcp_static_cast<const SymEngine::Abs>"(RCP[const Basic] &b) nogil
Expand Down Expand Up @@ -445,9 +444,12 @@ cdef extern from "<symengine/functions.h>" namespace "SymEngine":
cdef cppclass Function(Basic):
pass

cdef cppclass TrigFunction(Function):
cdef cppclass OneArgFunction(Function):
RCP[const Basic] get_arg() nogil

cdef cppclass TrigFunction(OneArgFunction):
pass

cdef cppclass Sin(TrigFunction):
pass

Expand Down Expand Up @@ -484,8 +486,8 @@ cdef extern from "<symengine/functions.h>" namespace "SymEngine":
cdef cppclass ASec(TrigFunction):
pass

cdef cppclass HyperbolicFunction(Function):
RCP[const Basic] get_arg() nogil
cdef cppclass HyperbolicFunction(OneArgFunction):
pass

cdef cppclass Sinh(HyperbolicFunction):
pass
Expand Down Expand Up @@ -542,16 +544,16 @@ cdef extern from "<symengine/functions.h>" namespace "SymEngine":
vec_basic get_variables() nogil
vec_basic get_point() nogil

cdef cppclass Abs(Function):
RCP[const Basic] get_arg() nogil
cdef cppclass Abs(OneArgFunction):
pass

cdef cppclass Max(Function):
pass

cdef cppclass Min(Function):
pass

cdef cppclass Gamma(Function):
cdef cppclass Gamma(OneArgFunction):
pass

cdef cppclass ATan2(Function):
Expand Down Expand Up @@ -656,17 +658,17 @@ cdef extern from "<symengine/matrix.h>" namespace "SymEngine":
bool is_a_DenseMatrix "SymEngine::is_a<SymEngine::DenseMatrix>"(const MatrixBase &b) nogil
DenseMatrix* static_cast_DenseMatrix "static_cast<SymEngine::DenseMatrix*>"(const MatrixBase *a)
void inverse_FFLU "SymEngine::inverse_fraction_free_LU"(const DenseMatrix &A,
DenseMatrix &B) nogil
void pivoted_LU (const DenseMatrix &A, DenseMatrix &L, DenseMatrix &U, vector[int] &P) nogil
void pivoted_LU_solve (const DenseMatrix &A, const DenseMatrix &b, DenseMatrix &x) nogil
DenseMatrix &B) nogil except +
void pivoted_LU (const DenseMatrix &A, DenseMatrix &L, DenseMatrix &U, vector[int] &P) nogil except +
void pivoted_LU_solve (const DenseMatrix &A, const DenseMatrix &b, DenseMatrix &x) nogil except +
void inverse_GJ "SymEngine::inverse_gauss_jordan"(const DenseMatrix &A,
DenseMatrix &B) nogil
DenseMatrix &B) nogil except +
void FFLU_solve "SymEngine::fraction_free_LU_solve"(const DenseMatrix &A,
const DenseMatrix &b, DenseMatrix &x) nogil
const DenseMatrix &b, DenseMatrix &x) nogil except +
void FFGJ_solve "SymEngine::fraction_free_gauss_jordan_solve"(const DenseMatrix &A,
const DenseMatrix &b, DenseMatrix &x) nogil
const DenseMatrix &b, DenseMatrix &x) nogil except +
void LDL_solve "SymEngine::LDL_solve"(const DenseMatrix &A, const DenseMatrix &b,
DenseMatrix &x) nogil
DenseMatrix &x) nogil except +
void jacobian "SymEngine::sjacobian"(const DenseMatrix &A,
const DenseMatrix &x, DenseMatrix &result) nogil except +
void diff "SymEngine::sdiff"(const DenseMatrix &A,
Expand Down
150 changes: 0 additions & 150 deletions symengine/lib/symengine_wrapper.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -4,159 +4,9 @@ from symengine cimport RCP, map_basic_basic
cdef class Basic(object):
cdef RCP[const symengine.Basic] thisptr

cdef class Number(Basic):
pass

cdef class Integer(Number):
pass

cdef class Rational(Number):
pass

cdef class Complex(Number):
pass

cdef class RealDouble(Number):
pass

cdef class ComplexDouble(Number):
pass

cdef class RealMPFR(Number):
pass

cdef class ComplexMPC(Number):
pass

cdef class PyNumber(Number):
pass

cdef class Add(Basic):
pass

cdef class Mul(Basic):
pass

cdef class Pow(Basic):
pass

cdef class Function(Basic):
pass

cdef class TrigFunction(Function):
pass

cdef class Sin(TrigFunction):
pass

cdef class Cos(TrigFunction):
pass

cdef class Tan(TrigFunction):
pass

cdef class Cot(TrigFunction):
pass

cdef class Csc(TrigFunction):
pass

cdef class Sec(TrigFunction):
pass

cdef class ASin(TrigFunction):
pass

cdef class ACos(TrigFunction):
pass

cdef class ATan(TrigFunction):
pass

cdef class ACot(TrigFunction):
pass

cdef class ACsc(TrigFunction):
pass

cdef class ASec(TrigFunction):
pass

cdef class HyperbolicFunction(Function):
pass

cdef class Sinh(HyperbolicFunction):
pass

cdef class Cosh(HyperbolicFunction):
pass

cdef class Tanh(HyperbolicFunction):
pass

cdef class Coth(HyperbolicFunction):
pass

cdef class Csch(HyperbolicFunction):
pass

cdef class Sech(HyperbolicFunction):
pass

cdef class ASinh(HyperbolicFunction):
pass

cdef class ACosh(HyperbolicFunction):
pass

cdef class ATanh(HyperbolicFunction):
pass

cdef class ACoth(HyperbolicFunction):
pass

cdef class ACsch(HyperbolicFunction):
pass

cdef class ASech(HyperbolicFunction):
pass

cdef class FunctionSymbol(Function):
pass

cdef class PyFunction(FunctionSymbol):
pass

cdef class Abs(Function):
pass

cdef class Gamma(Function):
pass

cdef class ATan2(Function):
pass

cdef class Derivative(Basic):
pass

cdef class Subs(Basic):
pass

cdef class MatrixBase(object):
cdef symengine.MatrixBase* thisptr

cdef class DenseMatrixBase(MatrixBase):
pass

cdef class MutableDenseMatrix(DenseMatrixBase):
pass

cdef class ImmutableDenseMatrix(DenseMatrixBase):
pass

cdef class Log(Function):
pass

cdef class PyFunctionClass(object):
cdef RCP[const symengine.PyFunctionClass] thisptr

Expand Down
Loading

0 comments on commit bf388b5

Please sign in to comment.