class Posit

Declaration

template <class T,
          int totalbits,
          int esbits,
          class FT,
          posit::PositSpec positspec>
class Posit { /* full declaration omitted */ };

Description

Posit value type Stores the posit in the LSB part of the holding type T as signed integer

Operations are implemented at 4 levels: - Level 1: direct manipulation of bit representation - Level 2: decoding of the posit in its componentds (s,k,E,F) - Level 3: decoding and manipulation of the posit in full exponent form (s,X,f) - Level 4: using the posit backend (softfloat by Unpacked, FPU by BackendFloat, fixed point by BackendFixed)

Declared at: include/posit.h:193

Templates

T
the holding type that has to be signed due to complement 2 sign method
int totalbits
the significant bits of posit stored in T right aligned. Due to the 2 complement scheme the MSB bits are extension of the sign
int esbits
the size of the exponent
FT
the backend type that can be: unsigned integer for softposit, float/double for emulation, generic Backend, e.g. fixed point
posit::PositSpec positspec
specifies the number capabilities

Member Variables

public T v
public static Logger<double> _logger

Method Overview

Methods

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>(
    posit::Posit::single_tag t,
    uint32_t p)

Description

Construct the Posit with its backend direct initialization

Declared at: include/posit.h:296

Parameters

posit::Posit::single_tag t
uint32_t p

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>(unsigned long long i)

Description

Convert the long integer i to Posit

Declared at: include/posit.h:336

Parameters

unsigned long long i
64-bit unsigned integer value

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>(unsigned long i)

Description

Convert the long integer i to Posit

Declared at: include/posit.h:331

Parameters

unsigned long i
64-bit unsigned integer value

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>(unsigned int i)

Description

Convert the long integer i to Posit

Declared at: include/posit.h:326

Parameters

unsigned int i
32-bit unsigned integer value

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>(long long i)

Description

Convert the long integer i to Posit

Declared at: include/posit.h:321

Parameters

long long i
64-bit signed integer value

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>(long i)

Description

Convert the long integer i to Posit

Declared at: include/posit.h:316

Parameters

long i
64-bit signed integer value

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>(int i)

Description

Convert the integer i to Posit

Declared at: include/posit.h:311

Parameters

int i
32-bit signed integer value

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>(
    posit::Posit::BackendT u)

Description

Construct the Posit from its backend BackendT

Declared at: include/posit.h:305

Parameters

posit::Posit::BackendT u

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>(
    posit::Posit::UnpackedPosit u)

Description

Construct the Posit using its Unpacked from (s, R,E,F)

Declared at: include/posit.h:302

Parameters

posit::Posit::UnpackedPosit u

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>(posit::Posit::DeepInit,
                           T x)

Description

Construct the Posit passing the holding type x

Declared at: include/posit.h:299

Parameters

posit::Posit::DeepInit
T x

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>()

Description

empty constructor

Declared at: include/posit.h:293

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>(std::complex<float> c)

Declared at: include/posit.h:337

Parameters

std::complex<float> c

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>(std::complex<double> c)

Declared at: include/posit.h:338

Parameters

std::complex<double> c

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>(float f)

Description

Convert the float number f to Posit

Declared at: include/posit.h:343

Parameters

float f
32-bit float value

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>(double d)

Description

Convert the double number d to Posit

Declared at: include/posit.h:348

Parameters

double d

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>
abs() const

Description

Compute the absolute value of the Posit (L1)

Declared at: include/posit.h:407

Returns

New Posit containing the absolute value of the initial Posit

constexpr uint32_t as_float_bin() const

Declared at: include/posit.h:569

constexpr bool comparable(
    const Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>& u) const

Description

Returns true if the two Posits are comparable

Declared at: include/posit.h:278

Parameters

const Posit<T, totalbits, esbits, FT, positspec>& u

template <class It1, class It2>
static constexpr Posit<T,
                       totalbits,
                       esbits,
                       FT,
                       positspec>
dot(It1 begin1, It2 begin2, int N)

Description

computes the dot product between posit values vectors

Declared at: include/posit.h:563

Templates

It1
type of first iterator
It2
type of second iterator

Parameters

It1 begin1
first iterator
It2 begin2
second iterator
int N
length of vectors

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>
elu() const

Description

Pseudo-ELU without decoding the Posit; only works for 0-bit exponent posits

Declared at: include/posit.h:632

Returns

Posit

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>
fastELU() const

Description

Pseudo-ELU without decoding the Posit; only works for 0-bit exponent posits

Declared at: include/posit.h:655

Returns

Posit

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>
fastTanh() const

Description

Pseudo-Hyperbolic Tangent without decoding the Posit; only works for 0-bit exponent posits

Declared at: include/posit.h:649

Returns

Posit

template <class XFT>
static constexpr Posit<T,
                       totalbits,
                       esbits,
                       FT,
                       positspec>
from_floatval(typename XFT::holder_t x)

Description

Build the Posit from a floating point value expressed as the representing integer

