Static Convolution
- class Convolve(L)[source]
Bases:
objectStatic graph convolution context using CHOLMOD.
Designed for high-performance GSP operations on graphs with constant topology. Manages CHOLMOD symbolic and numeric factorizations internally.
- Parameters:
L (
csc_matrix) – Sparse Graph Laplacian of shape(n_vertices, n_vertices).
See also
DyConvolveFor graphs with evolving topologies.
Examples
>>> from sgwt import Convolve, LAPLACIAN_TEXAS_DELAY >>> import numpy as np >>> L = LAPLACIAN_TEXAS_DELAY >>> signal = np.random.randn(L.shape[0], 100) >>> with Convolve(L) as conv: ... lp = conv.lowpass(signal, scales=[0.1, 1.0, 10.0]) ... bp = conv.bandpass(signal, scales=[1.0])
- bandpass(B, scales=[1], order=1)[source]
Computes band-pass filtered wavelet coefficients at specified scales.
Applies the spectral wavelet kernel:
\[\Psi_s(\mathbf{L}) = \left( \frac{4\mathbf{L}/s}{(\mathbf{L} + \mathbf{I}/s)^2} \right)^n\]where \(s\) is the scale and \(n\) is the filter order. This kernel satisfies the admissibility condition \(\Psi(0) = 0\).
- Parameters:
B (
ndarray) – Input signal array. Can be 1D (n_vertices,) or 2D (n_vertices, n_timesteps).scales (
float | list[float], default:[1]) – Scale or list of scales \(s\) to compute coefficients for. If a scalar is passed, returns a single array instead of a list.order (
int, default:1) – Filter order \(n\).
- Returns:
Filtered signal(s). Returns a single array if
scalesis a scalar, otherwise a list of arrays for each scale.- Return type:
np.ndarray | list[np.ndarray]
- convolve(B, K)[source]
Performs graph convolution using a specified kernel.
- Parameters:
B (
ndarray) – Input signal array. Can be 1D (n_vertices,) or 2D (n_vertices, n_timesteps).K (
VFKernel | dict) – Kernel function (Vector Fitting model) to apply.
- Returns:
Convolved signal. Shape depends on input: (n_vertices, nDim) for 1D input, (n_vertices, n_timesteps, nDim) for 2D input.
- Return type:
- highpass(B, scales=[1])[source]
Computes high-pass filtered coefficients at specified scales.
Applies the spectral filter:
\[\mu_s(\mathbf{L}) = \frac{s\mathbf{L}}{s\mathbf{L} + \mathbf{I}}\]where \(s\) is the scale.
- Parameters:
B (
ndarray) – Input signal array. Can be 1D (n_vertices,) or 2D (n_vertices, n_timesteps).scales (
float | list[float], default:[1]) – Scale or list of scales \(s\) to compute coefficients for. If a scalar is passed, returns a single array instead of a list.
- Returns:
Filtered signal(s). Returns a single array if
scalesis a scalar, otherwise a list of arrays for each scale.- Return type:
np.ndarray | list[np.ndarray]
- lowpass(B, scales=[1], Bset=None, refactor=True, order=1)[source]
Computes low-pass filtered scaling coefficients at specified scales.
Applies the spectral filter:
\[\phi_s(\mathbf{L}) = \left( \frac{\mathbf{I}}{s\mathbf{L} + \mathbf{I}} \right)^n\]where \(s\) is the scale and \(n\) is the filter order.
- Parameters:
B (
ndarray) – Input signal array. Can be 1D (n_vertices,) or 2D (n_vertices, n_timesteps).scales (
float | list[float], default:[1]) – Scale or list of scales \(s\) to compute coefficients for. If a scalar is passed, returns a single array instead of a list.Bset (
csc_matrix, optional) – Sparse indicator vector for localized coefficient computation.refactor (
bool, default:True) – Whether to perform numeric factorization for each scale.order (
int, default:1) – Filter order \(n\).
- Returns:
Filtered signal(s). Returns a single array if
scalesis a scalar, otherwise a list of arrays for each scale.- Return type:
np.ndarray | list[np.ndarray]