Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Magnitude Function to include Bastian's solver #91

Open
lizliz opened this issue Mar 1, 2024 · 0 comments
Open

Update Magnitude Function to include Bastian's solver #91

lizliz opened this issue Mar 1, 2024 · 0 comments

Comments

@lizliz
Copy link
Collaborator

lizliz commented Mar 1, 2024

Pasting in the original message from @Pseudomanifold Bastien Rieck in here. The idea is to modify the magnitude function computation to do this version as an option.


Sorry, don't know how to properly add to this request...but here's some code that calculates magnitude using a Cholesky decomposition.

from scipy.linalg import cho_factor
from scipy.linalg import solve_triangular

[...]

M = np.exp(-D)
c, lower = cho_factor(M)
x = solve_triangular(c, np.ones(M.shape[0]), trans=1)

return x.T @ x

The idea is that the similarity matrix $\zeta$ is positive definite (under nice conditions), so it affords a Cholesky decomposition, which factorises as $L L^T$ for $L$ a lower-triangular matrix. Magnitude can be written as $\textrm{Mag}(X) = \mathbb{1}^T \zeta^{-1} \mathbb{1}$, i.e. a quadratic form (since we are taking row sums). Thus, calculating magnitude is equivalent to calculating $x^T x$ with $x$ defined by $Lx = \mathbb{1}$.

(We have described this a little bit in Appendix B of a recent preprint)

Hope that helps!

Originally posted by @Pseudomanifold in #89 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant