Skip to main content

Computations on abelian groups.

Project description

Documentation Status

abelian is a Python library for computations on elementary locally compact abelian groups (LCAs). The elementary LCAs are the groups R, Z, T = R/Z, Z_n and direct sums of these. The Fourier transformation is defined on these groups. With abelian it is possible to sample, periodize and perform Fourier analysis on elementary LCAs using homomorphisms between groups.

http://tommyodland.com/abelian/intro_figure_75.png

Classes and methods

  • The LCA class represents elementary LCAs, i.e. R, Z, T = R/Z, Z_n and direct sums of these groups.
    • Fundamental methods: identity LCA, direct sums, equality, isomorphic, element projection, Pontryagin dual.

  • The HomLCA class represents homomorphisms between LCAs.
    • Fundamental methods: identity morphism, zero morphism, equality, composition, evaluation, stacking, element-wise operations, kernel, cokernel, image, coimage, dual (adjoint) morphism.

  • The LCAFunc class represents functions from LCAs to complex numbers.
    • Fundamental methods: evaluation, composition, shift (translation), pullback, pushforward, point-wise operators (i.e. addition).

Example

http://tommyodland.com/abelian/fourier_hexa_33.png

We create a Gaussian on R^2 and a homomorphism for sampling.

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)

Next we approximate the two-dimensional integral of the Gaussian.

# 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

We use the FFT to move approximate the Fourier transform of the Gaussian.

# 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

Please see the documentation for more examples and information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

abelian-1.0.0-py3.6.egg (86.7 kB view details)

Uploaded Source

abelian-1.0.0-py2.py3-none-any.whl (41.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file abelian-1.0.0-py3.6.egg.

File metadata

  • Download URL: abelian-1.0.0-py3.6.egg
  • Upload date:
  • Size: 86.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for abelian-1.0.0-py3.6.egg
Algorithm Hash digest
SHA256 f72b6116c23bf4903b709b523915fcf1687395fec7dad258aa0802e55489b06b
MD5 db8d9dd2f69a96d5e167e99d63780d14
BLAKE2b-256 09fbade2a2985b9fd9bb2d103b2cd4de60856b31b4d8e7ae4c0dcc193b7b6685

See more details on using hashes here.

File details

Details for the file abelian-1.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for abelian-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ec17c6c8fff71d0cbad0c7dc351a124d1748cdae125deb66eb0533531c64abb9
MD5 6a9c094eb3c0cd423bd3c307d8d943c3
BLAKE2b-256 185c2d88b60340b4dcb796818afe650295461e4327aaee75230efa572f165aaa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page