I was going through this code and got error. But I could not understand why this is the case.
sage: T = TropicalSemiring(QQ)
sage: T(1)
1
sage: T(2)
2
sage: T(-2)
-2
sage: -T(2)
---------------------------------------------------------------------------
ArithmeticError Traceback (most recent call last)
Cell In[26], line 1
----> 1 -T(Integer(2))
File ~/sage/src/sage/rings/semirings/tropical_semiring.pyx:278, in sage.rings.semirings.tropical_semiring.TropicalSemiringElement.__neg__()
276 if self._val is None:
277 return self
--> 278 raise ArithmeticError("cannot negate any non-infinite element")
279
280 cpdef _mul_(left, right) noexcept:
ArithmeticError: cannot negate any non-infinite element
sage:
It looks like starting with T(-2) and reaching to -2 from T(2) by comparing with zero(+Inf) are different things.
T(-2) = -2
T(2) -T(2) = T.zero(+inf) = T(2) + (-T(2))
My doubt is : if we cannot negate the elements, then how can we compute the determinant of a Matrix over Tropical Semiring.
For example in 2x2 matrix : [[a,b], [c,d]] the determinant should be ad - bc
But can it be expressed as ad + (-bc) -->> min ( add(a,d), -1*add(b,c) )?
In fact we connot even do matrix subtraction directly.
What can be done in these cases??