阿贝尔群的计算。
项目描述
abelian 是一个Python库,用于对基本局部紧致的阿贝尔群(LCAs)进行计算。基本LCAs是R、Z、T = R/Z、Z_n 以及这些群的直和。傅里叶变换在这些群上定义。使用 abelian,可以通过群之间的同态在基本LCAs上采样、周期化和执行傅里叶分析。
类和方法
以下列出了最重要的类。软件还包含许多未列出的其他函数和方法。
- LCA 类表示基本LCAs,即R、Z、T = R/Z、Z_n 以及这些群的直和。
基本方法:恒等LCA、直和、等价、同构、元素投影、庞特里亚金对偶。
- HomLCA 类表示LCAs之间的同态。
基本方法:恒等同态、零同态、等价、组合、评估、堆叠、逐元素操作、核、余核、像、余像、对偶(伴随)同态。
- LCAFunc 类表示从LCAs到复数的函数。
基本方法:评估、组合、平移(平移)、反推、前推、点运算符(即加法)。
示例
以下示例展示了六边形格子的傅里叶分析。
我们创建了一个在R^2上的高斯函数和一个用于采样的同态。
from abelian import LCA, HomLCA, LCAFunc, voronoi
from math import exp, pi, sqrt
Z = LCA(orders = [0], discrete = [True])
R = LCA(orders = [0], discrete = [False])
# Create the Gaussian function on R^2
function = LCAFunc(lambda x: exp(-pi*sum(j**2 for j in x)), domain = R**2)
# Create an hexagonal sampling homomorphism (lattice on R^2)
phi = HomLCA([[1, 1/2], [0, sqrt(3)/2]], source = Z**2, target = R**2)
phi = phi * (1/7) # Downcale the hexagon
function_sampled = function.pullback(phi)
接下来我们逼近高斯函数的二维积分。
# Approximate the two dimensional integral of the Gaussian
scaling_factor = phi.A.det()
integral_sum = 0
for element in phi.source.elements_by_maxnorm(list(range(20))):
integral_sum += function_sampled(element)
print(integral_sum * scaling_factor) # 0.999999997457763
我们使用FFT来逼近高斯函数的傅里叶变换。
# Sample, periodize and take DFT of the Gaussian
phi_p = HomLCA([[10, 0], [0, 10]], source = Z**2, target = Z**2)
periodized = function_sampled.pushforward(phi_p.cokernel())
dual_func = periodized.dft()
# Interpret the output of the DFT on R^2
phi_periodize_ann = phi_p.annihilator()
# Compute a Voronoi transversal function, interpret on R^2
sigma = voronoi(phi.dual(), norm_p=2)
factor = phi_p.A.det() * scaling_factor
total_error = 0
for element in dual_func.domain.elements_by_maxnorm():
value = dual_func(element)
coords_on_R = sigma(phi_periodize_ann(element))
# The Gaussian is invariant under Fourier transformation, so we can
# compare the error using the analytical expression
true_val = function(coords_on_R)
approximated_val = abs(value)
total_error += abs(true_val - approximated_val*factor)
assert total_error < 10e-15
请参阅 文档 了解更多示例和信息。
项目详情
下载文件
下载适用于您平台文件的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源代码发行版
本发行版没有可用的源代码分发文件。请参阅有关生成分发存档的教程。
构建分发版
abelian-1.0.1-py2.py3-none-any.whl (42.0 kB 查看哈希值)