Utils

Module containing utility functions for the ICS algorithm.

This module provides various utility functions used in the computation of scatter matrices and transformations within the Invariant Coordinate Selection (ICS) algorithm. Functions included in this module perform operations such as sorting eigenvalues and eigenvectors, and computing the square root or inverse square root of symmetric matrices.

icspylab.utils.sort_eigenvalues_eigenvectors(eigenvalues, eigenvectors)[source]

Sort eigenvalues and eigenvectors in descending order of eigenvalues.

Parameters:
  • eigenvalues (ndarray) – Array of eigenvalues.

  • eigenvectors (ndarray) – Corresponding eigenvectors.

Returns:

A tuple containing:
  • eigenvalues (ndarray): 1D array of eigenvalues sorted in descending order.

  • eigenvectors (ndarray): 2D array of eigenvectors sorted to match the order of sorted_eigenvalues.

Return type:

tuple

icspylab.utils.sqrt_symmetric_matrix(A, inverse=False)[source]

Compute the square root or inverse square root of a symmetric matrix.

Parameters:
  • A (ndarray) – Symmetric matrix to compute the square root or inverse square root of.

  • inverse (bool, default=False)

Returns:

The (inverse) square root of the matrix.

Return type:

ndarray