original_docstring: Generate an operator to evaluate matrix-Tressian-products for a function.
  
      The passed function should take as arguments symbolic arrays and return a
      symbolic scalar, and likewise the returned operator will take symbolic array
      arguments.
  
      For a single argument function `func`, `n`-dimensional input array `x` and
      `2 * n`-dimensional 'matrix' array `m` of shape `x.shape + x.shape` then we
      have the following equivalence
  
          matrix_tressian_product(func)(x)(m) == (
              tensordot(jacobian(hessian(func))(x), 2 * n))
  
      where `tensordot` follows its NumPy semantics, i.e. `tensordot(a, b, n)`
      sums the products of components of `a` and `b` over the last `n` axes
      (dimensions) of `a` and first `n` dimensions of `b`.
  
      Args:
          func (Callable[..., Scalar]): Function which takes one or more arrays as
              arguments and returns a scalar.
          wrt (int): Index of argument to take derivatives with respect to.
          return_aux (bool): Whether the generated operator returns the
              matrix-Tressian-product function, Hessian, gradient and value of
              `func` as a 4-tuple (True) or just the matrix-Tressian-product
              function (False).
  
      Returns:
          Callable[..., Union[Callable[Array, Array],
                              Tuple[Callable, Array, Array, Scalar]]]:
              Generated matrix-Tressian-product operator.
      
docstring: Generate an operator to evaluate matrix-Tressian-products for a function.
  The passed function should take as arguments symbolic arrays and return a
  symbolic scalar, and likewise the returned operator will take symbolic array
  arguments.
  
  
  
  
  
  
docstring_tokens: Generate an operator to evaluate matrix - Tressian - products for a function . The passed function should take as arguments symbolic arrays and return a symbolic scalar and likewise the returned operator will take symbolic array arguments .
code: def matrix_tressian_product(func, wrt=0, return_aux=False):
      """Generate an operator to evaluate matrix-Tressian-products for a function.
  
      The passed function should take as arguments symbolic arrays and return a
      symbolic scalar, and likewise the returned operator will take symbolic array
      arguments.
  
      For a single argument function `func`, `n`-dimensional input array `x` and
      `2 * n`-dimensional 'matrix' array `m` of shape `x.shape + x.shape` then we
      have the following equivalence
  
          matrix_tressian_product(func)(x)(m) == (
              tensordot(jacobian(hessian(func))(x), 2 * n))
  
      where `tensordot` follows its NumPy semantics, i.e. `tensordot(a, b, n)`
      sums the products of components of `a` and `b` over the last `n` axes
      (dimensions) of `a` and first `n` dimensions of `b`.
  
      Args:
          func (Callable[..., Scalar]): Function which takes one or more arrays as
              arguments and returns a scalar.
          wrt (int): Index of argument to take derivatives with respect to.
          return_aux (bool): Whether the generated operator returns the
              matrix-Tressian-product function, Hessian, gradient and value of
              `func` as a 4-tuple (True) or just the matrix-Tressian-product
              function (False).
  
      Returns:
          Callable[..., Union[Callable[Array, Array],
                              Tuple[Callable, Array, Array, Scalar]]]:
              Generated matrix-Tressian-product operator.
      """
  
      @_wrap_derived(func, 'mtp', 'matrix-Tressian-product')
      def mtp_func(*args):
          hess, grad, val = hessian(func, wrt, return_aux=True)(*args)
          tress = sym.diff(hess, args[wrt])
          m = _named_array('m', hess.shape)
          mtp = _generalised_dot(tress, m, args[wrt].shape)
          m_mtp = FunctionExpression((m,), mtp)
          return (m_mtp, hess, grad, val) if return_aux else m_mtp
  
      return mtp_func
code_tokens: def matrix_tressian_product ( func , wrt = 0 , return_aux = False ) : @ _wrap_derived ( func , 'mtp' , 'matrix-Tressian-product' ) def mtp_func ( * args ) : hess , grad , val = hessian ( func , wrt , return_aux = True ) ( * args ) tress = sym . diff ( hess , args [ wrt ] ) m = _named_array ( 'm' , hess . shape ) mtp = _generalised_dot ( tress , m , args [ wrt ] . shape ) m_mtp = FunctionExpression ( ( m , ) , mtp ) return ( m_mtp , hess , grad , val ) if return_aux else m_mtp return mtp_func
short_docstring: Generate an operator to evaluate matrix-Tressian-products for a function.
short_docstring_tokens: Generate an operator to evaluate matrix - Tressian - products for a function .
comment: """Generate an operator to evaluate matrix-Tressian-products for a function.
  
      The passed function should take as arguments symbolic arrays and return a
      symbolic scalar, and likewise the returned operator will take symbolic array
      arguments.
  
      For a single argument function `func`, `n`-dimensional input array `x` and
      `2 * n`-dimensional 'matrix' array `m` of shape `x.shape + x.shape` then we
      have the following equivalence
  
          matrix_tressian_product(func)(x)(m) == (
              tensordot(jacobian(hessian(func))(x), 2 * n))
  
      where `tensordot` follows its NumPy semantics, i.e. `tensordot(a, b, n)`
      sums the products of components of `a` and `b` over the last `n` axes
      (dimensions) of `a` and first `n` dimensions of `b`.
  
      Args:
          func (Callable[..., Scalar]): Function which takes one or more arrays as
              arguments and returns a scalar.
          wrt (int): Index of argument to take derivatives with respect to.
          return_aux (bool): Whether the generated operator returns the
              matrix-Tressian-product function, Hessian, gradient and value of
              `func` as a 4-tuple (True) or just the matrix-Tressian-product
              function (False).
  
      Returns:
          Callable[..., Union[Callable[Array, Array],
                              Tuple[Callable, Array, Array, Scalar]]]:
              Generated matrix-Tressian-product operator.
      """