def __remove_equalities(self, equalities, momentequalities):
A = self.__process_equalities(equalities, momentequalities)<EOL>if min(A.shape != np.linalg.matrix_rank(A)):<EOL><INDENT>print("<STR_LIT>"<EOL>"<STR_LIT>", file=sys.stderr)<EOL><DEDENT>if A.shape[<NUM_LIT:0>] == <NUM_LIT:0>:<EOL><INDENT>return<EOL><DEDENT>c = np.array(self.obj_facvar)<EOL>if self.verbose > <NUM_LIT:0>:<EOL><INDENT>print("<STR_LIT>")<EOL><DEDENT>Q, R = np.linalg.qr(A[:, <NUM_LIT:1>:].T, mode='<STR_LIT>')<EOL>n = np.max(np.nonzero(np.sum(np.abs(R), axis=<NUM_LIT:1>) > <NUM_LIT:0>)) + <NUM_LIT:1><EOL>x = np.dot(Q[:, :n], np.linalg.solve(np.transpose(R[:n, :]), -A[:, <NUM_LIT:0>]))<EOL>self._new_basis = lil_matrix(Q[:, n:])<EOL>self._original_obj_facvar = self.obj_facvar<EOL>self._original_constant_term = self.constant_term<EOL>self.obj_facvar = self._new_basis.T.dot(c)<EOL>self.constant_term += c.dot(x)<EOL>x = np.append(<NUM_LIT:1>, x)<EOL>new_F = lil_matrix((self.F.shape[<NUM_LIT:0>], self._new_basis.shape[<NUM_LIT:1>] + <NUM_LIT:1>))<EOL>new_F[:, <NUM_LIT:0>] = self.F[:, :self.n_vars+<NUM_LIT:1>].dot(x).reshape((new_F.shape[<NUM_LIT:0>],<EOL><NUM_LIT:1>))<EOL>new_F[:, <NUM_LIT:1>:] = self.F[:, <NUM_LIT:1>:self.n_vars+<NUM_LIT:1>].dot(self._new_basis)<EOL>self._original_F = self.F<EOL>self.F = new_F<EOL>self.n_vars = self._new_basis.shape[<NUM_LIT:1>]<EOL>if self.verbose > <NUM_LIT:0>:<EOL><INDENT>print("<STR_LIT>"<EOL>% self.n_vars)<EOL><DEDENT>
Attempt to remove equalities by solving the linear equations.