@@ -5156,27 +5156,27 @@ cdef class LambdaDouble(_Lambdify):
5156
5156
pass
5157
5157
5158
5158
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.LLVMDoubleVisitor() )
5160
+ deref( self .lambda_visitor) .init(args_, outs_, cse)
5161
5161
5162
5162
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])
5164
5164
5165
5165
cpdef unsafe_eval(self , inp, out, unsigned nbroadcast = 1 ):
5166
5166
cdef double [::1 ] c_inp, c_out
5167
5167
cdef unsigned idx
5168
5168
c_inp = np.ascontiguousarray(inp.ravel(order = self .order), dtype = self .numpy_dtype)
5169
5169
c_out = out
5170
5170
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])
5172
5172
5173
5173
cpdef as_scipy_low_level_callable(self ):
5174
5174
from ctypes import c_double, c_void_p, c_int, cast, POINTER, CFUNCTYPE
5175
5175
if self .tot_out_size > 1 :
5176
5176
raise RuntimeError (" SciPy LowLevelCallable supports only functions with 1 output" )
5177
5177
addr1 = cast(< size_t> & _scipy_callback_lambda_real,
5178
5178
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)
5180
5180
return create_low_level_callable(self , addr1, addr2)
5181
5181
5182
5182
cpdef as_ctypes(self ):
@@ -5191,7 +5191,7 @@ cdef class LambdaDouble(_Lambdify):
5191
5191
from ctypes import c_double, c_void_p, c_int, cast, POINTER, CFUNCTYPE
5192
5192
addr1 = cast(< size_t> & _ctypes_callback_lambda_real,
5193
5193
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)
5195
5195
return addr1, addr2
5196
5196
5197
5197
@@ -5201,19 +5201,19 @@ cdef class LambdaComplexDouble(_Lambdify):
5201
5201
pass
5202
5202
5203
5203
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)
5206
5206
5207
5207
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])
5209
5209
5210
5210
cpdef unsafe_eval(self , inp, out, unsigned nbroadcast = 1 ):
5211
5211
cdef double complex [::1 ] c_inp, c_out
5212
5212
cdef unsigned idx
5213
5213
c_inp = np.ascontiguousarray(inp.ravel(order = self .order), dtype = self .numpy_dtype)
5214
5214
c_out = out
5215
5215
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])
5217
5217
5218
5218
5219
5219
IF HAVE_SYMENGINE_LLVM:
@@ -5222,31 +5222,31 @@ IF HAVE_SYMENGINE_LLVM:
5222
5222
self .opt_level = opt_level
5223
5223
5224
5224
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)
5227
5227
5228
5228
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)
5231
5231
5232
5232
def __reduce__ (self ):
5233
5233
"""
5234
5234
Interface for pickle. Note that the resulting object is platform dependent.
5235
5235
"""
5236
- cdef bytes s = self .lambda_double[ 0 ] .dumps()
5236
+ cdef bytes s = deref( self .lambda_visitor) .dumps()
5237
5237
return llvm_loading_func, (self .args_size, self .tot_out_size, self .out_shapes, self .real, \
5238
5238
self .n_exprs, self .order, self .accum_out_sizes, self .numpy_dtype, s)
5239
5239
5240
5240
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])
5242
5242
5243
5243
cpdef unsafe_eval(self , inp, out, unsigned nbroadcast = 1 ):
5244
5244
cdef double [::1 ] c_inp, c_out
5245
5245
cdef unsigned idx
5246
5246
c_inp = np.ascontiguousarray(inp.ravel(order = self .order), dtype = self .numpy_dtype)
5247
5247
c_out = out
5248
5248
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])
5250
5250
5251
5251
cpdef as_scipy_low_level_callable(self ):
5252
5252
from ctypes import c_double, c_void_p, c_int, cast, POINTER, CFUNCTYPE
@@ -5256,7 +5256,7 @@ IF HAVE_SYMENGINE_LLVM:
5256
5256
raise RuntimeError (" SciPy LowLevelCallable supports only functions with 1 output" )
5257
5257
addr1 = cast(< size_t> & _scipy_callback_llvm_real,
5258
5258
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)
5260
5260
return create_low_level_callable(self , addr1, addr2)
5261
5261
5262
5262
cpdef as_ctypes(self ):
@@ -5273,71 +5273,71 @@ IF HAVE_SYMENGINE_LLVM:
5273
5273
raise RuntimeError (" Lambda function has to be real" )
5274
5274
addr1 = cast(< size_t> & _ctypes_callback_llvm_real,
5275
5275
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)
5277
5277
return addr1, addr2
5278
5278
5279
5279
cdef class LLVMFloat(_LLVMLambdify):
5280
5280
def __cinit__ (self , args , *exprs , cppbool real = True , order = ' C' , cppbool cse = False , cppbool _load = False , opt_level = 3 , dtype = None ):
5281
5281
self .opt_level = opt_level
5282
5282
5283
5283
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)
5286
5286
5287
5287
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)
5290
5290
5291
5291
def __reduce__ (self ):
5292
5292
"""
5293
5293
Interface for pickle. Note that the resulting object is platform dependent.
5294
5294
"""
5295
- cdef bytes s = self .lambda_double[ 0 ] .dumps()
5295
+ cdef bytes s = deref( self .lambda_visitor) .dumps()
5296
5296
return llvm_float_loading_func, (self .args_size, self .tot_out_size, self .out_shapes, self .real, \
5297
5297
self .n_exprs, self .order, self .accum_out_sizes, self .numpy_dtype, s)
5298
5298
5299
5299
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])
5301
5301
5302
5302
cpdef unsafe_eval(self , inp, out, unsigned nbroadcast = 1 ):
5303
5303
cdef float [::1 ] c_inp, c_out
5304
5304
cdef unsigned idx
5305
5305
c_inp = np.ascontiguousarray(inp.ravel(order = self .order), dtype = self .numpy_dtype)
5306
5306
c_out = out
5307
5307
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])
5309
5309
5310
5310
IF HAVE_SYMENGINE_LLVM_LONG_DOUBLE:
5311
5311
cdef class LLVMLongDouble(_LLVMLambdify):
5312
5312
def __cinit__ (self , args , *exprs , cppbool real = True , order = ' C' , cppbool cse = False , cppbool _load = False , opt_level = 3 , dtype = None ):
5313
5313
self .opt_level = opt_level
5314
5314
5315
5315
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)
5318
5318
5319
5319
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)
5322
5322
5323
5323
def __reduce__ (self ):
5324
5324
"""
5325
5325
Interface for pickle. Note that the resulting object is platform dependent.
5326
5326
"""
5327
- cdef bytes s = self .lambda_double[ 0 ] .dumps()
5327
+ cdef bytes s = deref( self .lambda_visitor) .dumps()
5328
5328
return llvm_long_double_loading_func, (self .args_size, self .tot_out_size, self .out_shapes, self .real, \
5329
5329
self .n_exprs, self .order, self .accum_out_sizes, self .numpy_dtype, s)
5330
5330
5331
5331
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])
5333
5333
5334
5334
cpdef unsafe_eval(self , inp, out, unsigned nbroadcast = 1 ):
5335
5335
cdef long double [::1 ] c_inp, c_out
5336
5336
cdef unsigned idx
5337
5337
c_inp = np.ascontiguousarray(inp.ravel(order = self .order), dtype = self .numpy_dtype)
5338
5338
c_out = out
5339
5339
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])
5341
5341
5342
5342
def llvm_loading_func (*args ):
5343
5343
return LLVMDouble(args, _load = True )
0 commit comments