Declared at: include/posit.h:379

Templates

XFT
floating point trait type

Parameters

typename XFT::holder_t x
floating point representing integer

Returns

Posit built from the floating point conversion

static constexpr Posit<T,
                       totalbits,
                       esbits,
                       FT,
                       positspec>
from_sraw(T x)

Description

Build Posit using its representing signed integer x

Declared at: include/posit.h:384

Parameters

T x
signed integer representation of the Posit

Returns

Posit built using its signed integer representation

static constexpr Posit<T,
                       totalbits,
                       esbits,
                       FT,
                       positspec>
from_uraw(typename PT::POSIT_UTYPE x)

Description

Build Posit using its representing unsigned integer x

Declared at: include/posit.h:389

Parameters

typename PT::POSIT_UTYPE x
unsigned integer representation of the Posit

Returns

Posit built using its unsigned integer representation

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>
half() const

Description

returns half (Level 1)

Declared at: include/posit.h:226

static constexpr Posit<T,
                       totalbits,
                       esbits,
                       FT,
                       positspec>
inf()

Declared at: include/posit.h:531

static constexpr Posit<T,
                       totalbits,
                       esbits,
                       FT,
                       positspec>
infinity()

Declared at: include/posit.h:539

constexpr bool is_infinity() const

Description

returns true if it is any infinity

Declared at: include/posit.h:422

constexpr bool is_nan() const

Description

returns true if the value is NaN

Declared at: include/posit.h:420

constexpr bool is_one() const

Description

returns true for one

Declared at: include/posit.h:426

constexpr bool is_sphere_range() const

Description

Check if the Posit is in in the unit interval [-1,1] (Level 1)

Declared at: include/posit.h:440

Returns

True if Posit in the interval [-1,1]

constexpr bool is_unitary_range() const

Description

Check if the Posit is in in the unit interval [0,1] (Level 1)

Declared at: include/posit.h:436

Returns

True if Posit in the interval [0,1]

constexpr bool is_zero() const

Description

returns true for zero

Declared at: include/posit.h:424

static constexpr Posit<T,
                       totalbits,
                       esbits,
                       FT,
                       positspec>
ldexp(const Posit<T,
                  totalbits,
                  esbits,
                  FT,
                  positspec>& u,
      int exp)

Declared at: include/posit.h:290

Parameters

const Posit<T, totalbits, esbits, FT, positspec>& u
int exp

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>
log() const

Description

Natural logarithm of the Posit

Declared at: include/posit.h:612

Returns

Posit

template <class VV>
void logValue(VV v)

Declared at: include/posit.h:202

Templates

VV

Parameters

VV v

static constexpr Posit<T,
                       totalbits,
                       esbits,
                       FT,
                       positspec>
lowest()

Declared at: include/posit.h:536

static constexpr Posit<T,
                       totalbits,
                       esbits,
                       FT,
                       positspec>
max()

Declared at: include/posit.h:534

static constexpr Posit<T,
                       totalbits,
                       esbits,
                       FT,
                       positspec>
min()

Declared at: include/posit.h:535

static constexpr Posit<T,
                       totalbits,
                       esbits,
                       FT,
                       positspec>
mone()

Declared at: include/posit.h:542

static constexpr Posit<T,
                       totalbits,
                       esbits,
                       FT,
                       positspec>
nan()

Declared at: include/posit.h:538

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>
neg() const

Description

Compute the sign opposition of the Posit (L1)

Declared at: include/posit.h:411

Returns

New Posit with the opposite sign of the initial Posit

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>
next() const

Description

Returns next (anti-clockwise in the Posit ring) regular Posit number

Declared at: include/posit.h:432

static constexpr Posit<T,
                       totalbits,
                       esbits,
                       FT,
                       positspec>
ninf()

Declared at: include/posit.h:533

static constexpr Posit<T,
                       totalbits,
                       esbits,
                       FT,
                       positspec>
one()

Declared at: include/posit.h:540

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>
one_minus_ur() const

Description

1's complement without decoding the posit; only works for 0-bit exponent posits in the unary interval

Declared at: include/posit.h:661

Returns

Posit

static constexpr Posit<T,
                       totalbits,
                       esbits,
                       FT,
                       positspec>
onehalf()

Declared at: include/posit.h:543

constexpr bool operator bool() const

Declared at: include/posit.h:590

constexpr std::complex<float> operator complex()
    const

Declared at: include/posit.h:591

constexpr std::complex<float> operator complex()
    const

Declared at: include/posit.h:591

constexpr double operator double() const

Declared at: include/posit.h:577

constexpr float operator float() const

Declared at: include/posit.h:576

constexpr int operator int() const

Declared at: include/posit.h:580

constexpr long operator long() const

Declared at: include/posit.h:581

constexpr long long operator long long() const

Declared at: include/posit.h:582

constexpr short operator short() const

Declared at: include/posit.h:579

constexpr signed char operator signed char() const

Declared at: include/posit.h:594

