+class Dummy(Symbol):
+
+ _count = 0
+
+ def __new__(cls, name=None):
+ if name is None:
+ name = 'Dummy_{}'.format(Dummy._count)
+ self = object().__new__(cls)
+ self._index = Dummy._count
+ self._name = name.strip()
+ self._coefficients = {self: Fraction(1)}
+ self._constant = Fraction(0)
+ self._symbols = (self,)
+ self._dimension = 1
+ Dummy._count += 1
+ return self
+
+ def __hash__(self):
+ return hash(self.sortkey())
+
+ def sortkey(self):
+ return self._name, self._index
+
+ def __eq__(self, other):
+ return isinstance(other, Dummy) and self._index == other._index
+
+ def __repr__(self):
+ return '_{}'.format(self.name)
+
+ def _repr_latex_(self):
+ return '${}_{{{}}}$'.format(self.name, self._index)
+
+