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, and quire16
Installation
On most linux distros with CPython 2.7, 3.4, 3.5, 3.6, or 3.7, sfpy should work out of the box:
pip install sfpy
Under the hood, sfpy uses Cython to create bindings for the softposit and softfloat C libraries. The building instructions are tested on Ubuntu 16.04 - for other platforms they may need some adaptation.
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distributions
Close
Hashes for sfpy-0.4.2-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8db150d338d3adbd21bea2d494f17b150b3845bcd90f9f0b710911ffd589524 |
|
MD5 | 5c9ff1c68785c3cda2a9479cf858ef5f |
|
BLAKE2b-256 | 6b43a2c9647a08327f46246668babfabac7d4aec981959f6a3929a28bca16fe8 |
Close
Hashes for sfpy-0.4.2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b191effde19ef578f68b11e3d7412c55fff755abf88aba68ee3d3fa35e6ea39a |
|
MD5 | ed0f8bae99613e817cab2254b0a4d961 |
|
BLAKE2b-256 | 30442054c574b76fd3654d52dc95542029f5f052df49bd74474c8ad7e62ee9eb |
Close
Hashes for sfpy-0.4.2-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 411d0d0642054fb32b91fa778dae7ab67eab9809d74f3704883610955feb19ef |
|
MD5 | bd7d52cf3ef39ecadd4b54ae6471aac0 |
|
BLAKE2b-256 | 14866fa9707b8a992a10f432533163530f83cc603478d617adb3b452dcb4ed73 |
Close
Hashes for sfpy-0.4.2-cp34-cp34m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7ab63845f82dc0d7a2fdce367bf236b573ee8aace977cd47df95523c35638ff |
|
MD5 | 5a2bdf2ed703d5981fe2da00555b6485 |
|
BLAKE2b-256 | 8bb5febeabe9c1da06dabe04a5e7571c47ccb6dd47afb7fabe67f5210f9af300 |
Close
Hashes for sfpy-0.4.2-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 308bf2c57b9012b322c267ef8cc469948e58261117ebafda85e7686aa278cdfe |
|
MD5 | e50311bc81469521abd69e5de97becdf |
|
BLAKE2b-256 | b252788a9d92d9fdd3576b0fd8afb9058b6119e1be0fbaa1d02d6a89c8fb080f |
Close
Hashes for sfpy-0.4.2-cp27-cp27m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c73474c7f24f4862f79c4a3f6ea68d0b98ecdc8684c1128b7f1194345e9afbf |
|
MD5 | 5a48e12d1d2a80a62b7b13d699d01715 |
|
BLAKE2b-256 | 67e0e2a3e4dadd895d3bfe68c1a0f920e983d47d352d8bf1d42e52bf85403d4d |