OpenCV  4.1.0
Open Source Computer Vision
Classes | Functions | Variables

Classes

struct  cv::softdouble
 
struct  cv::softfloat
 

Functions

 cv::softdouble::softdouble ()
 Default constructor.
 
 cv::softdouble::softdouble (const softdouble &c)
 Copy constructor.
 
 cv::softdouble::softdouble (const uint32_t)
 Construct from integer.
 
 cv::softdouble::softdouble (const uint64_t)
 
 cv::softdouble::softdouble (const int32_t)
 
 cv::softdouble::softdouble (const int64_t)
 
 cv::softdouble::softdouble (const double a)
 Construct from double.
 
 cv::softfloat::softfloat ()
 Default constructor.
 
 cv::softfloat::softfloat (const softfloat &c)
 Copy constructor.
 
 cv::softfloat::softfloat (const uint32_t)
 Construct from integer.
 
 cv::softfloat::softfloat (const uint64_t)
 
 cv::softfloat::softfloat (const int32_t)
 
 cv::softfloat::softfloat (const int64_t)
 
 cv::softfloat::softfloat (const float a)
 Construct from float.
 
softfloat cv::abs (softfloat a)
 Absolute value.
 
softdouble cv::abs (softdouble a)
 
softfloat cv::cbrt (const softfloat &a)
 Cube root.
 
softdouble cv::cos (const softdouble &a)
 Cosine.
 
static softfloat cv::softfloat::eps ()
 Difference between 1 and next representable value.
 
static softdouble cv::softdouble::eps ()
 Difference between 1 and next representable value.
 
softfloat cv::exp (const softfloat &a)
 Exponent.
 
softdouble cv::exp (const softdouble &a)
 
static const softfloat cv::softfloat::fromRaw (const uint32_t a)
 Construct from raw.
 
static softdouble cv::softdouble::fromRaw (const uint64_t a)
 Construct from raw.
 
int cv::softfloat::getExp () const
 Get 0-based exponent.
 
int cv::softdouble::getExp () const
 Get 0-based exponent.
 
softfloat cv::softfloat::getFrac () const
 Get a fraction part.
 
softdouble cv::softdouble::getFrac () const
 Get a fraction part.
 
bool cv::softfloat::getSign () const
 Get sign bit.
 
bool cv::softdouble::getSign () const
 Get sign bit.
 
static softfloat cv::softfloat::inf ()
 Positive infinity constant.
 
static softdouble cv::softdouble::inf ()
 Positive infinity constant.
 
bool cv::softfloat::isInf () const
 Inf state indicator.
 
bool cv::softdouble::isInf () const
 Inf state indicator.
 
bool cv::softfloat::isNaN () const
 NaN state indicator.
 
bool cv::softdouble::isNaN () const
 NaN state indicator.
 
bool cv::softfloat::isSubnormal () const
 Subnormal number indicator.
 
bool cv::softdouble::isSubnormal () const
 Subnormal number indicator.
 
softfloat cv::log (const softfloat &a)
 Natural logarithm.
 
softdouble cv::log (const softdouble &a)
 
static softfloat cv::softfloat::max ()
 Biggest finite value.
 
static softdouble cv::softdouble::max ()
 Biggest finite value.
 
softfloat cv::max (const softfloat &a, const softfloat &b)
 
softdouble cv::max (const softdouble &a, const softdouble &b)
 
static softfloat cv::softfloat::min ()
 Smallest normalized value.
 
static softdouble cv::softdouble::min ()
 Smallest normalized value.
 
softfloat cv::min (const softfloat &a, const softfloat &b)
 Min and Max functions.
 
softdouble cv::min (const softdouble &a, const softdouble &b)
 
softfloat cv::mulAdd (const softfloat &a, const softfloat &b, const softfloat &c)
 Fused Multiplication and Addition.
 
softdouble cv::mulAdd (const softdouble &a, const softdouble &b, const softdouble &c)
 
