# 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)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/alexandre-pasco/FFHT-unofficial",
"name": "FFHT-unofficial",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "fast Fourier Hadamard transform butterfly",
"author": "Alexandre Pasco",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/d8/9e/e384f7128645766c9842f7f82211946f164ef685b6cebfbc678e7985c0b1/FFHT-unofficial-0.3.tar.gz",
"platform": null,
"description": "# Fast Fast Hadamard Transform (unofficial)\n\nThe 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.\n\nThe 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\u00e9lisation with OpenMP. However, there were still minor compilation problems, thus the library could not be installed from source.\n\nThe 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`.\n\n# Installation\n\nInstalling 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.\n\n```\npip install --upgrade pip\npip install ffht-unofficial\n```\n\n# Usage\n\nWithin 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.\n\n\n```\nimport numpy as np\nimport ffht\n\n# a 1dim array\nx1 = np.random.normal(size=(2**20))\n\n# a 2dim array\nx2 = np.random.normal(size=(3, 2**20))\n\n# out of place FHT\ny1 = ffht.fht(x1)\ny1 /= 2**(20/2) # rescale to obtain an isometry\ny2 = ffht.fht(x2)\ny2 /= 2**(20/2)\n\n# in place FHT\nffht.fht_(x1)\nx1 /= 2**(20/2)\nffht.fht_(x2)\nx2 /= 2**(20/2)\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Fast implementation of the Fast Hadamard Transform (FHT)",
"version": "0.3",
"project_urls": {
"Homepage": "https://github.com/alexandre-pasco/FFHT-unofficial"
},
"split_keywords": [
"fast",
"fourier",
"hadamard",
"transform",
"butterfly"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5c4cfb24e80c43bf880d28bd6b17076a6abec86714dd4b477b441694a83947f7",
"md5": "0b739c459f4e8731768fa7ef987da1dd",
"sha256": "918b5e8055471f18579084746d11c8e21b9069d1dfcf9b670bd0fa0e8c4825b7"
},
"downloads": -1,
"filename": "FFHT_unofficial-0.3-cp39-cp39-manylinux1_x86_64.whl",
"has_sig": false,
"md5_digest": "0b739c459f4e8731768fa7ef987da1dd",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": null,
"size": 87900,
"upload_time": "2023-05-25T09:33:35",
"upload_time_iso_8601": "2023-05-25T09:33:35.154327Z",
"url": "https://files.pythonhosted.org/packages/5c/4c/fb24e80c43bf880d28bd6b17076a6abec86714dd4b477b441694a83947f7/FFHT_unofficial-0.3-cp39-cp39-manylinux1_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d89ee384f7128645766c9842f7f82211946f164ef685b6cebfbc678e7985c0b1",
"md5": "9f0bec248bec0fcb2399cd2b029fccdf",
"sha256": "fca77acd9a0580390965a08e36ca5124e13239e0238eaf2ad07de927f8fead14"
},
"downloads": -1,
"filename": "FFHT-unofficial-0.3.tar.gz",
"has_sig": false,
"md5_digest": "9f0bec248bec0fcb2399cd2b029fccdf",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 52707,
"upload_time": "2023-05-25T09:33:38",
"upload_time_iso_8601": "2023-05-25T09:33:38.028704Z",
"url": "https://files.pythonhosted.org/packages/d8/9e/e384f7128645766c9842f7f82211946f164ef685b6cebfbc678e7985c0b1/FFHT-unofficial-0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-25 09:33:38",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "alexandre-pasco",
"github_project": "FFHT-unofficial",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "numpy",
"specs": []
},
{
"name": "pybind11",
"specs": []
}
],
"lcname": "ffht-unofficial"
}