softposit-rs
Rust port of SoftPosit repository.
Such types are supported now:
- P32E2 or P32: 32-bit posit with exponent size ES=2;
- P16E1 or P16: 16-bit posit with ES=1;
- P8E0 or P8: 8-bit posit without exponent bits.
Initial support of generic types PxE1{N} and PxE2{N}. Requires rust 1.51.
Examples
Convert from f64, Add
use P32;
Quire
Each Posit type has correspondent Quire type (Q32, Q16, Q8).
These types support AddAssign
and SubAssign
operations.
For example:
use ;
// c == 12.3*0.4 - 6.3*8.4 == -48;
Math
Math functions, like trigonomentic, are partially implemented for P32E2 type.
For complex computations use num::Complex
type.
Linear algebra
You can also use matrix operations, defined in nalgebra crate
by using linalg
feature:
use P32;
use ;
type DMatrix = ;
Benchmarking
Type | Operation | i3-2310M @ 2.10GHz | i5-3470 @ 3.20GHz |
---|---|---|---|
P32E2 | + | 47 MPOPS | 82 MPOPS |
- | 45 MPOPS | 83 MPOPS | |
* | 56 MPOPS | 99 MPOPS | |
/ | 25 MPOPS | 42 MPOPS | |
√⎺⎺ | 48 MPOPS | 92 MPOPS | |
round | 89 MPOPS | 159 MPOPS |