static softfloat cv::softfloat::nan ()
 Default NaN constant.
 
static softdouble cv::softdouble::nan ()
 Default NaN constant.
 
static softfloat cv::softfloat::one ()
 One constant.
 
static softdouble cv::softdouble::one ()
 One constant.
 
 cv::softdouble::operator double () const
 
 cv::softfloat::operator float () const
 
 cv::softfloat::operator softdouble () const
 Type casts.
 
 cv::softdouble::operator softfloat () const
 Type casts.
 
bool cv::softfloat::operator!= (const softfloat &) const
 
bool cv::softdouble::operator!= (const softdouble &) const
 
softfloat cv::softfloat::operator% (const softfloat &) const
 Remainder operator.
 
softdouble cv::softdouble::operator% (const softdouble &) const
 Remainder operator.
 
softfloat & cv::softfloat::operator%= (const softfloat &a)
 
softdouble & cv::softdouble::operator%= (const softdouble &a)
 
softfloat cv::softfloat::operator* (const softfloat &) const
 
softdouble cv::softdouble::operator* (const softdouble &) const
 
softfloat & cv::softfloat::operator*= (const softfloat &a)
 
softdouble & cv::softdouble::operator*= (const softdouble &a)
 
softfloat cv::softfloat::operator+ (const softfloat &) const
 Basic arithmetics.
 
softdouble cv::softdouble::operator+ (const softdouble &) const
 Basic arithmetics.
 
softfloat & cv::softfloat::operator+= (const softfloat &a)
 
softdouble & cv::softdouble::operator+= (const softdouble &a)
 
softfloat cv::softfloat::operator- (const softfloat &) const
 
softfloat cv::softfloat::operator- () const
 
softdouble cv::softdouble::operator- (const softdouble &) const
 
softdouble cv::softdouble::operator- () const
 
softfloat & cv::softfloat::operator-= (const softfloat &a)
 
softdouble & cv::softdouble::operator-= (const softdouble &a)
 
softfloat cv::softfloat::operator/ (const softfloat &) const
 
softdouble cv::softdouble::operator/ (const softdouble &) const
 
softfloat & cv::softfloat::operator/= (const softfloat &a)
 
softdouble & cv::softdouble::operator/= (const softdouble &a)
 
bool cv::softfloat::operator< (const softfloat &) const
 
bool cv::softdouble::operator< (const softdouble &) const
 
bool cv::softfloat::operator<= (const softfloat &) const
 
bool cv::softdouble::operator<= (const softdouble &) const
 
softfloat & cv::softfloat::operator= (const softfloat &c)
 Assign constructor.
 
softdouble & cv::softdouble::operator= (const softdouble &c)
 Assign constructor.
 
bool cv::softfloat::operator== (const softfloat &) const
 Comparison operations.
 
bool cv::softdouble::operator== (const softdouble &) const
 Comparison operations.
 
bool cv::softfloat::operator> (const softfloat &) const
 
bool cv::softdouble::operator> (const softdouble &) const
 
bool cv::softfloat::operator>= (const softfloat &) const
 
bool cv::softdouble::operator>= (const softdouble &) const
 
static softfloat cv::softfloat::pi ()
 Correct pi approximation.
 
static softdouble cv::softdouble::pi ()
 Correct pi approximation.
 
softfloat cv::pow (const softfloat &a, const softfloat &b)
 Raising to the power.
 
softdouble cv::pow (const softdouble &a, const softdouble &b)
 
template<typename _Tp >
static _Tp cv::saturate_cast (softfloat a)
 Saturate casts.
 
template<typename _Tp >
static _Tp cv::saturate_cast (softdouble a)
 
template<>
int64_t cv::saturate_cast< int64_t > (softfloat a)
 
template<>
int64_t cv::saturate_cast< int64_t > (softdouble a)
 
template<>
schar cv::saturate_cast< schar > (softfloat a)
 
template<>
schar cv::saturate_cast< schar > (softdouble a)
 
