{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# How to compute the mesh Laplacian?" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from geomfum.dataset import NotebooksDataset\n", "from geomfum.laplacian import LaplacianFinder\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": [ "Find Laplacian." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "laplacian_finder = LaplacianFinder()" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "((7207, 7207), (7207, 7207))" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stiffness_matrix, mass_matrix = laplacian_finder(mesh)\n", "\n", "(stiffness_matrix.shape, mass_matrix.shape)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Tip: different algorithms can be used by changing `which` (check docs for possibilities)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Syntax sugar:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "((7207, 7207), (7207, 7207))" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mesh.laplacian.find(laplacian_finder=laplacian_finder, recompute=False)\n", "\n", "(mesh.laplacian.stiffness_matrix.shape, mesh.laplacian.mass_matrix.shape)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Further reading\n", "\n", "* [How to compute the mesh Laplacian spectrum?](./02_mesh_laplacian_spectrum.ipynb)" ] } ], "metadata": { "kernelspec": { "display_name": "venv", "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.11.8" } }, "nbformat": 4, "nbformat_minor": 2 }