Skip to content

Commit 9f48c43

Browse files
authored
Merge pull request #309 from isuruf/lambdify
LLVM float and long double
2 parents 4687897 + e831e2d commit 9f48c43

File tree

7 files changed

+222
-64
lines changed

7 files changed

+222
-64
lines changed

CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8)
22
project(python_wrapper)
33

44
set(CMAKE_PREFIX_PATH ${SymEngine_DIR} ${CMAKE_PREFIX_PATH})
5-
find_package(SymEngine 0.5.0 REQUIRED CONFIG
5+
find_package(SymEngine 0.6.0 REQUIRED CONFIG
66
PATH_SUFFIXES lib/cmake/symengine cmake/symengine CMake/)
77
message("SymEngine_DIR : " ${SymEngine_DIR})
88
message("SymEngine Version : " ${SymEngine_VERSION})
@@ -30,6 +30,15 @@ if (MINGW AND (CMAKE_BUILD_TYPE STREQUAL "Release"))
3030
endif()
3131
endif()
3232

33+
include(CheckTypeSize)
34+
check_type_size("long double" SYMENGINE_SIZEOF_LONG_DOUBLE)
35+
36+
if (HAVE_SYMENGINE_LLVM AND SYMENGINE_SIZEOF_LONG_DOUBLE GREATER "8" AND CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
37+
set (HAVE_SYMENGINE_LLVM_LONG_DOUBLE True)
38+
else ()
39+
set (HAVE_SYMENGINE_LLVM_LONG_DOUBLE False)
40+
endif ()
41+
3342
foreach (PKG MPC MPFR PIRANHA FLINT LLVM)
3443
if ("${HAVE_SYMENGINE_${PKG}}" STREQUAL "")
3544
set(HAVE_SYMENGINE_${PKG} False)

symengine/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from .lib.symengine_wrapper import (
2-
have_mpfr, have_mpc, have_flint, have_piranha, have_llvm,
2+
have_mpfr, have_mpc, have_flint, have_piranha, have_llvm, have_llvm_long_double,
33
I, E, pi, oo, zoo, nan, Symbol, Dummy, S, sympify, SympifyError,
44
Integer, Rational, Float, Number, RealNumber, RealDouble, ComplexDouble,
55
add, Add, Mul, Pow, function_symbol,

symengine/lib/config.pxi.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ DEF HAVE_SYMENGINE_MPC = ${HAVE_SYMENGINE_MPC}
33
DEF HAVE_SYMENGINE_PIRANHA = ${HAVE_SYMENGINE_PIRANHA}
44
DEF HAVE_SYMENGINE_FLINT = ${HAVE_SYMENGINE_FLINT}
55
DEF HAVE_SYMENGINE_LLVM = ${HAVE_SYMENGINE_LLVM}
6+
DEF HAVE_SYMENGINE_LLVM_LONG_DOUBLE = ${HAVE_SYMENGINE_LLVM_LONG_DOUBLE}

symengine/lib/symengine.pxd

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -985,13 +985,22 @@ cdef extern from "<symengine/lambda_double.h>" namespace "SymEngine":
985985
void call(double complex *r, const double complex *x) nogil
986986

987987
cdef extern from "<symengine/llvm_double.h>" namespace "SymEngine":
988-
cdef cppclass LLVMDoubleVisitor:
989-
LLVMDoubleVisitor() nogil
988+
cdef cppclass LLVMVisitor:
989+
LLVMVisitor() nogil
990990
void init(const vec_basic &x, const vec_basic &b, bool cse, int opt_level) nogil except +
991-
void call(double *r, const double *x) nogil
992991
const string& dumps() nogil
993992
void loads(const string&) nogil
994993

994+
cdef cppclass LLVMFloatVisitor(LLVMVisitor):
995+
void call(float *r, const float *x) nogil
996+
997+
cdef cppclass LLVMDoubleVisitor(LLVMVisitor):
998+
void call(double *r, const double *x) nogil
999+
1000+
cdef cppclass LLVMLongDoubleVisitor(LLVMVisitor):
1001+
void call(long double *r, const long double *x) nogil
1002+
1003+
9951004
cdef extern from "<symengine/series.h>" namespace "SymEngine":
9961005
cdef cppclass SeriesCoeffInterface:
9971006
rcp_const_basic as_basic() nogil except +

symengine/lib/symengine_wrapper.pxd

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,46 @@ cdef class _Lambdify(object):
3939

4040
cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse)
4141
cdef _load(self, const string &s)
42-
cpdef unsafe_real(self,
43-
double[::1] inp, double[::1] out,
44-
int inp_offset=*, int out_offset=*)
45-
cpdef unsafe_complex(self, double complex[::1] inp, double complex[::1] out,
46-
int inp_offset=*, int out_offset=*)
4742
cpdef eval_real(self, inp, out)
4843
cpdef eval_complex(self, inp, out)
44+
cpdef unsafe_eval(sef, inp, out, unsigned nbroadcast=*)
4945

5046
cdef class LambdaDouble(_Lambdify):
5147
cdef vector[symengine.LambdaRealDoubleVisitor] lambda_double
52-
cdef vector[symengine.LambdaComplexDoubleVisitor] lambda_double_complex
5348
cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse)
5449
cpdef unsafe_real(self, double[::1] inp, double[::1] out, int inp_offset=*, int out_offset=*)
55-
cpdef unsafe_complex(self, double complex[::1] inp, double complex[::1] out, int inp_offset=*, int out_offset=*)
5650
cpdef as_scipy_low_level_callable(self)
5751
cpdef as_ctypes(self)
52+
cpdef unsafe_real(self,
53+
double[::1] inp, double[::1] out,
54+
int inp_offset=*, int out_offset=*)
55+
56+
cdef class LambdaComplexDouble(_Lambdify):
57+
cdef vector[symengine.LambdaComplexDoubleVisitor] lambda_double
58+
cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse)
59+
cpdef unsafe_complex(self, double complex[::1] inp, double complex[::1] out, int inp_offset=*, int out_offset=*)
5860

5961
IF HAVE_SYMENGINE_LLVM:
60-
cdef class LLVMDouble(_Lambdify):
62+
cdef class _LLVMLambdify(_Lambdify):
6163
cdef int opt_level
64+
65+
cdef class LLVMDouble(_LLVMLambdify):
6266
cdef vector[symengine.LLVMDoubleVisitor] lambda_double
6367
cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse)
6468
cdef _load(self, const string &s)
6569
cpdef unsafe_real(self, double[::1] inp, double[::1] out, int inp_offset=*, int out_offset=*)
6670
cpdef as_scipy_low_level_callable(self)
6771
cpdef as_ctypes(self)
72+
73+
cdef class LLVMFloat(_LLVMLambdify):
74+
cdef vector[symengine.LLVMFloatVisitor] lambda_double
75+
cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse)
76+
cdef _load(self, const string &s)
77+
cpdef unsafe_real(self, float[::1] inp, float[::1] out, int inp_offset=*, int out_offset=*)
78+
79+
IF HAVE_SYMENGINE_LLVM_LONG_DOUBLE:
80+
cdef class LLVMLongDouble(_LLVMLambdify):
81+
cdef vector[symengine.LLVMLongDoubleVisitor] lambda_double
82+
cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse)
83+
cdef _load(self, const string &s)
84+
cpdef unsafe_real(self, long double[::1] inp, long double[::1] out, int inp_offset=*, int out_offset=*)

0 commit comments

Comments
 (0)