template<>
short cv::saturate_cast< short > (softfloat a)
 
template<>
short cv::saturate_cast< short > (softdouble a)
 
template<>
uchar cv::saturate_cast< uchar > (softfloat a)
 
template<>
uchar cv::saturate_cast< uchar > (softdouble a)
 
template<>
uint64_t cv::saturate_cast< uint64_t > (softfloat a)
 
template<>
uint64_t cv::saturate_cast< uint64_t > (softdouble a)
 
template<>
unsigned cv::saturate_cast< unsigned > (softfloat a)
 Saturate cast to unsigned integer and unsigned long long integer We intentionally do not clip negative numbers, to make -1 become 0xffffffff etc.
 
template<>
unsigned cv::saturate_cast< unsigned > (softdouble a)
 
template<>
ushort cv::saturate_cast< ushort > (softfloat a)
 
template<>
ushort cv::saturate_cast< ushort > (softdouble a)
 
softfloat cv::softfloat::setExp (int e) const
 Construct a copy with new 0-based exponent.
 
softdouble cv::softdouble::setExp (int e) const
 Construct a copy with new 0-based exponent.
 
softfloat cv::softfloat::setFrac (const softfloat &s) const
 Construct a copy with provided significand.
 
softdouble cv::softdouble::setFrac (const softdouble &s) const
 Construct a copy with provided significand.
 
softfloat cv::softfloat::setSign (bool sign) const
 Construct a copy with new sign bit.
 
softdouble cv::softdouble::setSign (bool sign) const
 Construct a copy with new sign bit.
 
softdouble cv::sin (const softdouble &a)
 Sine.
 
softfloat cv::sqrt (const softfloat &a)
 Square root.
 
softdouble cv::sqrt (const softdouble &a)
 
static softfloat cv::softfloat::zero ()
 Zero constant.
 
static softdouble cv::softdouble::zero ()
 Zero constant.
 

Variables

uint32_t cv::softfloat::v
 
uint64_t cv::softdouble::v
 

Detailed Description

SoftFloat is a software implementation of floating-point calculations according to IEEE 754 standard. All calculations are done in integers, that's why they are machine-independent and bit-exact. This library can be useful in accuracy-critical parts like look-up tables generation, tests, etc. OpenCV contains a subset of SoftFloat partially rewritten to C++.

Types

There are two basic types: softfloat and softdouble. These types are binary compatible with float and double types respectively and support conversions to/from them. Other types from original SoftFloat library like fp16 or fp128 were thrown away as well as quiet/signaling NaN support, on-the-fly rounding mode switch and exception flags (though exceptions can be implemented in the future).

Operations

Both types support the following:

Function Documentation

cv::softdouble::softdouble ( )
inline

Default constructor.

cv::softdouble::softdouble ( const softdouble c)
inline

Copy constructor.

cv::softdouble::softdouble ( const uint32_t  )
explicit

Construct from integer.

cv::softdouble::softdouble ( const uint64_t  )
explicit
cv::softdouble::softdouble ( const int32_t  )
explicit
cv::softdouble::softdouble ( const int64_t  )
explicit
cv::softdouble::softdouble ( const double  a)
inlineexplicit

Construct from double.

cv::softfloat::softfloat ( )
inline

Default constructor.

cv::softfloat::softfloat ( const softfloat c)
inline

Copy constructor.

cv::softfloat::softfloat ( const uint32_t  )
explicit

Construct from integer.

cv::softfloat::softfloat ( const uint64_t  )
explicit
cv::softfloat::softfloat ( const int32_t  )
explicit
cv::softfloat::softfloat ( const int64_t  )
explicit
cv::softfloat::softfloat ( const float  a)
inlineexplicit

Construct from float.

softfloat cv::abs ( softfloat  a)
inline

Absolute value.

softdouble cv::abs ( softdouble  a)
inline
softfloat cv::cbrt ( const softfloat &  a)

Cube root.

