Skip to main content

Fast implementation of the Fast Hadamard Transform (FHT)

Project description

Fast Fast Hadamard Transform (unofficial)

The FFHT-unofficial library is a more recent python wrapper of the original FFHT library. The latter provides a heavily optimized C99 implementation of the Fast Hadamard Transform. For more informations, see https://github.com/FALCONN-LIB/FFHT.

The problem of the original FFHT library is that it relies on numpy C API which is no longer supported by recent numpy versions, it looks like no further updates are planned. One of the contributors did fix the issue in the fork https://github.com/dnbaker/FFHT by using pybind11 instead, and added a 2D support using parallélisation with OpenMP. However, there were still minor compilation problems, thus the library could not be installed from source.

The only objective of the FFHT-unofficial library is to distribute a slightly corrected version of the latter fork. In a nutshell, the problem was solved only by adding the argument extra_link_args=['-fopenmp'] in the initialization of the Extension class in setup.py.

Installation

Installing the library requires a modern c++ compiler like gcc, as well as the python libraries numpy and pybind11. To install FFHT-unofficial from PYPI, run the lines below.

pip install --upgrade pip
pip install ffht-unofficial

Usage

Within a python script, the FFHT-unofficial library is imported by import ffht. The library contains two functions, ffht.fht_ and ffht.fht, respectively for the inplace and the out of place FHT. Note that those functions do not actually compute the Hadamard transform of a vector, but a scaled version. In order to obtain the isometric Hadamard transform, the results must by a factor 2**(-d/2), where 2**d is the dimension of that data to transform. The code below provides an example of usage of the ffht functions for 1dim and 2dim numpy array. One can also see the example.py file.

import numpy as np
import ffht

# a 1dim array
x1 = np.random.normal(size=(2**20))

# a 2dim array
x2 = np.random.normal(size=(3, 2**20))

# out of place FHT
y1 = ffht.fht(x1)
y1 /= 2**(20/2) # rescale to obtain an isometry
y2 = ffht.fht(x2)
y2 /= 2**(20/2)

# in place FHT
ffht.fht_(x1)
x1 /= 2**(20/2)
ffht.fht_(x2)
x2 /= 2**(20/2)

Project details


Download files

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

Source Distribution

FFHT-unofficial-0.3.tar.gz (52.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

FFHT_unofficial-0.3-cp39-cp39-manylinux1_x86_64.whl (87.9 kB view details)

Uploaded CPython 3.9

File details

Details for the file FFHT-unofficial-0.3.tar.gz.

File metadata

  • Download URL: FFHT-unofficial-0.3.tar.gz
  • Upload date:
  • Size: 52.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for FFHT-unofficial-0.3.tar.gz
Algorithm Hash digest
SHA256 fca77acd9a0580390965a08e36ca5124e13239e0238eaf2ad07de927f8fead14
MD5 9f0bec248bec0fcb2399cd2b029fccdf
BLAKE2b-256 d89ee384f7128645766c9842f7f82211946f164ef685b6cebfbc678e7985c0b1

See more details on using hashes here.

File details

Details for the file FFHT_unofficial-0.3-cp39-cp39-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for FFHT_unofficial-0.3-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 918b5e8055471f18579084746d11c8e21b9069d1dfcf9b670bd0fa0e8c4825b7
MD5 0b739c459f4e8731768fa7ef987da1dd
BLAKE2b-256 5c4cfb24e80c43bf880d28bd6b17076a6abec86714dd4b477b441694a83947f7

See more details on using hashes here.

Supported by

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