@@ -1211,7 +1211,7 @@ cdef class Basic(object):
1211
1211
return int (float (self ))
1212
1212
1213
1213
def __long__ (self ):
1214
- return long (float (self ))
1214
+ return int (float (self ))
1215
1215
1216
1216
def __complex__ (self ):
1217
1217
f = self .n(real = False )
@@ -1627,7 +1627,9 @@ class Equality(Relational):
1627
1627
def is_Equality (self ):
1628
1628
return True
1629
1629
1630
- func = __class__
1630
+ @property
1631
+ def func (self ):
1632
+ return self .__class__
1631
1633
1632
1634
1633
1635
Eq = Equality
@@ -1648,7 +1650,9 @@ class Unequality(Relational):
1648
1650
s = self .args_as_sage()
1649
1651
return sage.ne(* s)
1650
1652
1651
- func = __class__
1653
+ @property
1654
+ def func (self ):
1655
+ return self .__class__
1652
1656
1653
1657
1654
1658
Ne = Unequality
@@ -5157,27 +5161,27 @@ cdef class LambdaDouble(_Lambdify):
5157
5161
pass
5158
5162
5159
5163
cdef _init(self , symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse):
5160
- self .lambda_double.resize( 1 )
5161
- self .lambda_double[ 0 ] .init(args_, outs_, cse)
5164
+ self .lambda_visitor.reset(new symengine.LambdaRealDoubleVisitor() )
5165
+ deref( self .lambda_visitor) .init(args_, outs_, cse)
5162
5166
5163
5167
cpdef unsafe_real(self , double [::1 ] inp, double [::1 ] out, int inp_offset = 0 , int out_offset = 0 ):
5164
- self .lambda_double[ 0 ] .call(& out[out_offset], & inp[inp_offset])
5168
+ deref( self .lambda_visitor) .call(& out[out_offset], & inp[inp_offset])
5165
5169
5166
5170
cpdef unsafe_eval(self , inp, out, unsigned nbroadcast = 1 ):
5167
5171
cdef double [::1 ] c_inp, c_out
5168
5172
cdef unsigned idx
5169
5173
c_inp = np.ascontiguousarray(inp.ravel(order = self .order), dtype = self .numpy_dtype)
5170
5174
c_out = out
5171
5175
for idx in range (nbroadcast):
5172
- self .lambda_double[ 0 ] .call(& c_out[idx* self .tot_out_size], & c_inp[idx* self .args_size])
5176
+ deref( self .lambda_visitor) .call(& c_out[idx* self .tot_out_size], & c_inp[idx* self .args_size])
5173
5177
5174
5178
cpdef as_scipy_low_level_callable(self ):
5175
5179
from ctypes import c_double, c_void_p, c_int, cast, POINTER, CFUNCTYPE
5176
5180
if self .tot_out_size > 1 :
5177
5181
raise RuntimeError (" SciPy LowLevelCallable supports only functions with 1 output" )
5178
5182
addr1 = cast(< size_t> & _scipy_callback_lambda_real,
5179
5183
CFUNCTYPE(c_double, c_int, POINTER(c_double), c_void_p))
5180
- addr2 = cast(< size_t> & self .lambda_double[ 0 ] , c_void_p)
5184
+ addr2 = cast(< size_t> self .lambda_visitor.get() , c_void_p)
5181
5185
return create_low_level_callable(self , addr1, addr2)
5182
5186
5183
5187
cpdef as_ctypes(self ):
@@ -5192,7 +5196,7 @@ cdef class LambdaDouble(_Lambdify):
5192
5196
from ctypes import c_double, c_void_p, c_int, cast, POINTER, CFUNCTYPE
5193
5197
addr1 = cast(< size_t> & _ctypes_callback_lambda_real,
5194
5198
CFUNCTYPE(c_void_p, POINTER(c_double), POINTER(c_double), c_void_p))
5195
- addr2 = cast(< size_t> & self .lambda_double[ 0 ] , c_void_p)
5199
+ addr2 = cast(< size_t> self .lambda_visitor.get() , c_void_p)
5196
5200
return addr1, addr2
5197
5201
5198
5202
@@ -5202,19 +5206,19 @@ cdef class LambdaComplexDouble(_Lambdify):
5202
5206
pass
5203
5207
5204
5208
cdef _init(self , symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse):
5205
- self .lambda_double.resize( 1 )
5206
- self .lambda_double[ 0 ] .init(args_, outs_, cse)
5209
+ self .lambda_visitor.reset(new symengine.LambdaComplexDoubleVisitor() )
5210
+ deref( self .lambda_visitor) .init(args_, outs_, cse)
5207
5211
5208
5212
cpdef unsafe_complex(self , double complex [::1 ] inp, double complex [::1 ] out, int inp_offset = 0 , int out_offset = 0 ):
5209
- self .lambda_double[ 0 ] .call(& out[out_offset], & inp[inp_offset])
5213
+ deref( self .lambda_visitor) .call(& out[out_offset], & inp[inp_offset])
5210
5214
5211
5215
cpdef unsafe_eval(self , inp, out, unsigned nbroadcast = 1 ):
5212
5216
cdef double complex [::1 ] c_inp, c_out
5213
5217
cdef unsigned idx
5214
5218
c_inp = np.ascontiguousarray(inp.ravel(order = self .order), dtype = self .numpy_dtype)
5215
5219
c_out = out
5216
5220
for idx in range (nbroadcast):
5217
- self .lambda_double[ 0 ] .call(& c_out[idx* self .tot_out_size], & c_inp[idx* self .args_size])
5221
+ deref( self .lambda_visitor) .call(& c_out[idx* self .tot_out_size], & c_inp[idx* self .args_size])
5218
5222
5219
5223
5220
5224
IF HAVE_SYMENGINE_LLVM:
@@ -5223,31 +5227,31 @@ IF HAVE_SYMENGINE_LLVM:
5223
5227
self .opt_level = opt_level
5224
5228
5225
5229
cdef _init(self , symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse):
5226
- self .lambda_double.resize( 1 )
5227
- self .lambda_double[ 0 ] .init(args_, outs_, cse, self .opt_level)
5230
+ self .lambda_visitor.reset(new symengine.LLVMDoubleVisitor() )
5231
+ deref( self .lambda_visitor) .init(args_, outs_, cse, self .opt_level)
5228
5232
5229
5233
cdef _load(self , const string & s):
5230
- self .lambda_double.resize( 1 )
5231
- self .lambda_double[ 0 ] .loads(s)
5234
+ self .lambda_visitor.reset(new symengine.LLVMDoubleVisitor() )
5235
+ deref( self .lambda_visitor) .loads(s)
5232
5236
5233
5237
def __reduce__ (self ):
5234
5238
"""
5235
5239
Interface for pickle. Note that the resulting object is platform dependent.
5236
5240
"""
5237
- cdef bytes s = self .lambda_double[ 0 ] .dumps()
5241
+ cdef bytes s = deref( self .lambda_visitor) .dumps()
5238
5242
return llvm_loading_func, (self .args_size, self .tot_out_size, self .out_shapes, self .real, \
5239
5243
self .n_exprs, self .order, self .accum_out_sizes, self .numpy_dtype, s)
5240
5244
5241
5245
cpdef unsafe_real(self , double [::1 ] inp, double [::1 ] out, int inp_offset = 0 , int out_offset = 0 ):
5242
- self .lambda_double[ 0 ] .call(& out[out_offset], & inp[inp_offset])
5246
+ deref( self .lambda_visitor) .call(& out[out_offset], & inp[inp_offset])
5243
5247
5244
5248
cpdef unsafe_eval(self , inp, out, unsigned nbroadcast = 1 ):
5245
5249
cdef double [::1 ] c_inp, c_out
5246
5250
cdef unsigned idx
5247
5251
c_inp = np.ascontiguousarray(inp.ravel(order = self .order), dtype = self .numpy_dtype)
5248
5252
c_out = out
5249
5253
for idx in range (nbroadcast):
5250
- self .lambda_double[ 0 ] .call(& c_out[idx* self .tot_out_size], & c_inp[idx* self .args_size])
5254
+ deref( self .lambda_visitor) .call(& c_out[idx* self .tot_out_size], & c_inp[idx* self .args_size])
5251
5255
5252
5256
cpdef as_scipy_low_level_callable(self ):
5253
5257
from ctypes import c_double, c_void_p, c_int, cast, POINTER, CFUNCTYPE
@@ -5257,7 +5261,7 @@ IF HAVE_SYMENGINE_LLVM:
5257
5261
raise RuntimeError (" SciPy LowLevelCallable supports only functions with 1 output" )
5258
5262
addr1 = cast(< size_t> & _scipy_callback_llvm_real,
5259
5263
CFUNCTYPE(c_double, c_int, POINTER(c_double), c_void_p))
5260
- addr2 = cast(< size_t> & self .lambda_double[ 0 ] , c_void_p)
5264
+ addr2 = cast(< size_t> self .lambda_visitor.get() , c_void_p)
5261
5265
return create_low_level_callable(self , addr1, addr2)
5262
5266
5263
5267
cpdef as_ctypes(self ):
@@ -5274,71 +5278,71 @@ IF HAVE_SYMENGINE_LLVM:
5274
5278
raise RuntimeError (" Lambda function has to be real" )
5275
5279
addr1 = cast(< size_t> & _ctypes_callback_llvm_real,
5276
5280
CFUNCTYPE(c_void_p, POINTER(c_double), POINTER(c_double), c_void_p))
5277
- addr2 = cast(< size_t> & self .lambda_double[ 0 ] , c_void_p)
5281
+ addr2 = cast(< size_t> self .lambda_visitor.get() , c_void_p)
5278
5282
return addr1, addr2
5279
5283
5280
5284
cdef class LLVMFloat(_LLVMLambdify):
5281
5285
def __cinit__ (self , args , *exprs , cppbool real = True , order = ' C' , cppbool cse = False , cppbool _load = False , opt_level = 3 , dtype = None ):
5282
5286
self .opt_level = opt_level
5283
5287
5284
5288
cdef _init(self , symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse):
5285
- self .lambda_double.resize( 1 )
5286
- self .lambda_double[ 0 ] .init(args_, outs_, cse, self .opt_level)
5289
+ self .lambda_visitor.reset(new symengine.LLVMFloatVisitor() )
5290
+ deref( self .lambda_visitor) .init(args_, outs_, cse, self .opt_level)
5287
5291
5288
5292
cdef _load(self , const string & s):
5289
- self .lambda_double.resize( 1 )
5290
- self .lambda_double[ 0 ] .loads(s)
5293
+ self .lambda_visitor.reset(new symengine.LLVMFloatVisitor() )
5294
+ deref( self .lambda_visitor) .loads(s)
5291
5295
5292
5296
def __reduce__ (self ):
5293
5297
"""
5294
5298
Interface for pickle. Note that the resulting object is platform dependent.
5295
5299
"""
5296
- cdef bytes s = self .lambda_double[ 0 ] .dumps()
5300
+ cdef bytes s = deref( self .lambda_visitor) .dumps()
5297
5301
return llvm_float_loading_func, (self .args_size, self .tot_out_size, self .out_shapes, self .real, \
5298
5302
self .n_exprs, self .order, self .accum_out_sizes, self .numpy_dtype, s)
5299
5303
5300
5304
cpdef unsafe_real(self , float [::1 ] inp, float [::1 ] out, int inp_offset = 0 , int out_offset = 0 ):
5301
- self .lambda_double[ 0 ] .call(& out[out_offset], & inp[inp_offset])
5305
+ deref( self .lambda_visitor) .call(& out[out_offset], & inp[inp_offset])
5302
5306
5303
5307
cpdef unsafe_eval(self , inp, out, unsigned nbroadcast = 1 ):
5304
5308
cdef float [::1 ] c_inp, c_out
5305
5309
cdef unsigned idx
5306
5310
c_inp = np.ascontiguousarray(inp.ravel(order = self .order), dtype = self .numpy_dtype)
5307
5311
c_out = out
5308
5312
for idx in range (nbroadcast):
5309
- self .lambda_double[ 0 ] .call(& c_out[idx* self .tot_out_size], & c_inp[idx* self .args_size])
5313
+ deref( self .lambda_visitor) .call(& c_out[idx* self .tot_out_size], & c_inp[idx* self .args_size])
5310
5314
5311
5315
IF HAVE_SYMENGINE_LLVM_LONG_DOUBLE:
5312
5316
cdef class LLVMLongDouble(_LLVMLambdify):
5313
5317
def __cinit__ (self , args , *exprs , cppbool real = True , order = ' C' , cppbool cse = False , cppbool _load = False , opt_level = 3 , dtype = None ):
5314
5318
self .opt_level = opt_level
5315
5319
5316
5320
cdef _init(self , symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse):
5317
- self .lambda_double.resize( 1 )
5318
- self .lambda_double[ 0 ] .init(args_, outs_, cse, self .opt_level)
5321
+ self .lambda_visitor.reset(new symengine.LLVMLongDoubleVisitor() )
5322
+ deref( self .lambda_visitor) .init(args_, outs_, cse, self .opt_level)
5319
5323
5320
5324
cdef _load(self , const string & s):
5321
- self .lambda_double.resize( 1 )
5322
- self .lambda_double[ 0 ] .loads(s)
5325
+ self .lambda_visitor.reset(new symengine.LLVMLongDoubleVisitor() )
5326
+ deref( self .lambda_visitor) .loads(s)
5323
5327
5324
5328
def __reduce__ (self ):
5325
5329
"""
5326
5330
Interface for pickle. Note that the resulting object is platform dependent.
5327
5331
"""
5328
- cdef bytes s = self .lambda_double[ 0 ] .dumps()
5332
+ cdef bytes s = deref( self .lambda_visitor) .dumps()
5329
5333
return llvm_long_double_loading_func, (self .args_size, self .tot_out_size, self .out_shapes, self .real, \
5330
5334
self .n_exprs, self .order, self .accum_out_sizes, self .numpy_dtype, s)
5331
5335
5332
5336
cpdef unsafe_real(self , long double [::1 ] inp, long double [::1 ] out, int inp_offset = 0 , int out_offset = 0 ):
5333
- self .lambda_double[ 0 ] .call(& out[out_offset], & inp[inp_offset])
5337
+ deref( self .lambda_visitor) .call(& out[out_offset], & inp[inp_offset])
5334
5338
5335
5339
cpdef unsafe_eval(self , inp, out, unsigned nbroadcast = 1 ):
5336
5340
cdef long double [::1 ] c_inp, c_out
5337
5341
cdef unsigned idx
5338
5342
c_inp = np.ascontiguousarray(inp.ravel(order = self .order), dtype = self .numpy_dtype)
5339
5343
c_out = out
5340
5344
for idx in range (nbroadcast):
5341
- self .lambda_double[ 0 ] .call(& c_out[idx* self .tot_out_size], & c_inp[idx* self .args_size])
5345
+ deref( self .lambda_visitor) .call(& c_out[idx* self .tot_out_size], & c_inp[idx* self .args_size])
5342
5346
5343
5347
def llvm_loading_func (*args ):
5344
5348
return LLVMDouble(args, _load = True )
0 commit comments