4. Riemannian Metric and Global Inner Product¶
Throughout the paper, we introduce several metrics and inner products defined on functions, vector fields, and (k)-forms. These objects are represented by the classes Function, VectorField, and Form, all of which inherit from the parent class Tensor. Each instance of DiffusionGeometry provides a unified interface to access the Riemannian metric for any tensor via the method g, as well as the pointwise norm through pointwise_norm. The following is a minimal working example.
In [1]:
# This example showcases the unifyied API for the metrics without visualising them
import sys
import os
sys.path.append(os.path.abspath('..')) # Add parent directory to path
from diffusion_geometry import DiffusionGeometry
import numpy as np
from plotly.subplots import make_subplots
# from generate_data import gen_2d_data
# Generate random points
data = np.random.rand(200, 3)
dg = DiffusionGeometry.from_point_cloud(data)
# Create two functions
f1 = dg.function_space.zeros()
f2 = dg.function_space.zeros()
# Create two vector fields
v1 = dg.vector_field_space.zeros()
v2 = dg.vector_field_space.zeros()
# Create two 2-forms
a1 = dg.form_space(2).zeros()
a2 = dg.form_space(2).zeros()
# Calculate the Riemannian metric
g_functions = dg.g(f1, f2)
g_vector_fields = dg.g(v1, v2)
g_2_forms = dg.g(a1, a2)
# Calculate the point-wise norm
pointwise_norm_functions = dg.pointwise_norm(f1)
pointwise_norm_vector_fields = dg.pointwise_norm(v1)
pointwise_norm_2_forms = dg.pointwise_norm(a1)
# Calculate the inner product which is the integral
# ⟨a, b⟩ = ∫ g(a, b) dμ
inner_product_functions = dg.inner(f1, f2)
inner_product_vector_fields = dg.inner(v1, v2)
inner_product_2_forms = dg.inner(a1, a2)
# Calculate the norm
norm_functions = dg.norm(f1)
norm_vector_fields = dg.norm(v1)
norm_2_forms = dg.norm(a1)