Ensure numerical matrix symmetry/zero values
Source:R/input_checks.R
ensure_matrix_symmetry_and_truncate_zeros.RdEnsures 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.
Usage
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
)Arguments
- M
Numeric square matrix.
- checkTol
Positive scalar. If the maximum absolute difference between
Mandt(M)is larger, show a warning.- alert
Passed to
get_alert_function:NULLorTRUEto read the option value,FALSEto return a dummy function, or a function that takes an arbitrary number of strings as arguments (e.g.stop()).- tol
All entries with absolute value below this value are truncated to zero.
See also
Other input validation functions:
checkGamma(),
check_graph(),
check_partial_matrix_and_graph()