parameters: (x, P)
docstring: Alias for :math:`x^T P x`.
docstring_summary: Alias for :math:`x^T P x`.
docstring_tokens: Alias for : math : x^T P x .
function: def quad_form(x, P):
      """ Alias for :math:`x^T P x`.
  
      """
      x, P = map(Expression.cast_to_const, (x, P))
      # Check dimensions.
      if not P.ndim == 2 or P.shape[0] != P.shape[1] or max(x.shape, (1,))[0] != P.shape[0]:
          raise Exception("Invalid dimensions for arguments.")
      if x.is_constant():
          return x.H @ P @ x
      elif P.is_constant():
          return QuadForm(x, P)
      else:
          raise Exception(
              "At least one argument to quad_form must be non-variable."
          )
function_tokens: def quad_form ( x , P ) : x , P = map ( Expression . cast_to_const , ( x , P ) ) # Check dimensions. if not P . ndim == 2 or P . shape [ 0 ] != P . shape [ 1 ] or max ( x . shape , ( 1 , ) ) [ 0 ] != P . shape [ 0 ] : raise Exception ( "Invalid dimensions for arguments." ) if x . is_constant ( ) : return x . H @ P @ x elif P . is_constant ( ) : return QuadForm ( x , P ) else : raise Exception ( "At least one argument to quad_form must be non-variable." )