softfloat and softposit in python
Project description
sfpy
softfloat and softposit in Python
- support for softfloat float16, float32, and float64
- support for softposit posit8, quire8, posit16, quire16, posit32, and quire32
Installation
On most linux distros, sfpy should work out of the box:
pip install sfpy
Binary wheels (compatible with manylinux1) are available for CPython 2.7, 3.5, 3.6, and 3.7.
Under the hood, sfpy uses Cython to create bindings for the softposit and softfloat C libraries. These building instructions are tested on Ubuntu 18.04 - for other platforms they may need some adaptation. The cythonized C and compiled static libraries (.a), as well as necessary headers, are included in the source releases; installing these does not require Cython.
Demo
>>> import sfpy
>>> from sfpy import *
>>> a, b = Float16(1.3), Float16(1.4)
>>> a * b - a / b
Float16(0.89208984375)
>>> sfpy.float.flag_get_inexact()
True
>>> a += b
>>> a
Float16(2.69921875)
>>>
>>> x, y = Posit16(3.0), Posit16(3)
>>> x
Posit16(3.0)
>>> x.bits
22528
>>> y
Posit16(2.9802322387695312e-08)
>>> y.bits
3
>>> x * y
Posit16(8.940696716308594e-08)
>>> acc = Posit16(0)
>>> for i in range(10000):
... acc = acc.fma(x, y)
...
>>> acc
Posit16(1.9073486328125e-06)
>>> acc.bits
24
>>> q = Quire16(0)
>>> for i in range(10000):
... q.iqma(x, y)
...
>>> q
Quire16(0.00089263916015625)
>>> q.bits
64424509440000
>>> q.to_posit()
Posit16(0.00089263916015625)
>>> q.to_posit().bits
490
Building
See BUILDING.
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
Built Distributions
File details
Details for the file sfpy-0.6.0.tar.gz
.
File metadata
- Download URL: sfpy-0.6.0.tar.gz
- Upload date:
- Size: 343.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9e6643dbc51d0c091fb6a0cf998612adf6c45be8ea699fe7af53abb91d194ca |
|
MD5 | 062a4d6092f977675503892b1f5c753c |
|
BLAKE2b-256 | 849bcb03a3909761acf1acfd756b43ec121c665fbaa66bcfd41b74aedbb5176e |
File details
Details for the file sfpy-0.6.0-cp37-cp37m-manylinux1_x86_64.whl
.
File metadata
- Download URL: sfpy-0.6.0-cp37-cp37m-manylinux1_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f6e45c355bcd0e0d7af7d834c610cf5ff279114103826c1cfb4e97a3d634b51 |
|
MD5 | 059d2ba2d2f60645b988b44f3632d9fa |
|
BLAKE2b-256 | 76080aa8788d07eb7b808dee9ab8b9d3384f46d711dcd2d115d8da893e0c5a89 |
File details
Details for the file sfpy-0.6.0-cp36-cp36m-manylinux1_x86_64.whl
.
File metadata
- Download URL: sfpy-0.6.0-cp36-cp36m-manylinux1_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85bb68a3837830e2ce99963d4ca7bf62d508357986ba78d531cc9f86cbe5b8a8 |
|
MD5 | 4433ef3aaf0539ca1c087db6a2ed5594 |
|
BLAKE2b-256 | ac857de8b9b566dfe5597e81cb3e60a22f0091531c57c4894b55167103c6f81a |
File details
Details for the file sfpy-0.6.0-cp35-cp35m-manylinux1_x86_64.whl
.
File metadata
- Download URL: sfpy-0.6.0-cp35-cp35m-manylinux1_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65ed2eb92dccde52480e1b51f47283f6e553d3c83f2727558992dfb7b868a6ef |
|
MD5 | 3543c6a656e8c19bdc7011915d996626 |
|
BLAKE2b-256 | 418d453be0935d80ab5eea518980c77c3d9c5b2c617ff8074b52ae3e1b15334c |
File details
Details for the file sfpy-0.6.0-cp34-cp34m-manylinux1_x86_64.whl
.
File metadata
- Download URL: sfpy-0.6.0-cp34-cp34m-manylinux1_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.4m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39dc569ab5afd9eae026568532e9daa935b2599149a031b369e2d0c115465597 |
|
MD5 | 0aa73b04c58af462ad04ecce87b343c0 |
|
BLAKE2b-256 | 2a78084f318b011caf254eaa144a47339e464f62b136da37f4505a65588e65ee |
File details
Details for the file sfpy-0.6.0-cp27-cp27mu-manylinux1_x86_64.whl
.
File metadata
- Download URL: sfpy-0.6.0-cp27-cp27mu-manylinux1_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 2.7mu
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c5c6693a27998497177e1c7846bb10e722b710aa647a77fb2324bc11447edd3 |
|
MD5 | f20adb2919975096c6eeabde52ef84ea |
|
BLAKE2b-256 | e2543946f40b31ab9095185c293b42db234a2ef7569b87cec7ce0196e8fcc51e |
File details
Details for the file sfpy-0.6.0-cp27-cp27m-manylinux1_x86_64.whl
.
File metadata
- Download URL: sfpy-0.6.0-cp27-cp27m-manylinux1_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 2.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6927550d91788f4ad13c84a794fe82fc05335b76834d51411be1dd8b952450e8 |
|
MD5 | 983f629183ac19e3ba29283bff4a231a |
|
BLAKE2b-256 | 41d207f3c1a124403859372c159e8d98624b4cbb678811db8237c151bf190547 |