Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Drop return type from single-underscore arithmetic methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jdemeyer committed Jun 1, 2016
1 parent 769ff19 commit 56776e2
Show file tree
Hide file tree
Showing 95 changed files with 472 additions and 495 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement):

################################
## Arithmetic
cpdef ModuleElement _neg_(self):
cpdef _neg_(self):
"""
TEST::
Expand All @@ -484,7 +484,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement):
"""
return FreeAlgebraElement_letterplace(self._parent,-self._poly,check=False)
cpdef ModuleElement _add_(self, ModuleElement other):
cpdef _add_(self, ModuleElement other):
"""
Addition, under the side condition that either one summand
is zero, or both summands have the same degree.
Expand Down Expand Up @@ -517,7 +517,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement):
right._poly = A._current_ring(right._poly)
return FreeAlgebraElement_letterplace(self._parent,self._poly+right._poly,check=False)

cpdef ModuleElement _sub_(self, ModuleElement other):
cpdef _sub_(self, ModuleElement other):
"""
Difference, under the side condition that either one summand
is zero or both have the same weighted degree.
Expand Down Expand Up @@ -556,7 +556,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement):
right._poly = A._current_ring(right._poly)
return FreeAlgebraElement_letterplace(self._parent,self._poly-right._poly,check=False)

cpdef ModuleElement _lmul_(self, RingElement right):
cpdef _lmul_(self, RingElement right):
"""
Multiplication from the right with an element of the base ring.
Expand All @@ -570,7 +570,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement):
"""
return FreeAlgebraElement_letterplace(self._parent,self._poly._lmul_(right),check=False)

cpdef ModuleElement _rmul_(self, RingElement left):
cpdef _rmul_(self, RingElement left):
"""
Multiplication from the left with an element of the base ring.
Expand All @@ -584,7 +584,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement):
"""
return FreeAlgebraElement_letterplace(self._parent,self._poly._rmul_(left),check=False)

cpdef RingElement _mul_(self, RingElement other):
cpdef _mul_(self, RingElement other):
"""
Product of two free algebra elements in letterplace implementation.
Expand Down
24 changes: 12 additions & 12 deletions src/sage/algebras/quatalg/quaternion_algebra_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ cdef class QuaternionAlgebraElement_abstract(AlgebraElement):
"""
return ~self.reduced_norm() * self.conjugate()

cpdef ModuleElement _rmul_(self, RingElement left):
cpdef _rmul_(self, RingElement left):
"""
Return left*self, where left is in the base ring.
Expand All @@ -501,7 +501,7 @@ cdef class QuaternionAlgebraElement_abstract(AlgebraElement):
"""
return self.__class__(self._parent, (left*self[0], left*self[1], left*self[2], left*self[3]), check=False)

cpdef ModuleElement _lmul_(self, RingElement right):
cpdef _lmul_(self, RingElement right):
"""
Return self*right, where right is in the base ring.
Expand All @@ -515,7 +515,7 @@ cdef class QuaternionAlgebraElement_abstract(AlgebraElement):
"""
return self.__class__(self._parent, (self[0]*right, self[1]*right, self[2]*right, self[3]*right), check=False)

cpdef RingElement _div_(self, RingElement right):
cpdef _div_(self, RingElement right):
"""
Return quotient of self by right.
Expand Down Expand Up @@ -724,7 +724,7 @@ cdef class QuaternionAlgebraElement_generic(QuaternionAlgebraElement_abstract):
return (unpickle_QuaternionAlgebraElement_generic_v0,
(self._parent, (self.x, self.y, self.z, self.w)))

cpdef ModuleElement _add_(self, ModuleElement _right):
cpdef _add_(self, ModuleElement _right):
"""
Return the sum of self and _right.
Expand All @@ -740,7 +740,7 @@ cdef class QuaternionAlgebraElement_generic(QuaternionAlgebraElement_abstract):
# TODO -- make this, etc. use __new__
return QuaternionAlgebraElement_generic(self._parent, (self.x + right.x, self.y + right.y, self.z + right.z, self.w + right.w), check=False)

