robust-laplacians-py icon indicating copy to clipboard operation
robust-laplacians-py copied to clipboard

Cholmod: Laplacian matrix not positive definite

Open rezss opened this issue 2 years ago • 0 comments

Hey, I really appreciate your work with that library.

I have a small issue (or lack of understanding) however: In the readme of the library there is the following state:

The resulting Laplacian is always a symmetric positive-definite matrix, with all positive edge weights.

But when i computed the mesh_laplacian from an .obj file (loaded with trimesh, example: dog8.obj.zip) and try to compute the eigenvalues using cholesky, I do get the following error:

import robust_laplacian
from sksparse.cholmod import cholesky

L, M = robust_laplacian.mesh_laplacian(np.array(mesh.vertices), np.array(mesh.faces))
chol = cholesky(L)

{CholmodNotPositiveDefiniteError}CholmodNotPositiveDefiniteError('/tmp/suite-sparse-20230122-5765-1n0vsg8/SuiteSparse-7.0.1/CHOLMOD/Supernodal/t_cholmod_super_numeric.c:963: matrix not positive definite (code 1)')

I'm able to fix the issue in that case by adding a a small epsilon to the laplacian

L.data += sys.float_info.epsilon
chol = cholesky(L)
op_inv = scipy.sparse.linalg.LinearOperator(matvec=chol, shape=L.shape, dtype=L.dtype)
eigen_values, eigen_vectors = scipy.sparse.linalg.eigsh(L, n_eig, M, sigma=0, OPinv=op_inv)

But due to my lack of understanding I'm note sure if this has any dire consequences.

rezss avatar Jul 02 '23 16:07 rezss