Special cases:

  • cbrt(NaN) is NaN
  • cbrt(+/-Inf) is +/-Inf
softdouble cv::cos ( const softdouble &  a)
static softfloat cv::softfloat::eps ( )
inlinestatic

Difference between 1 and next representable value.

static softdouble cv::softdouble::eps ( )
inlinestatic

Difference between 1 and next representable value.

softfloat cv::exp ( const softfloat &  a)

Exponent.

Special cases:

  • exp(NaN) is NaN
  • exp(-Inf) == 0
  • exp(+Inf) == +Inf
Examples:
samples/cpp/polar_transforms.cpp.
softdouble cv::exp ( const softdouble &  a)
static const softfloat cv::softfloat::fromRaw ( const uint32_t  a)
inlinestatic

Construct from raw.

Builds new value from raw binary representation

static softdouble cv::softdouble::fromRaw ( const uint64_t  a)
inlinestatic

Construct from raw.

Builds new value from raw binary representation

int cv::softfloat::getExp ( ) const
inline

Get 0-based exponent.

int cv::softdouble::getExp ( ) const
inline

Get 0-based exponent.

softfloat cv::softfloat::getFrac ( ) const
inline

Get a fraction part.

Returns a number 1 <= x < 2 with the same significand

softdouble cv::softdouble::getFrac ( ) const
inline

Get a fraction part.

Returns a number 1 <= x < 2 with the same significand

bool cv::softfloat::getSign ( ) const
inline

Get sign bit.

bool cv::softdouble::getSign ( ) const
inline

Get sign bit.

static softfloat cv::softfloat::inf ( )
inlinestatic

Positive infinity constant.

static softdouble cv::softdouble::inf ( )
inlinestatic

Positive infinity constant.

bool cv::softfloat::isInf ( ) const
inline

Inf state indicator.

bool cv::softdouble::isInf ( ) const
inline

Inf state indicator.

bool cv::softfloat::isNaN ( ) const
inline

NaN state indicator.

bool cv::softdouble::isNaN ( ) const
inline

NaN state indicator.

bool cv::softfloat::isSubnormal ( ) const
inline

Subnormal number indicator.

bool cv::softdouble::isSubnormal ( ) const
inline

Subnormal number indicator.

softfloat cv::log ( const softfloat &  a)

Natural logarithm.

Special cases:

  • log(NaN), log(x < 0) are NaN
  • log(0) == -Inf
Examples:
samples/cpp/polar_transforms.cpp, and samples/cpp/stitching_detailed.cpp.
softdouble cv::log ( const softdouble &  a)
static softfloat cv::softfloat::max ( )
inlinestatic

Biggest finite value.

static softdouble cv::softdouble::max ( )
inlinestatic

Biggest finite value.

softfloat cv::max ( const softfloat &  a,
const softfloat &  b 
)
inline
softdouble cv::max ( const softdouble &  a,
const softdouble &  b 
)
inline
static softfloat cv::softfloat::min ( )
inlinestatic

Smallest normalized value.

static softdouble cv::softdouble::min ( )
inlinestatic

Smallest normalized value.

softfloat cv::min ( const softfloat &  a,
const softfloat &  b 
)
inline
softdouble cv::min ( const softdouble &  a,
const softdouble &  b 
)
inline
softfloat cv::mulAdd ( const softfloat &  a,
const softfloat &  b,
const softfloat &  c 
)

Fused Multiplication and Addition.

Computes (a*b)+c with single rounding

softdouble cv::mulAdd ( const softdouble &  a,
const softdouble &  b,
const softdouble &  c 
)
static softfloat cv::softfloat::nan ( )
inlinestatic

Default NaN constant.

static softdouble cv::softdouble::nan ( )
inlinestatic

Default NaN constant.

static softfloat cv::softfloat::one ( )
inlinestatic

One constant.

static softdouble cv::softdouble::one ( )
inlinestatic

One constant.