constexpr posit::Posit::BackendT
operator typename conditional<
    is_posit_backend<FT>::value,
    type - parameter - 0 - 3,
    typename conditional<
        std::is_floating_point<FT>::value,
        BackendFloat<type - parameter - 0 - 3>,
        Unpacked<type - parameter - 0 - 3,
                 typename PositTrait<
                     type - parameter - 0 - 0,
                     totalbits,
                     esbits,
                     positspec>::exponenttype> >::
        type>::type() const

Declared at: include/posit.h:573

constexpr unsigned char operator unsigned char()
    const

Declared at: include/posit.h:593

constexpr unsigned int operator unsigned int()
    const

Declared at: include/posit.h:585

constexpr unsigned long operator unsigned long()
    const

Declared at: include/posit.h:586

constexpr unsigned long long
operator unsigned long long() const

Declared at: include/posit.h:587

constexpr unsigned short operator unsigned short()
    const

Declared at: include/posit.h:584

static constexpr Posit<T,
                       totalbits,
                       esbits,
                       FT,
                       positspec>
pack_low(posit::Posit::UnpackedPosit)

Description

transform from unpacled low (Level 2) to bit representation (Level 1)

Declared at: include/posit.h:235

Parameters

posit::Posit::UnpackedPosit

static constexpr Posit<T,
                       totalbits,
                       esbits,
                       FT,
                       positspec>
pinf()

Declared at: include/posit.h:532

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>
prev() const

Description

Returns previous (clockwise in the Posit ring) regular Posit number

Declared at: include/posit.h:429

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>
pseudosigmoid() const

Description

Pseudosigmoid without decoding the Posit; only works for 0-bit exponent posits

Declared at: include/posit.h:616

Returns

Posit

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>
pseudosigmoidalt() const

Description

Alternative Pseudosigmoid without decoding the Posit; only works for 0-bit exponent posits

Declared at: include/posit.h:624

Returns

Posit

Posit<T, totalbits, esbits, FT, positspec>
pseudosoftplus() const

Description

Pseudo-SoftPlus without decoding the Posit; only works for 0-bit exponent posits

Declared at: include/posit.h:636

Returns

Posit

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>
pseudotanh(int k) const

Description

Pseudo-generalized TANH without decoding the Posit; only works for 0-bit exponent posits

Declared at: include/posit.h:640

Parameters

int k

Returns

Posit

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>
pseudotanh() const

Description

Pseudo-Hyperbolic Tangent without decoding the Posit; only works for 0-bit exponent posits

Declared at: include/posit.h:644

Returns

Posit

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>
reciprocate() const

Description

Returns 1/x as Level 1. Special Cases: zero should give positive infinity, if present, nan otherwise; nan should be nan, if present; +inf/-inf should give zero, if present; before0,after0 should give infinity, if present.

Declared at: include/posit.h:524

Returns

constexpr Posit

constexpr posit::Posit::BackendT to_backend()
    const

Description

Unpack the Posit to its backend type BackendT

Declared at: include/posit.h:401

Returns

An instance of the BackendT initialized with the current posit value

template <class PT2>
PT2 to_posit()

Description

Convert the posit to another posit described by PT2

Declared at: include/posit.h:249

Templates

PT2
is a posit type declaration (e.g. posit::Posit <int8 _t, 8 , 0, uint_fast32_t, posit::PositSpec::WithNan>)

template <class QuireT>
QuireT to_quire()

Description

Convert the posit to a backend fixed point for quire-like accumulation

Declared at: include/posit.h:267

Templates

QuireT
is the quire type (e.g. uint64_t)

constexpr T to_sraw() const

Description

Returns Posit integer representation

Declared at: include/posit.h:393

Returns

Posit integer field v

constexpr typename PT::POSIT_UTYPE to_uraw() const

Description

Returns Posit unsigned integer representation

Declared at: include/posit.h:397

Returns

Posit integer field v as unsigned type

constexpr Posit<T,
                totalbits,
                esbits,
                FT,
                positspec>
twice() const

Description

returns half (Level 1)

Declared at: include/posit.h:229

static constexpr Posit<T,
                       totalbits,
                       esbits,
                       FT,
                       positspec>
two()

Declared at: include/posit.h:541

constexpr posit::Posit::UnpackedPosit unpack_low()
    const

Description

transform from bit representation (Level 1) to unpacked low (Level 2)

Declared at: include/posit.h:232

static constexpr posit::Posit::UnpackedPosit
unpacked_full2low(posit::Posit::BackendT x)

Description

transform from Level 2 to Level 4

Declared at: include/posit.h:241

Parameters

posit::Posit::BackendT x

static constexpr posit::Posit::BackendT
unpacked_low2full(posit::Posit::UnpackedPosit x)

Description

transform from Level 2 to Level 4

Declared at: include/posit.h:238

Parameters

posit::Posit::UnpackedPosit x

static constexpr Posit<T,
                       totalbits,
                       esbits,
                       FT,
                       positspec>
zero()

Declared at: include/posit.h:530