brainspace.gradient.utils.make_symmetric

brainspace.gradient.utils.make_symmetric(x, check=True, tol=1e-10, copy=True, sparse_format=None)[source]

Make array symmetric.

Parameters:
  • x (2D ndarray or sparse matrix) – Input data.
  • check (bool, optional) – If True, check if already symmetry first. Default is True.
  • tol (float, optional) – Maximum allowed tolerance for equivalence. Default is 1e-10.
  • copy (bool, optional) – If True, return a copy. Otherwise, work on x. If already symmetric, returns original array.
  • sparse_format ({'coo', 'csr', 'csc', ..}, optional) – Format of output symmetric matrix. Only used if x is sparse. Default is None, uses original format.
Returns:

sym (2D ndarray or sparse matrix.) – Symmetrized version of x. Return x it is already symmetric.

Raises:

ValueError – If x is not square.