{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# How to compute the mesh Laplacian spectrum?" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from geomfum.dataset import NotebooksDataset\n", "from geomfum.laplacian import LaplacianFinder, LaplacianSpectrumFinder\n", "from geomfum.numerics.eig import ScipyEigsh\n", "from geomfum.shape import TriangleMesh" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Load a mesh](00_load_mesh_from_file.ipynb)." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "dataset = NotebooksDataset()\n", "mesh = TriangleMesh.from_file(dataset.get_filename(\"cat-00\"))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Compute spectrum of [Laplacian](./01_mesh_laplacian.ipynb)." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "((5,), (7207, 5))" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "spectrum_finder = LaplacianSpectrumFinder(\n", " nonzero=False,\n", " fix_sign=False,\n", " laplacian_finder=LaplacianFinder.from_registry(which=\"robust\"),\n", " eig_solver=ScipyEigsh(spectrum_size=5, sigma=-0.01),\n", ")\n", "\n", "eigvals, eigvecs = spectrum_finder(mesh, as_basis=False)\n", "\n", "(eigvals.shape, eigvecs.shape)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Syntax sugar:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "((5,), (7207, 5))" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mesh.laplacian.find_spectrum(laplacian_spectrum_finder=spectrum_finder)\n", "\n", "(mesh.basis.vals.shape, mesh.basis.vecs.shape)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Further reading\n", "\n", "* [How to compute descriptors?](./03_descriptors.ipynb)" ] } ], "metadata": { "kernelspec": { "display_name": "py12", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.3" } }, "nbformat": 4, "nbformat_minor": 2 }