Skip to content

Commit

Permalink
Use arithmetic operators from libgap-api.h. Refs #2.
Browse files Browse the repository at this point in the history
  • Loading branch information
embray committed Jan 14, 2021
1 parent d381021 commit fdc2f7b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
21 changes: 10 additions & 11 deletions gappy/gap_includes.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ cdef extern from "gap/libgap-api.h" nogil:
GAP_CallbackFunc markBagsCallback, GAP_CallbackFunc errorCallback,
int handleSignals)

# Arithmetic and operators
Obj GAP_SUM(Obj, Obj)
Obj GAP_DIFF(Obj, Obj)
Obj GAP_PROD(Obj, Obj)
Obj GAP_QUO(Obj, Obj)
Obj GAP_POW(Obj, Obj)
Obj GAP_MOD(Obj, Obj)
int GAP_EQ(Obj opL, Obj opR)
int GAP_LT(Obj opL, Obj opR)

# Evaluation
Obj GAP_EvalString(const char *) except *
Obj GAP_EvalStringNoExcept "GAP_EvalString"(const char *)
Expand Down Expand Up @@ -85,17 +95,6 @@ cdef extern from "gap/libgap-api.h" nogil:
Obj GAP_NewPrecord(Int)


cdef extern from "gap/ariths.h" nogil:
Obj SUM(Obj, Obj)
Obj DIFF(Obj, Obj)
Obj PROD(Obj, Obj)
Obj QUO(Obj, Obj)
Obj POW(Obj, Obj)
Obj MOD(Obj, Obj)
bint EQ(Obj opL, Obj opR)
bint LT(Obj opL, Obj opR)


cdef extern from "gap/bool.h" nogil:
cdef Obj GAP_True "True"
cdef Obj GAP_False "False"
Expand Down
16 changes: 8 additions & 8 deletions gappy/gapobj.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ cdef class GapObj:
sig_on()
try:
GAP_Enter()
return EQ(self.value, other.value)
return GAP_EQ(self.value, other.value)
finally:
GAP_Leave()
sig_off()
Expand All @@ -1020,7 +1020,7 @@ cdef class GapObj:
sig_on()
try:
GAP_Enter()
return LT(self.value, other.value)
return GAP_LT(self.value, other.value)
finally:
GAP_Leave()
sig_off()
Expand Down Expand Up @@ -1055,7 +1055,7 @@ cdef class GapObj:
try:
sig_GAP_Enter()
sig_on()
result = SUM(self.value, (<GapObj>right).value)
result = GAP_SUM(self.value, (<GapObj>right).value)
sig_off()
finally:
GAP_Leave()
Expand Down Expand Up @@ -1089,7 +1089,7 @@ cdef class GapObj:
try:
sig_GAP_Enter()
sig_on()
result = DIFF(self.value, (<GapObj>right).value)
result = GAP_DIFF(self.value, (<GapObj>right).value)
sig_off()
finally:
GAP_Leave()
Expand Down Expand Up @@ -1124,7 +1124,7 @@ cdef class GapObj:
try:
sig_GAP_Enter()
sig_on()
result = PROD(self.value, (<GapObj>right).value)
result = GAP_PROD(self.value, (<GapObj>right).value)
sig_off()
finally:
GAP_Leave()
Expand Down Expand Up @@ -1165,7 +1165,7 @@ cdef class GapObj:
try:
sig_GAP_Enter()
sig_on()
result = QUO(self.value, (<GapObj>right).value)
result = GAP_QUO(self.value, (<GapObj>right).value)
sig_off()
finally:
GAP_Leave()
Expand Down Expand Up @@ -1198,7 +1198,7 @@ cdef class GapObj:
try:
sig_GAP_Enter()
sig_on()
result = MOD(self.value, (<GapObj>right).value)
result = GAP_MOD(self.value, (<GapObj>right).value)
sig_off()
finally:
GAP_Leave()
Expand Down Expand Up @@ -1276,7 +1276,7 @@ cdef class GapObj:
try:
sig_GAP_Enter()
sig_on()
result = POW(self.value, (<GapObj>other).value)
result = GAP_POW(self.value, (<GapObj>other).value)
sig_off()
finally:
GAP_Leave()
Expand Down

0 comments on commit fdc2f7b

Please sign in to comment.