This internal function is used to determine whether a square matrix
is diagonal (within a specified tolerance). Returns TRUE
when the absolute values of all off-diagonal elements
are below tol, using all.equal().
is_diagonal(A, tol = .Machine$double.eps * 100, symmetric = FALSE)Square matrix. No check is done.
Numeric to specify tolerance in all.equal()
If FALSE (default), sum of absolute values of the corresponding
lower and upper triangular elements are examined with a doubled
tol. If TRUE, only the lower triangular elements are
examined assuming symmetry.