cpdef ModuleElement _sub_(self, ModuleElement _right):
cpdef _sub_(self, ModuleElement _right):
"""
Return the difference of self and _right.
Expand All @@ -755,7 +755,7 @@ cdef class QuaternionAlgebraElement_generic(QuaternionAlgebraElement_abstract):
cdef QuaternionAlgebraElement_generic right = _right
return QuaternionAlgebraElement_generic(self._parent, (self.x - right.x, self.y - right.y, self.z - right.z, self.w - right.w), check=False)

cpdef RingElement _mul_(self, RingElement _right):
cpdef _mul_(self, RingElement _right):
"""
Return the product of self and _right.
Expand Down Expand Up @@ -1076,7 +1076,7 @@ cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abst
return (unpickle_QuaternionAlgebraElement_rational_field_v0,
(self._parent, (self[0], self[1], self[2], self[3])))

cpdef ModuleElement _add_(self, ModuleElement _right):
cpdef _add_(self, ModuleElement _right):
"""
EXAMPLES::
Expand Down Expand Up @@ -1132,7 +1132,7 @@ cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abst
mpz_set(result.b, self.b)
return result

cpdef ModuleElement _sub_(self, ModuleElement _right):
cpdef _sub_(self, ModuleElement _right):
"""
EXAMPLES::
Expand Down Expand Up @@ -1173,7 +1173,7 @@ cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abst
mpz_set(result.b, self.b)
return result

