code: def _matrix_operator(C, operator):
      """Matrix function."""
      if not isinstance(C, np.ndarray) or C.ndim < 2:
          raise ValueError("Input must be at least a 2D ndarray")
      if C.dtype.char in typecodes["AllFloat"] and (
          np.isinf(C).any() or np.isnan(C).any()
      ):
          raise ValueError(
              "Matrices must be positive definite. Add "
              "regularization to avoid this error."
          )
      eigvals, eigvecs = np.linalg.eigh(C)
      eigvals = operator(eigvals)
      if C.ndim >= 3:
          eigvals = np.expand_dims(eigvals, -2)
      D = (eigvecs * eigvals) @ np.swapaxes(eigvecs.conj(), -2, -1)
      return D
  
file_path: pyRiemann/pyriemann/utils/base.py
imports: import numpy
  from numpy.core.numerictypes import typecodes
  from .test import is_pos_def
label_desc: Use image node_id 1 for calling a global function with example usage: _matrix_operator(C, operator) and returns: D