def _process_monomial(self, monomial, n_vars):
coeff, monomial = monomial.as_coeff_Mul()<EOL>k = <NUM_LIT:0><EOL>conjugate = False<EOL>try:<EOL><INDENT>k = self.monomial_index[monomial]<EOL><DEDENT>except KeyError:<EOL><INDENT>daggered_monomial =apply_substitutions(Dagger(monomial), self.substitutions,<EOL>self.pure_substitution_rules)<EOL>try:<EOL><INDENT>k = self.monomial_index[daggered_monomial]<EOL>conjugate = True<EOL><DEDENT>except KeyError:<EOL><INDENT>k = n_vars + <NUM_LIT:1><EOL>self.monomial_index[monomial] = k<EOL><DEDENT><DEDENT>if conjugate:<EOL><INDENT>k = -k<EOL><DEDENT>return k, coeff<EOL>
Process a single monomial when building the moment matrix.