cpdef RingElement _mul_(self, RingElement _right):
cpdef _mul_(self, RingElement _right):
"""
EXAMPLES::
Expand Down Expand Up @@ -1739,7 +1739,7 @@ cdef class QuaternionAlgebraElement_number_field(QuaternionAlgebraElement_abstra
return (unpickle_QuaternionAlgebraElement_number_field_v0,
(self._parent, (self[0], self[1], self[2], self[3])))

cpdef ModuleElement _add_(self, ModuleElement _right):
cpdef _add_(self, ModuleElement _right):
"""
Add self and _right:
Expand Down Expand Up @@ -1810,7 +1810,7 @@ cdef class QuaternionAlgebraElement_number_field(QuaternionAlgebraElement_abstra

return result

cpdef ModuleElement _sub_(self, ModuleElement _right):
cpdef _sub_(self, ModuleElement _right):
"""
Subtract _right from self.
Expand Down Expand Up @@ -1860,7 +1860,7 @@ cdef class QuaternionAlgebraElement_number_field(QuaternionAlgebraElement_abstra

return result

cpdef RingElement _mul_(self, RingElement _right):
cpdef _mul_(self, RingElement _right):
"""
Multiply self and _right.
Expand Down
2 changes: 1 addition & 1 deletion src/sage/geometry/toric_lattice_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ cdef class ToricLatticeElement(Vector_integer_dense):
# We need to override this function to prohibit default behaviour.
# It seems to be called when right is in the same lattice as self, which
# is wrong from our point of view.
cpdef Element _dot_product_(self, Vector right):
cpdef _dot_product_(self, Vector right):
"""
Raise a ``TypeError`` exception.
Expand Down
5 changes: 0 additions & 5 deletions src/sage/groups/libgap_wrapper.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,3 @@ from sage.libs.gap.element cimport GapElement
cdef class ElementLibGAP(MultiplicativeGroupElement):
cdef GapElement _libgap
cpdef GapElement gap(self)
cpdef MonoidElement _mul_(left, MonoidElement right)
cpdef MultiplicativeGroupElement _div_(self, MultiplicativeGroupElement right)



4 changes: 2 additions & 2 deletions src/sage/groups/libgap_wrapper.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ cdef class ElementLibGAP(MultiplicativeGroupElement):
from sage.misc.latex import latex
return latex(self._repr_())

cpdef MonoidElement _mul_(left, MonoidElement right):
cpdef _mul_(left, MonoidElement right):
"""
Multiplication of group elements
Expand Down Expand Up @@ -585,7 +585,7 @@ cdef class ElementLibGAP(MultiplicativeGroupElement):
return cmp((<ElementLibGAP>left)._libgap,
(<ElementLibGAP>right)._libgap)

cpdef MultiplicativeGroupElement _div_(left, MultiplicativeGroupElement right):
cpdef _div_(left, MultiplicativeGroupElement right):
"""
Division of group elements.
Expand Down
2 changes: 1 addition & 1 deletion src/sage/groups/matrix_gps/group_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement):
"""
return self._matrix

cpdef MonoidElement _mul_(self, MonoidElement other):
cpdef _mul_(self, MonoidElement other):
"""
Return the product of ``self`` and`` other``, which must
have identical parents.
Expand Down
2 changes: 1 addition & 1 deletion src/sage/groups/perm_gps/permgroup_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement):
elif is_Matrix(left):
return left.with_permuted_rows(self)

cpdef MonoidElement _mul_(left, MonoidElement _right):
cpdef _mul_(left, MonoidElement _right):
"""
EXAMPLES::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ cdef class SemimonomialTransformation(MultiplicativeGroupElement):
"""
return hash(self.v) + hash(self.perm) + hash(self.get_autom())

cpdef MonoidElement _mul_(left, MonoidElement _right):
cpdef _mul_(left, MonoidElement _right):
r"""
Multiplication of elements.
Expand Down
4 changes: 0 additions & 4 deletions src/sage/libs/gap/element.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ cdef class GapElement(RingElement):

cdef _initialize(self, parent, libGAP_Obj obj)
cpdef _type_number(self)
cpdef ModuleElement _add_(self, ModuleElement right)
cpdef ModuleElement _sub_(self, ModuleElement right)
cpdef RingElement _mul_(self, RingElement right)
cpdef RingElement _div_(self, RingElement right)
cpdef is_bool(self)


Expand Down
8 changes: 4 additions & 4 deletions src/sage/libs/gap/element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ cdef class GapElement(RingElement):
libgap_exit()
return result

cpdef ModuleElement _add_(self, ModuleElement right):
cpdef _add_(self, ModuleElement right):
r"""
Add two GapElement objects.
Expand Down Expand Up @@ -723,7 +723,7 @@ cdef class GapElement(RingElement):
return make_any_gap_element(self.parent(), result)


cpdef ModuleElement _sub_(self, ModuleElement right):
cpdef _sub_(self, ModuleElement right):
r"""
Subtract two GapElement objects.
Expand Down Expand Up @@ -756,7 +756,7 @@ cdef class GapElement(RingElement):
return make_any_gap_element(self.parent(), result)


cpdef RingElement _mul_(self, RingElement right):
cpdef _mul_(self, RingElement right):
r"""
Multiply two GapElement objects.
Expand Down Expand Up @@ -789,7 +789,7 @@ cdef class GapElement(RingElement):
return make_any_gap_element(self.parent(), result)


cpdef RingElement _div_(self, RingElement right):
cpdef _div_(self, RingElement right):
r"""
Divide two GapElement objects.
Expand Down
8 changes: 4 additions & 4 deletions src/sage/libs/pari/gen.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -240,19 +240,19 @@ cdef class gen(gen_auto):
s = repr(self)
return (objtogen, (s,))

cpdef ModuleElement _add_(self, ModuleElement right):
cpdef _add_(self, ModuleElement right):
sig_on()
return P.new_gen(gadd(self.g, (<gen>right).g))

cpdef ModuleElement _sub_(self, ModuleElement right):
cpdef _sub_(self, ModuleElement right):
sig_on()
return P.new_gen(gsub(self.g, (<gen> right).g))

cpdef RingElement _mul_(self, RingElement right):
cpdef _mul_(self, RingElement right):
sig_on()
return P.new_gen(gmul(self.g, (<gen>right).g))

cpdef RingElement _div_(self, RingElement right):
cpdef _div_(self, RingElement right):
sig_on()
return P.new_gen(gdiv(self.g, (<gen>right).g))

Expand Down
12 changes: 6 additions & 6 deletions src/sage/matrix/matrix0.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4592,7 +4592,7 @@ cdef class Matrix(sage.structure.element.Matrix):
###################################################
# Arithmetic
###################################################
cdef Vector _vector_times_matrix_(self, Vector v):
cdef _vector_times_matrix_(self, Vector v):
"""
Returns the vector times matrix product.
Expand Down Expand Up @@ -4650,7 +4650,7 @@ cdef class Matrix(sage.structure.element.Matrix):
return sum([v[i] * self.row(i, from_list=True)
for i in xrange(self._nrows)], M(0))

cdef Vector _matrix_times_vector_(self, Vector v):
cdef _matrix_times_vector_(self, Vector v):
"""
EXAMPLES::
Expand Down Expand Up @@ -4760,7 +4760,7 @@ cdef class Matrix(sage.structure.element.Matrix):
MS = self.matrix_space(n, m)
return MS(X).transpose()

cpdef ModuleElement _add_(self, ModuleElement _right):
cpdef _add_(self, ModuleElement _right):
"""
Add two matrices with the same parent.
Expand All @@ -4783,7 +4783,7 @@ cdef class Matrix(sage.structure.element.Matrix):
A.set_unsafe(i,j,self.get_unsafe(i,j)._add_(right.get_unsafe(i,j)))
return A

cpdef ModuleElement _sub_(self, ModuleElement _right):
cpdef _sub_(self, ModuleElement _right):
"""
Subtract two matrices with the same parent.
Expand Down Expand Up @@ -4849,7 +4849,7 @@ cdef class Matrix(sage.structure.element.Matrix):
return self.change_ring(self._base_ring.quotient_ring(p))


cpdef ModuleElement _rmul_(self, RingElement left):
cpdef _rmul_(self, RingElement left):
"""
EXAMPLES::
Expand Down Expand Up @@ -4886,7 +4886,7 @@ cdef class Matrix(sage.structure.element.Matrix):
ans.set_unsafe(r, c, x * self.get_unsafe(r, c))
return ans

cpdef ModuleElement _lmul_(self, RingElement right):
cpdef _lmul_(self, RingElement right):
"""
EXAMPLES:
Expand Down
8 changes: 4 additions & 4 deletions src/sage/matrix/matrix_cyclo_dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ cdef class Matrix_cyclo_dense(matrix_dense.Matrix_dense):
# * _dict -- sparse dictionary of underlying elements (need not be a copy)
########################################################################

cpdef ModuleElement _add_(self, ModuleElement right):
cpdef _add_(self, ModuleElement right):
"""
Return the sum of two dense cyclotomic matrices.
Expand Down Expand Up @@ -497,7 +497,7 @@ cdef class Matrix_cyclo_dense(matrix_dense.Matrix_dense):
A._matrix = self._matrix + (<Matrix_cyclo_dense>right)._matrix
return A

cpdef ModuleElement _sub_(self, ModuleElement right):
cpdef _sub_(self, ModuleElement right):
"""
Return the difference of two dense cyclotomic matrices.
Expand All @@ -524,7 +524,7 @@ cdef class Matrix_cyclo_dense(matrix_dense.Matrix_dense):
A._matrix = self._matrix - (<Matrix_cyclo_dense>right)._matrix
return A

cpdef ModuleElement _lmul_(self, RingElement right):
cpdef _lmul_(self, RingElement right):
"""
Multiply a dense cyclotomic matrix by a scalar.
Expand Down Expand Up @@ -566,7 +566,7 @@ cdef class Matrix_cyclo_dense(matrix_dense.Matrix_dense):
A._matrix = T * self._matrix
return A

cdef baseMatrix _matrix_times_matrix_(self, baseMatrix right):
cdef _matrix_times_matrix_(self, baseMatrix right):
"""
Return the product of two cyclotomic dense matrices.
Expand Down
Loading

0 comments on commit 56776e2

Please sign in to comment.