original_docstring: Evaluate the multinomial at xval.
  
          if xval is a length n z2 vector, return element of Z8.
          if xval is a length n vector of multinomials, return
          a multinomial. The multinomials must all be on n vars.
          
docstring: Evaluate the multinomial at xval.
  if xval is a length n z2 vector, return element of Z8.
  if xval is a length n vector of multinomials, return
  a multinomial. The multinomials must all be on n vars.
docstring_tokens: Evaluate the multinomial at xval . if xval is a length n z2 vector return element of Z8 . if xval is a length n vector of multinomials return a multinomial . The multinomials must all be on n vars .
code: def evaluate(self, xval):
          """Evaluate the multinomial at xval.
  
          if xval is a length n z2 vector, return element of Z8.
          if xval is a length n vector of multinomials, return
          a multinomial. The multinomials must all be on n vars.
          """
          if len(xval) != self.n_vars:
              raise QiskitError("Evaluate on wrong number of variables.")
          check_int = list(map(lambda x: isinstance(x, int), xval))
          check_poly = list(map(lambda x: isinstance(x, SpecialPolynomial), xval))
          if False in check_int and False in check_poly:
              raise QiskitError("Evaluate on a wrong type.")
          is_int = False not in check_int
          if not is_int:
              if False in [i.n_vars == self.n_vars for i in xval]:
                  raise QiskitError("Evaluate on incompatible polynomials.")
          else:
              xval = xval % 2
          # Examine each term of this polynomial
          terms0 = [[]]
          terms1 = list(combinations(range(self.n_vars), r=1))
          terms2 = list(combinations(range(self.n_vars), r=2))
          terms3 = list(combinations(range(self.n_vars), r=3))
          # Set the initial result and start for each term
          if is_int:
              result = 0
              start = 1
          else:
              result = SpecialPolynomial(self.n_vars)
              start = SpecialPolynomial(self.n_vars)
              start.weight_0 = 1
          # Compute the new terms and accumulate
          for term in terms0 + terms1 + terms2 + terms3:
              value = self.get_term(term)
              if value != 0:
                  newterm = reduce(mul, [xval[j] for j in term], start)
                  result = result + value * newterm
          if isinstance(result, int):
              result = result % 8
          return result
code_tokens: def evaluate ( self , xval ) : if len ( xval ) != self . n_vars : raise QiskitError ( "Evaluate on wrong number of variables." ) check_int = list ( map ( lambda x : isinstance ( x , int ) , xval ) ) check_poly = list ( map ( lambda x : isinstance ( x , SpecialPolynomial ) , xval ) ) if False in check_int and False in check_poly : raise QiskitError ( "Evaluate on a wrong type." ) is_int = False not in check_int if not is_int : if False in [ i . n_vars == self . n_vars for i in xval ] : raise QiskitError ( "Evaluate on incompatible polynomials." ) else : xval = xval % 2 terms0 = [ [ ] ] terms1 = list ( combinations ( range ( self . n_vars ) , r = 1 ) ) terms2 = list ( combinations ( range ( self . n_vars ) , r = 2 ) ) terms3 = list ( combinations ( range ( self . n_vars ) , r = 3 ) ) if is_int : result = 0 start = 1 else : result = SpecialPolynomial ( self . n_vars ) start = SpecialPolynomial ( self . n_vars ) start . weight_0 = 1 for term in terms0 + terms1 + terms2 + terms3 : value = self . get_term ( term ) if value != 0 : newterm = reduce ( mul , [ xval [ j ] for j in term ] , start ) result = result + value * newterm if isinstance ( result , int ) : result = result % 8 return result
short_docstring: Evaluate the multinomial at xval.
short_docstring_tokens: Evaluate the multinomial at xval .
comment: """Evaluate the multinomial at xval.
  
          if xval is a length n z2 vector, return element of Z8.
          if xval is a length n vector of multinomials, return
          a multinomial. The multinomials must all be on n vars.
          """$SEP$# Examine each term of this polynomial$SEP$# Set the initial result and start for each term$SEP$# Compute the new terms and accumulate