irtazahashmi / pytspl

A Python library for Topological Signal Processing and Learning.
MIT License
4 stars 0 forks source link

Consider having a function for both total variation and curl computation as well #31

Closed cookbook-ms closed 3 months ago

cookbook-ms commented 3 months ago

In the current code of hodgedecomposition.py, you have only get_divergence(), while the total variance and the curl are often needed, just as in get different sets of eigenvectors or as below what you repeated in GP part.

def get_eigenpairs(self) -> list:
        """
        Return the eigenpairs of the Laplacian matrices.

        Returns:
            list(torch.tensor): The eigenpairs of the Laplacian matrices.
        """
        eigvals, eigvecs = np.linalg.eigh(self.L1)

        total_var = np.diag(eigvecs.T @ self.L1 @ eigvecs)
        total_div = np.diag(eigvecs.T @ self.L1l @ eigvecs)
        total_curl = np.diag(eigvecs.T @ self.L1u @ eigvecs)
irtazahashmi commented 3 months ago

I have improved that: https://github.com/irtazahashmi/pytspl/blob/dev/pytspl/hogde_gp/hodge_gp_trainer.py

and added curl in the Hodge decomposition module. I will also add total variance.

irtazahashmi commented 3 months ago

These functions are now implemented under the decomposition.eigendecomposition module and can also be called using the simlicial_complex object.

Also, I have clarified the functionality to retrieve eigenpair for each component in the decomposition.eigendecomposition module.