forceSymmetric package:Matrix R Documentation _F_o_r_c_e _a _M_a_t_r_i_x _t_o '_s_y_m_m_e_t_r_i_c_M_a_t_r_i_x' _W_i_t_h_o_u_t _S_y_m_m_e_t_r_y _C_h_e_c_k_s _D_e_s_c_r_i_p_t_i_o_n: Force 'x' (inheriting from 'Matrix' class) to 'symmetricMatrix', *without* a symmetry check (which _is_ applied for all 'as(x, "symmetricMatrix")' alikes). _U_s_a_g_e: forceSymmetric(x, uplo) _A_r_g_u_m_e_n_t_s: x: a (classed) square matrix. uplo: optional string, '"U"' or '"L"'. The default is '"U"' unless 'x' already has a 'uplo' slot (i.e., when it is 'symmetricMatrix', or 'triangularMatrix'), where the default will be 'x@uplo'. _V_a_l_u_e: a square matrix inheriting from class 'symmetricMatrix'. _S_e_e _A_l_s_o: 'symmpart' for the symmetric part, or the coercions 'as(x, )'. _E_x_a_m_p_l_e_s: ## Hilbert matrix i <- 1:6 h6 <- 1/outer(i - 1L, i, "+") sd <- sqrt(diag(h6)) hh <- t(h6/sd)/sd # theoretically symmetric isSymmetric(hh, tol=0) # FALSE; hence try( as(hh, "symmetricMatrix") ) # fails, but this works fine: H6 <- forceSymmetric(hh) ## result can be pretty surprising: (M <- Matrix(1:36, 6)) forceSymmetric(M) # symmetric, hence very different in lower triangle (tm <- tril(M)) forceSymmetric(tm)