@@ -5156,27 +5156,27 @@ cdef class LambdaDouble(_Lambdify):
51565156 pass
51575157
51585158 cdef _init(self , symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse):
5159- self .lambda_double.resize( 1 )
5160- self .lambda_double[ 0 ] .init(args_, outs_, cse)
5159+ self .lambda_visitor.reset(new symengine.LambdaRealDoubleVisitor() )
5160+ deref( self .lambda_visitor) .init(args_, outs_, cse)
51615161
51625162 cpdef unsafe_real(self , double [::1 ] inp, double [::1 ] out, int inp_offset = 0 , int out_offset = 0 ):
5163- self .lambda_double[ 0 ] .call(& out[out_offset], & inp[inp_offset])
5163+ deref( self .lambda_visitor) .call(& out[out_offset], & inp[inp_offset])
51645164
51655165 cpdef unsafe_eval(self , inp, out, unsigned nbroadcast = 1 ):
51665166 cdef double [::1 ] c_inp, c_out
51675167 cdef unsigned idx
51685168 c_inp = np.ascontiguousarray(inp.ravel(order = self .order), dtype = self .numpy_dtype)
51695169 c_out = out
51705170 for idx in range (nbroadcast):
5171- self .lambda_double[ 0 ] .call(& c_out[idx* self .tot_out_size], & c_inp[idx* self .args_size])
5171+ deref( self .lambda_visitor) .call(& c_out[idx* self .tot_out_size], & c_inp[idx* self .args_size])
51725172
51735173 cpdef as_scipy_low_level_callable(self ):
51745174 from ctypes import c_double, c_void_p, c_int, cast, POINTER, CFUNCTYPE
51755175 if self .tot_out_size > 1 :
51765176 raise RuntimeError (" SciPy LowLevelCallable supports only functions with 1 output" )
51775177 addr1 = cast(< size_t> & _scipy_callback_lambda_real,
51785178 CFUNCTYPE(c_double, c_int, POINTER(c_double), c_void_p))
5179- addr2 = cast(< size_t> & self .lambda_double[ 0 ] , c_void_p)
5179+ addr2 = cast(< size_t> self .lambda_visitor.get() , c_void_p)
51805180 return create_low_level_callable(self , addr1, addr2)
51815181
51825182 cpdef as_ctypes(self ):
@@ -5191,7 +5191,7 @@ cdef class LambdaDouble(_Lambdify):
51915191 from ctypes import c_double, c_void_p, c_int, cast, POINTER, CFUNCTYPE
51925192 addr1 = cast(< size_t> & _ctypes_callback_lambda_real,
51935193 CFUNCTYPE(c_void_p, POINTER(c_double), POINTER(c_double), c_void_p))
5194- addr2 = cast(< size_t> & self .lambda_double[ 0 ] , c_void_p)
5194+ addr2 = cast(< size_t> self .lambda_visitor.get() , c_void_p)
51955195 return addr1, addr2
51965196
51975197
@@ -5201,19 +5201,19 @@ cdef class LambdaComplexDouble(_Lambdify):
52015201 pass
52025202
52035203 cdef _init(self , symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse):
5204- self .lambda_double.resize( 1 )
5205- self .lambda_double[ 0 ] .init(args_, outs_, cse)
5204+ self .lambda_visitor.reset(new symengine.LambdaComplexDoubleVisitor() )
5205+ deref( self .lambda_visitor) .init(args_, outs_, cse)
52065206
52075207 cpdef unsafe_complex(self , double complex [::1 ] inp, double complex [::1 ] out, int inp_offset = 0 , int out_offset = 0 ):
5208- self .lambda_double[ 0 ] .call(& out[out_offset], & inp[inp_offset])
5208+ deref( self .lambda_visitor) .call(& out[out_offset], & inp[inp_offset])
52095209
52105210 cpdef unsafe_eval(self , inp, out, unsigned nbroadcast = 1 ):
52115211 cdef double complex [::1 ] c_inp, c_out
52125212 cdef unsigned idx
52135213 c_inp = np.ascontiguousarray(inp.ravel(order = self .order), dtype = self .numpy_dtype)
52145214 c_out = out
52155215 for idx in range (nbroadcast):
5216- self .lambda_double[ 0 ] .call(& c_out[idx* self .tot_out_size], & c_inp[idx* self .args_size])
5216+ deref( self .lambda_visitor) .call(& c_out[idx* self .tot_out_size], & c_inp[idx* self .args_size])
52175217
52185218
52195219IF HAVE_SYMENGINE_LLVM:
@@ -5222,31 +5222,31 @@ IF HAVE_SYMENGINE_LLVM:
52225222 self .opt_level = opt_level
52235223
52245224 cdef _init(self , symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse):
5225- self .lambda_double.resize( 1 )
5226- self .lambda_double[ 0 ] .init(args_, outs_, cse, self .opt_level)
5225+ self .lambda_visitor.reset(new symengine.LLVMDoubleVisitor() )
5226+ deref( self .lambda_visitor) .init(args_, outs_, cse, self .opt_level)
52275227
52285228 cdef _load(self , const string & s):
5229- self .lambda_double.resize( 1 )
5230- self .lambda_double[ 0 ] .loads(s)
5229+ self .lambda_visitor.reset(new symengine.LLVMDoubleVisitor() )
5230+ deref( self .lambda_visitor) .loads(s)
52315231
52325232 def __reduce__ (self ):
52335233 """
52345234 Interface for pickle. Note that the resulting object is platform dependent.
52355235 """
5236- cdef bytes s = self .lambda_double[ 0 ] .dumps()
5236+ cdef bytes s = deref( self .lambda_visitor) .dumps()
52375237 return llvm_loading_func, (self .args_size, self .tot_out_size, self .out_shapes, self .real, \
52385238 self .n_exprs, self .order, self .accum_out_sizes, self .numpy_dtype, s)
52395239
52405240 cpdef unsafe_real(self , double [::1 ] inp, double [::1 ] out, int inp_offset = 0 , int out_offset = 0 ):
5241- self .lambda_double[ 0 ] .call(& out[out_offset], & inp[inp_offset])
5241+ deref( self .lambda_visitor) .call(& out[out_offset], & inp[inp_offset])
52425242
52435243 cpdef unsafe_eval(self , inp, out, unsigned nbroadcast = 1 ):
52445244 cdef double [::1 ] c_inp, c_out
52455245 cdef unsigned idx
52465246 c_inp = np.ascontiguousarray(inp.ravel(order = self .order), dtype = self .numpy_dtype)
52475247 c_out = out
52485248 for idx in range (nbroadcast):
5249- self .lambda_double[ 0 ] .call(& c_out[idx* self .tot_out_size], & c_inp[idx* self .args_size])
5249+ deref( self .lambda_visitor) .call(& c_out[idx* self .tot_out_size], & c_inp[idx* self .args_size])
52505250
52515251 cpdef as_scipy_low_level_callable(self ):
52525252 from ctypes import c_double, c_void_p, c_int, cast, POINTER, CFUNCTYPE
@@ -5256,7 +5256,7 @@ IF HAVE_SYMENGINE_LLVM:
52565256 raise RuntimeError (" SciPy LowLevelCallable supports only functions with 1 output" )
52575257 addr1 = cast(< size_t> & _scipy_callback_llvm_real,
52585258 CFUNCTYPE(c_double, c_int, POINTER(c_double), c_void_p))
5259- addr2 = cast(< size_t> & self .lambda_double[ 0 ] , c_void_p)
5259+ addr2 = cast(< size_t> self .lambda_visitor.get() , c_void_p)
52605260 return create_low_level_callable(self , addr1, addr2)
52615261
52625262 cpdef as_ctypes(self ):
@@ -5273,71 +5273,71 @@ IF HAVE_SYMENGINE_LLVM:
52735273 raise RuntimeError (" Lambda function has to be real" )
52745274 addr1 = cast(< size_t> & _ctypes_callback_llvm_real,
52755275 CFUNCTYPE(c_void_p, POINTER(c_double), POINTER(c_double), c_void_p))
5276- addr2 = cast(< size_t> & self .lambda_double[ 0 ] , c_void_p)
5276+ addr2 = cast(< size_t> self .lambda_visitor.get() , c_void_p)
52775277 return addr1, addr2
52785278
52795279 cdef class LLVMFloat(_LLVMLambdify):
52805280 def __cinit__ (self , args , *exprs , cppbool real = True , order = ' C' , cppbool cse = False , cppbool _load = False , opt_level = 3 , dtype = None ):
52815281 self .opt_level = opt_level
52825282
52835283 cdef _init(self , symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse):
5284- self .lambda_double.resize( 1 )
5285- self .lambda_double[ 0 ] .init(args_, outs_, cse, self .opt_level)
5284+ self .lambda_visitor.reset(new symengine.LLVMFloatVisitor() )
5285+ deref( self .lambda_visitor) .init(args_, outs_, cse, self .opt_level)
52865286
52875287 cdef _load(self , const string & s):
5288- self .lambda_double.resize( 1 )
5289- self .lambda_double[ 0 ] .loads(s)
5288+ self .lambda_visitor.reset(new symengine.LLVMFloatVisitor() )
5289+ deref( self .lambda_visitor) .loads(s)
52905290
52915291 def __reduce__ (self ):
52925292 """
52935293 Interface for pickle. Note that the resulting object is platform dependent.
52945294 """
5295- cdef bytes s = self .lambda_double[ 0 ] .dumps()
5295+ cdef bytes s = deref( self .lambda_visitor) .dumps()
52965296 return llvm_float_loading_func, (self .args_size, self .tot_out_size, self .out_shapes, self .real, \
52975297 self .n_exprs, self .order, self .accum_out_sizes, self .numpy_dtype, s)
52985298
52995299 cpdef unsafe_real(self , float [::1 ] inp, float [::1 ] out, int inp_offset = 0 , int out_offset = 0 ):
5300- self .lambda_double[ 0 ] .call(& out[out_offset], & inp[inp_offset])
5300+ deref( self .lambda_visitor) .call(& out[out_offset], & inp[inp_offset])
53015301
53025302 cpdef unsafe_eval(self , inp, out, unsigned nbroadcast = 1 ):
53035303 cdef float [::1 ] c_inp, c_out
53045304 cdef unsigned idx
53055305 c_inp = np.ascontiguousarray(inp.ravel(order = self .order), dtype = self .numpy_dtype)
53065306 c_out = out
53075307 for idx in range (nbroadcast):
5308- self .lambda_double[ 0 ] .call(& c_out[idx* self .tot_out_size], & c_inp[idx* self .args_size])
5308+ deref( self .lambda_visitor) .call(& c_out[idx* self .tot_out_size], & c_inp[idx* self .args_size])
53095309
53105310 IF HAVE_SYMENGINE_LLVM_LONG_DOUBLE:
53115311 cdef class LLVMLongDouble(_LLVMLambdify):
53125312 def __cinit__ (self , args , *exprs , cppbool real = True , order = ' C' , cppbool cse = False , cppbool _load = False , opt_level = 3 , dtype = None ):
53135313 self .opt_level = opt_level
53145314
53155315 cdef _init(self , symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse):
5316- self .lambda_double.resize( 1 )
5317- self .lambda_double[ 0 ] .init(args_, outs_, cse, self .opt_level)
5316+ self .lambda_visitor.reset(new symengine.LLVMLongDoubleVisitor() )
5317+ deref( self .lambda_visitor) .init(args_, outs_, cse, self .opt_level)
53185318
53195319 cdef _load(self , const string & s):
5320- self .lambda_double.resize( 1 )
5321- self .lambda_double[ 0 ] .loads(s)
5320+ self .lambda_visitor.reset(new symengine.LLVMLongDoubleVisitor() )
5321+ deref( self .lambda_visitor) .loads(s)
53225322
53235323 def __reduce__ (self ):
53245324 """
53255325 Interface for pickle. Note that the resulting object is platform dependent.
53265326 """
5327- cdef bytes s = self .lambda_double[ 0 ] .dumps()
5327+ cdef bytes s = deref( self .lambda_visitor) .dumps()
53285328 return llvm_long_double_loading_func, (self .args_size, self .tot_out_size, self .out_shapes, self .real, \
53295329 self .n_exprs, self .order, self .accum_out_sizes, self .numpy_dtype, s)
53305330
53315331 cpdef unsafe_real(self , long double [::1 ] inp, long double [::1 ] out, int inp_offset = 0 , int out_offset = 0 ):
5332- self .lambda_double[ 0 ] .call(& out[out_offset], & inp[inp_offset])
5332+ deref( self .lambda_visitor) .call(& out[out_offset], & inp[inp_offset])
53335333
53345334 cpdef unsafe_eval(self , inp, out, unsigned nbroadcast = 1 ):
53355335 cdef long double [::1 ] c_inp, c_out
53365336 cdef unsigned idx
53375337 c_inp = np.ascontiguousarray(inp.ravel(order = self .order), dtype = self .numpy_dtype)
53385338 c_out = out
53395339 for idx in range (nbroadcast):
5340- self .lambda_double[ 0 ] .call(& c_out[idx* self .tot_out_size], & c_inp[idx* self .args_size])
5340+ deref( self .lambda_visitor) .call(& c_out[idx* self .tot_out_size], & c_inp[idx* self .args_size])
53415341
53425342 def llvm_loading_func (*args ):
53435343 return LLVMDouble(args, _load = True )
0 commit comments