Notebook source code:
notebooks/how_to/10_pointwise_from_functional.ipynb
Run it yourself on binder
How to compute a pointwise map from a functional map?#
In [1]:
import geomstats.backend as gs
from geomfum.convert import P2pFromFmConverter
from geomfum.dataset import NotebooksDataset
from geomfum.shape import TriangleMesh
In [2]:
dataset = NotebooksDataset()
mesh_a = TriangleMesh.from_file(dataset.get_filename("cat-00"))
mesh_b = TriangleMesh.from_file(dataset.get_filename("lion-00"))
mesh_a.n_vertices, mesh_b.n_vertices
Out [2]:
(7207, 5000)
Set Laplace eigenbasis for each mesh.
In [3]:
mesh_a.laplacian.find_spectrum(spectrum_size=6, set_as_basis=True)
mesh_b.laplacian.find_spectrum(spectrum_size=6, set_as_basis=True)
mesh_b.basis.use_k = 5
Assume we have a valid functional map \(C\) between mesh_a
and mesh_b
(which for demonstration purposes, we instantiate randomly).
In [4]:
fmap_matrix = gs.random.uniform(
size=(mesh_b.basis.spectrum_size, mesh_a.basis.spectrum_size)
)
fmap_matrix.shape
Out [4]:
(5, 6)
Compute pointwise map.
In [5]:
p2p_converter = P2pFromFmConverter()
p2p = p2p_converter(fmap_matrix, mesh_a.basis, mesh_b.basis)
p2p.shape
Out [5]:
(5000,)
The adjoint method can be used by setting adjoint
.
In [6]:
p2p_converter.adjoint = True
p2p = p2p_converter(fmap_matrix, mesh_a.basis, mesh_b.basis)
p2p.shape
Out [6]:
(5000,)
The bijective method can be use by setting bijective
.
In [7]:
p2p_converter.bijective = True
p2p = p2p_converter(fmap_matrix, mesh_a.basis, mesh_b.basis)
p2p.shape
Out [7]:
(7207,)