@@ -346,6 +346,19 @@ cdef class fmpq_mpoly(flint_mpoly):
346346 return res
347347 return NotImplemented
348348
349+ def __iadd__ (self , other ):
350+ if typecheck(other, fmpq_mpoly):
351+ if (< fmpq_mpoly> self ).ctx is not (< fmpq_mpoly> other).ctx:
352+ raise IncompatibleContextError(f" {(<fmpq_mpoly>self).ctx} is not {(<fmpq_mpoly>other).ctx}" )
353+ fmpq_mpoly_add((< fmpq_mpoly> self ).val, (< fmpq_mpoly> self ).val, (< fmpq_mpoly> other).val, self .ctx.val)
354+ return self
355+ else :
356+ other = any_as_fmpq(other)
357+ if other is not NotImplemented :
358+ fmpq_mpoly_add_fmpq((< fmpq_mpoly> self ).val, (< fmpq_mpoly> self ).val, (< fmpq> other).val, self .ctx.val)
359+ return self
360+ return NotImplemented
361+
349362 def __sub__ (self , other ):
350363 cdef fmpq_mpoly res
351364 if typecheck(other, fmpq_mpoly):
@@ -371,6 +384,19 @@ cdef class fmpq_mpoly(flint_mpoly):
371384 return - res
372385 return NotImplemented
373386
387+ def __isub__ (self , other ):
388+ if typecheck(other, fmpq_mpoly):
389+ if (< fmpq_mpoly> self ).ctx is not (< fmpq_mpoly> other).ctx:
390+ raise IncompatibleContextError(f" {(<fmpq_mpoly>self).ctx} is not {(<fmpq_mpoly>other).ctx}" )
391+ fmpq_mpoly_sub((< fmpq_mpoly> self ).val, (< fmpq_mpoly> self ).val, (< fmpq_mpoly> other).val, self .ctx.val)
392+ return self
393+ else :
394+ other = any_as_fmpq(other)
395+ if other is not NotImplemented :
396+ fmpq_mpoly_sub_fmpq((< fmpq_mpoly> self ).val, (< fmpq_mpoly> self ).val, (< fmpq> other).val, self .ctx.val)
397+ return self
398+ return NotImplemented
399+
374400 def __mul__ (self , other ):
375401 cdef fmpq_mpoly res
376402 if typecheck(other, fmpq_mpoly):
@@ -396,6 +422,19 @@ cdef class fmpq_mpoly(flint_mpoly):
396422 return res
397423 return NotImplemented
398424
425+ def __imul__ (self , other ):
426+ if typecheck(other, fmpq_mpoly):
427+ if (< fmpq_mpoly> self ).ctx is not (< fmpq_mpoly> other).ctx:
428+ raise IncompatibleContextError(f" {(<fmpq_mpoly>self).ctx} is not {(<fmpq_mpoly>other).ctx}" )
429+ fmpq_mpoly_mul((< fmpq_mpoly> self ).val, (< fmpq_mpoly> self ).val, (< fmpq_mpoly> other).val, self .ctx.val)
430+ return self
431+ else :
432+ other = any_as_fmpq(other)
433+ if other is not NotImplemented :
434+ fmpq_mpoly_scalar_mul_fmpq(self .val, (< fmpq_mpoly> self ).val, (< fmpq> other).val, self .ctx.val)
435+ return self
436+ return NotImplemented
437+
399438 def __pow__ (self , other , modulus ):
400439 cdef fmpq_mpoly res
401440 if modulus is not None :
0 commit comments