RobinMagnet / pyFM

Python implementation of Functional Maps
MIT License
95 stars 20 forks source link

Problems with eigenvector #16

Closed JunzheJosephZhu closed 3 months ago

JunzheJosephZhu commented 3 months ago

array([[ 8.30060239e+01,
[ 3.62382715e+01,
[-2.02953062e+00, [ 3.65334519e-03,
[ 2.69058151e+01,
[-2.37457767e+01, [-2.67653494e+01, [-2.86296451e+00, [-1.84055308e+00,

This is the dot product between the first several eigenvectors and an all-ones function. This appears to be off. Since the first eigenvectors is supposed to constant function and eigenvectors are orthogonal, aren't the numbers starting from the second one all supposed to be zero?

For reference, this is both the case for both robust and non-robust laplacian, regardless of the use for intrinsic representation.

JunzheJosephZhu commented 3 months ago

Computing eigenvectors directly from np.inv(A)@W seems to give the correct eigenvalues, but I used the resulting eigenvectors to reconstruct shapes, the results is horrible(turns an apple into a spiky ball)

Using lobpcg seems to produce the correct eigenvalues AND the correct reconstruction.

RobinMagnet commented 3 months ago

Hi,

The code is fine, this is just a small mistake on your side.

The eigenvectors are not orthonormal with respect to the standard inner product, but rather with respect to the $L^2$ inner product on the surface. You can also check that they are not normalized with respect to the standard inner product.

The $L^2$ inner product is defined as $\langle f, g \rangle = f^\top A g = \sumi A{ii} f_i g_i$, where $A$ is the area matrix. There is a l2_inner method in the TriMesh class in the package.

In the code, this comes from the fact the Laplacian is defined as $\Delta = A^{-1} W$, with $A$ the area matrix and $W$ the stiffness matrix, and that we obtain the eigenvectors solving the generalized eigenproblem $W\Phi_j = \lambda_j A \Phi_j$. In that case, the $\Phi_j$ are orthonormal with respect the the inner product induced by matrix $A$.