Skip to content

Commit

Permalink
Sparse matrix optimisation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Hale committed Jul 5, 2024
1 parent 10b1bbf commit 511d01f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="sgw_tools",
version="2.5.2",
version="2.5.3",
author="Mark Hale",
license="MIT",
description="Spectral graph wavelet tools",
Expand Down
15 changes: 8 additions & 7 deletions sgw_tools/filters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np
from scipy import sparse
import pygsp as gsp
from . import util
from . import approximations
Expand Down Expand Up @@ -225,11 +226,11 @@ def filter(self, s, method='cayley', maxiter=1000):

s = s.squeeze(axis=2)
L = self.G.L
im_eye = np.eye(self.G.N) * 1j
im_eye = sparse.identity(self.G.N, dtype=complex) * 1j
ys = []
for coeffs in self.coeff_bank:
h, c0, c = coeffs[0], coeffs[1], coeffs[2:]
J = np.linalg.inv(h * L + im_eye) @ (h * L - im_eye)
J = sparse.linalg.inv(h * L + im_eye) @ (h * L - im_eye)
y = c0 * s
v = s
for r in range(len(c)):
Expand All @@ -245,18 +246,18 @@ def filter(self, s, method='cayley', maxiter=1000):

s = s.squeeze(axis=2)
L = self.G.L
im_eye = np.eye(self.G.N) * 1j
im_eye = sparse.identity(self.G.N, dtype=complex) * 1j
ys = []
for idx, coeffs in enumerate(self.coeff_bank):
h, c0, c = coeffs[0], coeffs[1], coeffs[2:]
y = c0 * s

# Jacobi iteration matrix
M = h * L + im_eye
D = np.diag(1/np.diag(M))
D = sparse.diags(1/M.diagonal())
B = D @ M.conj()
J = -D @ (M - np.diag(np.diag(M)))
J = -D @ (M - sparse.diags(M.diagonal()))

v = s
for r in range(len(c)):
# Jacobi iteration
Expand Down

0 comments on commit 511d01f

Please sign in to comment.