cv::softdouble::operator double ( ) const
inline
cv::softfloat::operator float ( ) const
inline
cv::softfloat::operator softdouble ( ) const

Type casts.

cv::softdouble::operator softfloat ( ) const

Type casts.

bool cv::softfloat::operator!= ( const softfloat ) const
bool cv::softdouble::operator!= ( const softdouble ) const
softfloat cv::softfloat::operator% ( const softfloat ) const

Remainder operator.

A quote from original SoftFloat manual:

The IEEE Standard remainder operation computes the value a - n * b, where n is the integer closest to a / b. If a / b is exactly halfway between two integers, n is the even integer closest to a / b. The IEEE Standard’s remainder operation is always exact and so requires no rounding. Depending on the relative magnitudes of the operands, the remainder functions can take considerably longer to execute than the other SoftFloat functions. This is an inherent characteristic of the remainder operation itself and is not a flaw in the SoftFloat implementation.

softdouble cv::softdouble::operator% ( const softdouble ) const

Remainder operator.

A quote from original SoftFloat manual:

The IEEE Standard remainder operation computes the value a - n * b, where n is the integer closest to a / b. If a / b is exactly halfway between two integers, n is the even integer closest to a / b. The IEEE Standard’s remainder operation is always exact and so requires no rounding. Depending on the relative magnitudes of the operands, the remainder functions can take considerably longer to execute than the other SoftFloat functions. This is an inherent characteristic of the remainder operation itself and is not a flaw in the SoftFloat implementation.

softfloat& cv::softfloat::operator%= ( const softfloat a)
inline
softdouble& cv::softdouble::operator%= ( const softdouble a)
inline
softfloat cv::softfloat::operator* ( const softfloat ) const
softdouble cv::softdouble::operator* ( const softdouble ) const
softfloat& cv::softfloat::operator*= ( const softfloat a)
inline
softdouble& cv::softdouble::operator*= ( const softdouble a)
inline
softfloat cv::softfloat::operator+ ( const softfloat ) const

Basic arithmetics.

softdouble cv::softdouble::operator+ ( const softdouble ) const

Basic arithmetics.

softfloat& cv::softfloat::operator+= ( const softfloat a)
inline
softdouble& cv::softdouble::operator+= ( const softdouble a)
inline
softfloat cv::softfloat::operator- ( const softfloat ) const
softfloat cv::softfloat::operator- ( ) const
inline
softdouble cv::softdouble::operator- ( const softdouble ) const
softdouble cv::softdouble::operator- ( ) const
inline
softfloat& cv::softfloat::operator-= ( const softfloat a)
inline
softdouble& cv::softdouble::operator-= ( const softdouble a)
inline
softfloat cv::softfloat::operator/ ( const softfloat ) const
softdouble cv::softdouble::operator/ ( const softdouble ) const
softfloat& cv::softfloat::operator/= ( const softfloat a)
inline
softdouble& cv::softdouble::operator/= ( const softdouble a)
inline
bool cv::softfloat::operator< ( const softfloat ) const
bool cv::softdouble::operator< ( const softdouble ) const
bool cv::softfloat::operator<= ( const softfloat ) const
bool cv::softdouble::operator<= ( const softdouble ) const
softfloat& cv::softfloat::operator= ( const softfloat c)
inline

Assign constructor.

softdouble& cv::softdouble::operator= ( const softdouble c)
inline

Assign constructor.

bool cv::softfloat::operator== ( const softfloat ) const

Comparison operations.

  • Any operation with NaN produces false
    • The only exception is when x is NaN: x != y for any y.
  • Positive and negative zeros are equal
bool cv::softdouble::operator== ( const softdouble ) const

Comparison operations.

  • Any operation with NaN produces false
    • The only exception is when x is NaN: x != y for any y.
  • Positive and negative zeros are equal
bool cv::softfloat::operator> ( const softfloat ) const
bool cv::softdouble::operator> ( const softdouble ) const
bool cv::softfloat::operator>= ( const softfloat ) const
bool cv::softdouble::operator>= ( const softdouble ) const
static softfloat cv::softfloat::pi ( )
inlinestatic

