@@ -3,7 +3,7 @@ cimport symengine
3
3
from symengine cimport (RCP, pair, map_basic_basic, umap_int_basic,
4
4
umap_int_basic_iterator, umap_basic_num, umap_basic_num_iterator,
5
5
rcp_const_basic, std_pair_short_rcp_const_basic,
6
- rcp_const_seriescoeffinterface, CRCPBasic)
6
+ rcp_const_seriescoeffinterface, CRCPBasic, tribool, is_indeterminate, is_true, is_false )
7
7
from libcpp cimport bool as cppbool
8
8
from libcpp.string cimport string
9
9
from libcpp.vector cimport vector
@@ -3696,39 +3696,39 @@ cdef class DenseMatrixBase(MatrixBase):
3696
3696
3697
3697
@property
3698
3698
def is_zero_matrix (self ):
3699
- return tribool (deref(symengine.static_cast_DenseMatrix(self .thisptr)).is_zero())
3699
+ return tribool_py (deref(symengine.static_cast_DenseMatrix(self .thisptr)).is_zero())
3700
3700
3701
3701
@property
3702
3702
def is_real_matrix (self ):
3703
- return tribool (deref(symengine.static_cast_DenseMatrix(self .thisptr)).is_real())
3703
+ return tribool_py (deref(symengine.static_cast_DenseMatrix(self .thisptr)).is_real())
3704
3704
3705
3705
@property
3706
3706
def is_diagonal (self ):
3707
- return tribool (deref(symengine.static_cast_DenseMatrix(self .thisptr)).is_diagonal())
3707
+ return tribool_py (deref(symengine.static_cast_DenseMatrix(self .thisptr)).is_diagonal())
3708
3708
3709
3709
@property
3710
3710
def is_symmetric (self ):
3711
- return tribool (deref(symengine.static_cast_DenseMatrix(self .thisptr)).is_symmetric())
3711
+ return tribool_py (deref(symengine.static_cast_DenseMatrix(self .thisptr)).is_symmetric())
3712
3712
3713
3713
@property
3714
3714
def is_hermitian (self ):
3715
- return tribool (deref(symengine.static_cast_DenseMatrix(self .thisptr)).is_hermitian())
3715
+ return tribool_py (deref(symengine.static_cast_DenseMatrix(self .thisptr)).is_hermitian())
3716
3716
3717
3717
@property
3718
3718
def is_weakly_diagonally_dominant (self ):
3719
- return tribool (deref(symengine.static_cast_DenseMatrix(self .thisptr)).is_weakly_diagonally_dominant())
3719
+ return tribool_py (deref(symengine.static_cast_DenseMatrix(self .thisptr)).is_weakly_diagonally_dominant())
3720
3720
3721
3721
@property
3722
3722
def is_strongly_diagonally_dominant (self ):
3723
- return tribool (deref(symengine.static_cast_DenseMatrix(self .thisptr)).is_strictly_diagonally_dominant())
3723
+ return tribool_py (deref(symengine.static_cast_DenseMatrix(self .thisptr)).is_strictly_diagonally_dominant())
3724
3724
3725
3725
@property
3726
3726
def is_positive_definite (self ):
3727
- return tribool (deref(symengine.static_cast_DenseMatrix(self .thisptr)).is_positive_definite())
3727
+ return tribool_py (deref(symengine.static_cast_DenseMatrix(self .thisptr)).is_positive_definite())
3728
3728
3729
3729
@property
3730
3730
def is_negative_definite (self ):
3731
- return tribool (deref(symengine.static_cast_DenseMatrix(self .thisptr)).is_negative_definite())
3731
+ return tribool_py (deref(symengine.static_cast_DenseMatrix(self .thisptr)).is_negative_definite())
3732
3732
3733
3733
@property
3734
3734
def T (self ):
@@ -5347,47 +5347,51 @@ def contains(expr, sset):
5347
5347
return c2py(< rcp_const_basic> (symengine.contains(expr_.thisptr, s)))
5348
5348
5349
5349
5350
- def tribool ( value ):
5351
- if value == - 1 :
5350
+ cdef tribool_py(tribool value):
5351
+ if is_indeterminate( value) :
5352
5352
return None
5353
+ elif is_true(value):
5354
+ return True
5355
+ elif is_false(value):
5356
+ return False
5353
5357
else :
5354
- return bool ( value)
5358
+ raise RuntimeError ( " Internal error in symengine.py, tribool got a fourth value. " )
5355
5359
5356
5360
5357
5361
def is_zero (expr ):
5358
5362
cdef Basic expr_ = sympify(expr)
5359
- cdef int tbool = symengine.is_zero(deref(expr_.thisptr))
5360
- return tribool (tbool)
5363
+ cdef tribool tbool = symengine.is_zero(deref(expr_.thisptr))
5364
+ return tribool_py (tbool)
5361
5365
5362
5366
5363
5367
def is_positive (expr ):
5364
5368
cdef Basic expr_ = sympify(expr)
5365
- cdef int tbool = symengine.is_positive(deref(expr_.thisptr))
5366
- return tribool (tbool)
5369
+ cdef tribool tbool = symengine.is_positive(deref(expr_.thisptr))
5370
+ return tribool_py (tbool)
5367
5371
5368
5372
5369
5373
def is_negative (expr ):
5370
5374
cdef Basic expr_ = sympify(expr)
5371
- cdef int tbool = symengine.is_negative(deref(expr_.thisptr))
5372
- return tribool (tbool)
5375
+ cdef tribool tbool = symengine.is_negative(deref(expr_.thisptr))
5376
+ return tribool_py (tbool)
5373
5377
5374
5378
5375
5379
def is_nonpositive (expr ):
5376
5380
cdef Basic expr_ = sympify(expr)
5377
- cdef int tbool = symengine.is_nonpositive(deref(expr_.thisptr))
5378
- return tribool (tbool)
5381
+ cdef tribool tbool = symengine.is_nonpositive(deref(expr_.thisptr))
5382
+ return tribool_py (tbool)
5379
5383
5380
5384
5381
5385
def is_nonnegative (expr ):
5382
5386
cdef Basic expr_ = sympify(expr)
5383
- cdef int tbool = symengine.is_nonnegative(deref(expr_.thisptr))
5384
- return tribool (tbool)
5387
+ cdef tribool tbool = symengine.is_nonnegative(deref(expr_.thisptr))
5388
+ return tribool_py (tbool)
5385
5389
5386
5390
5387
5391
def is_real (expr ):
5388
5392
cdef Basic expr_ = sympify(expr)
5389
- cdef int tbool = symengine.is_real(deref(expr_.thisptr))
5390
- return tribool (tbool)
5393
+ cdef tribool tbool = symengine.is_real(deref(expr_.thisptr))
5394
+ return tribool_py (tbool)
5391
5395
5392
5396
5393
5397
def set_union (*args ):
0 commit comments