Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

LLVM float and long double #309

Merged
merged 4 commits into from
Feb 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8)
project(python_wrapper)

set(CMAKE_PREFIX_PATH ${SymEngine_DIR} ${CMAKE_PREFIX_PATH})
find_package(SymEngine 0.5.0 REQUIRED CONFIG
find_package(SymEngine 0.6.0 REQUIRED CONFIG
PATH_SUFFIXES lib/cmake/symengine cmake/symengine CMake/)
message("SymEngine_DIR : " ${SymEngine_DIR})
message("SymEngine Version : " ${SymEngine_VERSION})
Expand Down Expand Up @@ -30,6 +30,15 @@ if (MINGW AND (CMAKE_BUILD_TYPE STREQUAL "Release"))
endif()
endif()

include(CheckTypeSize)
check_type_size("long double" SYMENGINE_SIZEOF_LONG_DOUBLE)

if (HAVE_SYMENGINE_LLVM AND SYMENGINE_SIZEOF_LONG_DOUBLE GREATER "8" AND CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
set (HAVE_SYMENGINE_LLVM_LONG_DOUBLE True)
else ()
set (HAVE_SYMENGINE_LLVM_LONG_DOUBLE False)
endif ()

foreach (PKG MPC MPFR PIRANHA FLINT LLVM)
if ("${HAVE_SYMENGINE_${PKG}}" STREQUAL "")
set(HAVE_SYMENGINE_${PKG} False)
Expand Down
1 change: 1 addition & 0 deletions symengine/lib/config.pxi.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ DEF HAVE_SYMENGINE_MPC = ${HAVE_SYMENGINE_MPC}
DEF HAVE_SYMENGINE_PIRANHA = ${HAVE_SYMENGINE_PIRANHA}
DEF HAVE_SYMENGINE_FLINT = ${HAVE_SYMENGINE_FLINT}
DEF HAVE_SYMENGINE_LLVM = ${HAVE_SYMENGINE_LLVM}
DEF HAVE_SYMENGINE_LLVM_LONG_DOUBLE = ${HAVE_SYMENGINE_LLVM_LONG_DOUBLE}
15 changes: 12 additions & 3 deletions symengine/lib/symengine.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -985,13 +985,22 @@ cdef extern from "<symengine/lambda_double.h>" namespace "SymEngine":
void call(double complex *r, const double complex *x) nogil

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

cdef cppclass LLVMFloatVisitor(LLVMVisitor):
void call(float *r, const float *x) nogil

cdef cppclass LLVMDoubleVisitor(LLVMVisitor):
void call(double *r, const double *x) nogil

cdef cppclass LLVMLongDoubleVisitor(LLVMVisitor):
void call(long double *r, const long double *x) nogil


cdef extern from "<symengine/series.h>" namespace "SymEngine":
cdef cppclass SeriesCoeffInterface:
rcp_const_basic as_basic() nogil except +
Expand Down
33 changes: 25 additions & 8 deletions symengine/lib/symengine_wrapper.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,46 @@ cdef class _Lambdify(object):

cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse)
cdef _load(self, const string &s)
cpdef unsafe_real(self,
double[::1] inp, double[::1] out,
int inp_offset=*, int out_offset=*)
cpdef unsafe_complex(self, double complex[::1] inp, double complex[::1] out,
int inp_offset=*, int out_offset=*)
cpdef eval_real(self, inp, out)
cpdef eval_complex(self, inp, out)
cpdef unsafe_eval(sef, inp, out, unsigned nbroadcast=*)

cdef class LambdaDouble(_Lambdify):
cdef vector[symengine.LambdaRealDoubleVisitor] lambda_double
cdef vector[symengine.LambdaComplexDoubleVisitor] lambda_double_complex
cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse)
cpdef unsafe_real(self, double[::1] inp, double[::1] out, int inp_offset=*, int out_offset=*)
cpdef unsafe_complex(self, double complex[::1] inp, double complex[::1] out, int inp_offset=*, int out_offset=*)
cpdef as_scipy_low_level_callable(self)
cpdef as_ctypes(self)
cpdef unsafe_real(self,
double[::1] inp, double[::1] out,
int inp_offset=*, int out_offset=*)

cdef class LambdaComplexDouble(_Lambdify):
cdef vector[symengine.LambdaComplexDoubleVisitor] lambda_double
cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse)
cpdef unsafe_complex(self, double complex[::1] inp, double complex[::1] out, int inp_offset=*, int out_offset=*)

IF HAVE_SYMENGINE_LLVM:
cdef class LLVMDouble(_Lambdify):
cdef class _LLVMLambdify(_Lambdify):
cdef int opt_level

cdef class LLVMDouble(_LLVMLambdify):
cdef vector[symengine.LLVMDoubleVisitor] lambda_double
cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse)
cdef _load(self, const string &s)
cpdef unsafe_real(self, double[::1] inp, double[::1] out, int inp_offset=*, int out_offset=*)
cpdef as_scipy_low_level_callable(self)
cpdef as_ctypes(self)

cdef class LLVMFloat(_LLVMLambdify):
cdef vector[symengine.LLVMFloatVisitor] lambda_double
cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse)
cdef _load(self, const string &s)
cpdef unsafe_real(self, float[::1] inp, float[::1] out, int inp_offset=*, int out_offset=*)

IF HAVE_SYMENGINE_LLVM_LONG_DOUBLE:
cdef class LLVMLongDouble(_LLVMLambdify):
cdef vector[symengine.LLVMLongDoubleVisitor] lambda_double
cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse)
cdef _load(self, const string &s)
cpdef unsafe_real(self, long double[::1] inp, long double[::1] out, int inp_offset=*, int out_offset=*)
Loading