Correct pi approximation.

static softdouble cv::softdouble::pi ( )
inlinestatic

Correct pi approximation.

softfloat cv::pow ( const softfloat &  a,
const softfloat &  b 
)

Raising to the power.

Special cases:

  • x**NaN is NaN for any x
  • ( |x| == 1 )**Inf is NaN
  • ( |x| > 1 )**+Inf or ( |x| < 1 )**-Inf is +Inf
  • ( |x| > 1 )**-Inf or ( |x| < 1 )**+Inf is 0
  • x ** 0 == 1 for any x
  • x ** 1 == 1 for any x
  • NaN ** y is NaN for any other y
  • Inf**(y < 0) == 0
  • Inf ** y is +Inf for any other y
  • (x < 0)**y is NaN for any other y if x can't be correctly rounded to integer
  • 0 ** 0 == 1
  • 0 ** (y < 0) is +Inf
  • 0 ** (y > 0) is 0
Examples:
samples/cpp/distrans.cpp.
softdouble cv::pow ( const softdouble &  a,
const softdouble &  b 
)
template<typename _Tp >
static _Tp cv::saturate_cast ( softfloat  a)
inlinestatic

Saturate casts.

template<typename _Tp >
static _Tp cv::saturate_cast ( softdouble  a)
inlinestatic
template<>
int64_t cv::saturate_cast< int64_t > ( softfloat  a)
inline
template<>
int64_t cv::saturate_cast< int64_t > ( softdouble  a)
inline
template<>
schar cv::saturate_cast< schar > ( softfloat  a)
inline
template<>
schar cv::saturate_cast< schar > ( softdouble  a)
inline
template<>
short cv::saturate_cast< short > ( softfloat  a)
inline
template<>
short cv::saturate_cast< short > ( softdouble  a)
inline
template<>
uchar cv::saturate_cast< uchar > ( softfloat  a)
inline
template<>
uchar cv::saturate_cast< uchar > ( softdouble  a)
inline
template<>
uint64_t cv::saturate_cast< uint64_t > ( softfloat  a)
inline
template<>
uint64_t cv::saturate_cast< uint64_t > ( softdouble  a)
inline
template<>
unsigned cv::saturate_cast< unsigned > ( softfloat  a)
inline

Saturate cast to unsigned integer and unsigned long long integer We intentionally do not clip negative numbers, to make -1 become 0xffffffff etc.

template<>
unsigned cv::saturate_cast< unsigned > ( softdouble  a)
inline
template<>
ushort cv::saturate_cast< ushort > ( softfloat  a)
inline
template<>
ushort cv::saturate_cast< ushort > ( softdouble  a)
inline
softfloat cv::softfloat::setExp ( int  e) const
inline

Construct a copy with new 0-based exponent.

softdouble cv::softdouble::setExp ( int  e) const
inline

Construct a copy with new 0-based exponent.

softfloat cv::softfloat::setFrac ( const softfloat s) const
inline

Construct a copy with provided significand.

Constructs a copy of a number with significand taken from parameter

softdouble cv::softdouble::setFrac ( const softdouble s) const
inline

Construct a copy with provided significand.

Constructs a copy of a number with significand taken from parameter

softfloat cv::softfloat::setSign ( bool  sign) const
inline

Construct a copy with new sign bit.

softdouble cv::softdouble::setSign ( bool  sign) const
inline

Construct a copy with new sign bit.

softdouble cv::sin ( const softdouble &  a)
softfloat cv::sqrt ( const softfloat &  a)
softdouble cv::sqrt ( const softdouble &  a)
static softfloat cv::softfloat::zero ( )
inlinestatic

Zero constant.

static softdouble cv::softdouble::zero ( )
inlinestatic

Zero constant.

Variable Documentation

uint32_t cv::softfloat::v
uint64_t cv::softdouble::v