def h2_squared_norm(A, B, Phi_x, Phi_u, Q, R, sigma_w):
    '\n    Gets the squared infinite horizon LQR cost for system\n    (A,B) in feedback with the controller defined by Phi_x\n    and Phi_u. \n\n    '
    (n, p) = B.shape
    (A_k, B_k, C_k, D_k) = make_state_space_controller(Phi_x, Phi_u, n, p)
    A_cl = np.block([[(A + B.dot(D_k)), B.dot(C_k)], [B_k, A_k]])
    Q_sqrt = utils.psd_sqrt(Q)
    R_sqrt = utils.psd_sqrt(R)
    C_cl = np.block([[Q_sqrt, np.zeros((n, A_k.shape[0]))], [R_sqrt.dot(D_k), R_sqrt.dot(C_k)]])
    B_cl = np.vstack((np.eye(n), np.zeros((A_k.shape[0], n))))
    P = utils.solve_discrete_lyapunov(A_cl.T, B_cl.dot(B_cl.T))
    return ((sigma_w ** 2) * np.trace(C_cl.dot(P).dot(C_cl.T)))
Gets the squared infinite horizon LQR cost for system
(A,B) in feedback with the controller defined by Phi_x
and Phi_u.
def h2_squared_norm(A, B, Phi_x, Phi_u, Q, R, sigma_w):
    '\n    Gets the squared infinite horizon LQR cost for system\n    (A,B) in feedback with the controller defined by Phi_x\n    and Phi_u. \n\n    '
    (n, p) = B.shape
    (A_k, B_k, C_k, D_k) = make_state_space_controller(Phi_x, Phi_u, n, p)
    A_cl = np.block([[(A + B.dot(D_k)), B.dot(C_k)], [B_k, A_k]])
    Q_sqrt = utils.psd_sqrt(Q)
    R_sqrt = utils.psd_sqrt(R)
    C_cl = np.block([[Q_sqrt, np.zeros((n, A_k.shape[0]))], [R_sqrt.dot(D_k), R_sqrt.dot(C_k)]])
    B_cl = np.vstack((np.eye(n), np.zeros((A_k.shape[0], n))))
    P = utils.solve_discrete_lyapunov(A_cl.T, B_cl.dot(B_cl.T))
    return ((sigma_w ** 2) * np.trace(C_cl.dot(P).dot(C_cl.T)))