Ensures the symmetry of a square matrix by averaging it with its transpose. Optionally verifies that the matrix was close to symmetric before.
Makes sure zeros are "numerically zero", by truncating all small values.
ensure_matrix_symmetry(M, checkTol = Inf, alert = NULL)truncate_zeros(M, tol = get_small_tol())
ensure_matrix_symmetry_and_truncate_zeros(
M,
tol = get_small_tol(),
checkTol = Inf
)
The adjusted value of M
.
Numeric square matrix.
Positive scalar. If the maximum absolute difference between M
and t(M)
is larger, show a warning.
Passed to get_alert_function
: NULL
or TRUE
to read the option value,
FALSE
to return a dummy function, or a function that takes an arbitrary number of strings as arguments (e.g. stop()
).
All entries with absolute value below this value are truncated to zero.
Other input validation functions:
checkGamma()
,
check_graph()
,
check_partial_matrix_and_graph()