gspbox icon indicating copy to clipboard operation
gspbox copied to clipboard

incorrect gft results with a ring graph

Open 1taroh opened this issue 1 year ago • 2 comments

I found a bug that makes an incorrect gft result with a ring graph.

Example

Gfted one-hot vector's amplitude is constant. And its phase should be a line. However, this example shows gft makes an incorrect result.

N = 64;
G = gsp_ring(N);
G = gsp_compute_fourier_basis(G);

f = zeros(N);
f(10) = 1;

plot(1:N,angle(gsp_gft(G,f)))
xlim([1 N])
ylim([-pi pi])
ylabel("phase [rad]")
yticks([-pi,0,pi])

phase

The cause

This is because the sort of eigenvalues and eigenvectors in https://github.com/epfl-lts2/gspbox/blob/a7d9aac5e239f1bcb37a9bb09998cc161be2732f/utils/gsp_compute_fourier_basis.m#L77-L85

However, this sort is important when we talk about graph frequency...

1taroh avatar Dec 20 '23 15:12 1taroh

Hi @1taroh Thanks for reporting this. Is the line 87 the problem? https://github.com/epfl-lts2/gspbox/blob/a7d9aac5e239f1bcb37a9bb09998cc161be2732f/utils/gsp_compute_fourier_basis.m#L87C5-L87C21 Could you try to fix it?

nperraud avatar Dec 20 '23 15:12 nperraud

Thank you for replying.

Yes, this sort makes the error.

I try to fix it.

In pygsp, the eigenvector matrix of a ring graph is a real matrix. I'll try to do the same in gsptoolbox. This modification means we do not consider the phase. People who want to consider it like me should use DFT matrix.

1taroh avatar Dec 22 '23 16:12 1taroh