docs: def arnoldi_res(A, V, H, ip_B=None):
      """Measure Arnoldi residual.
  
      :param A: a linear operator that can be used with scipy's aslinearoperator
        with ``shape==(N,N)``.
      :param V: Arnoldi basis matrix with ``shape==(N,n)``.
      :param H: Hessenberg matrix: either :math:`\\underline{H}_{n-1}` with
        ``shape==(n,n-1)`` or :math:`H_n` with ``shape==(n,n)`` (if the Arnoldi
        basis spans an A-invariant subspace).
      :param ip_B: (optional) the inner product to use, see :py:meth:`inner`.
  
      :returns: either :math:`\\|AV_{n-1} - V_n \\underline{H}_{n-1}\\|` or
        :math:`\\|A V_n - V_n H_n\\|` (in the invariant case).
      """
      N = V.shape[0]
      invariant = H.shape[0] == H.shape[1]
      A = get_linearoperator((N, N), A)
      if invariant:
          res = A*V - numpy.dot(V, H)
      else:
          res = A*V[:, :-1] - numpy.dot(V, H)
      return norm(res, ip_B=ip_B)