Classes | |
struct | cv::softdouble |
struct | cv::softfloat |
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:
- Construction from signed and unsigned 32-bit and 64 integers, float/double or raw binary representation
- Conversions between each other, to float or double and to int using cvRound, cvTrunc, cvFloor, cvCeil or a bunch of saturate_cast functions
- Add, subtract, multiply, divide, remainder, square root, FMA with absolute precision
- Comparison operations
- Explicit sign, exponent and significand manipulation through get/set methods, number state indicators (isInf, isNan, isSubnormal)
- Type-specific constants like eps, minimum/maximum value, best pi approximation, etc.
- min(), max(), abs(), exp(), log() and pow() functions
Function Documentation
◆ softdouble() [1/7]
|
inline |
#include <opencv2/core/softfloat.hpp>
Default constructor.
◆ softdouble() [2/7]
|
inlineexplicit |
#include <opencv2/core/softfloat.hpp>
Construct from double.
◆ softdouble() [3/7]
|
explicit |
#include <opencv2/core/softfloat.hpp>
◆ softdouble() [4/7]
|
explicit |
#include <opencv2/core/softfloat.hpp>
◆ softdouble() [5/7]
|
inline |
#include <opencv2/core/softfloat.hpp>
Copy constructor.
◆ softdouble() [6/7]
|
explicit |
#include <opencv2/core/softfloat.hpp>
Construct from integer.
◆ softdouble() [7/7]
|
explicit |
#include <opencv2/core/softfloat.hpp>
◆ softfloat() [1/7]
|
inline |
#include <opencv2/core/softfloat.hpp>
Default constructor.
◆ softfloat() [2/7]
|
inlineexplicit |
#include <opencv2/core/softfloat.hpp>
Construct from float.
◆ softfloat() [3/7]
|
explicit |
#include <opencv2/core/softfloat.hpp>
◆ softfloat() [4/7]
|
explicit |
#include <opencv2/core/softfloat.hpp>
◆ softfloat() [5/7]
|
inline |
#include <opencv2/core/softfloat.hpp>
Copy constructor.
◆ softfloat() [6/7]
|
explicit |
#include <opencv2/core/softfloat.hpp>
Construct from integer.
◆ softfloat() [7/7]
|
explicit |
#include <opencv2/core/softfloat.hpp>
◆ abs() [1/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
◆ abs() [2/2]
#include <opencv2/core/softfloat.hpp>
Absolute value.
◆ cbrt()
#include <opencv2/core/softfloat.hpp>
Cube root.
Special cases:
- cbrt(NaN) is NaN
- cbrt(+/-Inf) is +/-Inf
◆ cos()
softdouble cv::cos | ( | const softdouble & | a | ) |
#include <opencv2/core/softfloat.hpp>
Cosine.
Special cases:
- cos(Inf) or cos(NaN) is NaN
- cos(x) == +/- 1 when cos(x) is close to +/- 1
◆ eps() [1/2]
|
inlinestatic |
#include <opencv2/core/softfloat.hpp>
Difference between 1 and next representable value.
◆ eps() [2/2]
|
inlinestatic |
#include <opencv2/core/softfloat.hpp>
Difference between 1 and next representable value.
◆ exp() [1/2]
softdouble cv::exp | ( | const softdouble & | a | ) |
#include <opencv2/core/softfloat.hpp>
◆ exp() [2/2]
#include <opencv2/core/softfloat.hpp>
Exponent.
Special cases:
- exp(NaN) is NaN
- exp(-Inf) == 0
- exp(+Inf) == +Inf
◆ fromRaw() [1/2]
#include <opencv2/core/softfloat.hpp>
Construct from raw.
Builds new value from raw binary representation
◆ fromRaw() [2/2]
|
inlinestatic |
#include <opencv2/core/softfloat.hpp>
Construct from raw.
Builds new value from raw binary representation
◆ getExp() [1/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
Get 0-based exponent.
◆ getExp() [2/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
Get 0-based exponent.
◆ getFrac() [1/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
Get a fraction part.
Returns a number 1 <= x < 2 with the same significand
◆ getFrac() [2/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
Get a fraction part.
Returns a number 1 <= x < 2 with the same significand
◆ getSign() [1/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
Get sign bit.
◆ getSign() [2/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
Get sign bit.
◆ inf() [1/2]
|
inlinestatic |
#include <opencv2/core/softfloat.hpp>
Positive infinity constant.
◆ inf() [2/2]
|
inlinestatic |
#include <opencv2/core/softfloat.hpp>
Positive infinity constant.
◆ isInf() [1/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
Inf state indicator.
◆ isInf() [2/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
Inf state indicator.
◆ isNaN() [1/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
NaN state indicator.
◆ isNaN() [2/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
NaN state indicator.
◆ isSubnormal() [1/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
Subnormal number indicator.
◆ isSubnormal() [2/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
Subnormal number indicator.
◆ log() [1/2]
softdouble cv::log | ( | const softdouble & | a | ) |
#include <opencv2/core/softfloat.hpp>
◆ log() [2/2]
#include <opencv2/core/softfloat.hpp>
Natural logarithm.
Special cases:
- log(NaN), log(x < 0) are NaN
- log(0) == -Inf
◆ max() [1/4]
|
inlinestatic |
#include <opencv2/core/softfloat.hpp>
Biggest finite value.
◆ max() [2/4]
|
inlinestatic |
#include <opencv2/core/softfloat.hpp>
Biggest finite value.
◆ max() [3/4]
|
inline |
#include <opencv2/core/softfloat.hpp>
◆ max() [4/4]
#include <opencv2/core/softfloat.hpp>
◆ min() [1/4]
|
inlinestatic |
#include <opencv2/core/softfloat.hpp>
Smallest normalized value.
◆ min() [2/4]
|
inlinestatic |
#include <opencv2/core/softfloat.hpp>
Smallest normalized value.
◆ min() [3/4]
|
inline |
#include <opencv2/core/softfloat.hpp>
◆ min() [4/4]
#include <opencv2/core/softfloat.hpp>
Min and Max functions.
◆ mulAdd() [1/2]
softdouble cv::mulAdd | ( | const softdouble & | a, |
const softdouble & | b, | ||
const softdouble & | c | ||
) |
#include <opencv2/core/softfloat.hpp>
◆ mulAdd() [2/2]
#include <opencv2/core/softfloat.hpp>
Fused Multiplication and Addition.
Computes (a*b)+c with single rounding
◆ nan() [1/2]
|
inlinestatic |
#include <opencv2/core/softfloat.hpp>
Default NaN constant.
◆ nan() [2/2]
|
inlinestatic |
#include <opencv2/core/softfloat.hpp>
Default NaN constant.
◆ one() [1/2]
|
inlinestatic |
#include <opencv2/core/softfloat.hpp>
One constant.
◆ one() [2/2]
|
inlinestatic |
#include <opencv2/core/softfloat.hpp>
One constant.
◆ operator double()
|
inline |
#include <opencv2/core/softfloat.hpp>
◆ operator float()
|
inline |
#include <opencv2/core/softfloat.hpp>
◆ operator softdouble()
cv::softfloat::operator softdouble | ( | ) | const |
#include <opencv2/core/softfloat.hpp>
Type casts
◆ operator softfloat()
cv::softdouble::operator softfloat | ( | ) | const |
#include <opencv2/core/softfloat.hpp>
Type casts
◆ operator!=() [1/2]
bool cv::softdouble::operator!= | ( | const softdouble & | ) | const |
#include <opencv2/core/softfloat.hpp>
◆ operator!=() [2/2]
bool cv::softfloat::operator!= | ( | const softfloat & | ) | const |
#include <opencv2/core/softfloat.hpp>
◆ operator%() [1/2]
softdouble cv::softdouble::operator% | ( | const softdouble & | ) | const |
#include <opencv2/core/softfloat.hpp>
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.
◆ operator%() [2/2]
#include <opencv2/core/softfloat.hpp>
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.
◆ operator%=() [1/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
◆ operator%=() [2/2]
#include <opencv2/core/softfloat.hpp>
◆ operator*() [1/2]
softdouble cv::softdouble::operator* | ( | const softdouble & | ) | const |
#include <opencv2/core/softfloat.hpp>
◆ operator*() [2/2]
#include <opencv2/core/softfloat.hpp>
◆ operator*=() [1/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
◆ operator*=() [2/2]
#include <opencv2/core/softfloat.hpp>
◆ operator+() [1/2]
softdouble cv::softdouble::operator+ | ( | const softdouble & | ) | const |
#include <opencv2/core/softfloat.hpp>
Basic arithmetics.
◆ operator+() [2/2]
#include <opencv2/core/softfloat.hpp>
Basic arithmetics.
◆ operator+=() [1/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
◆ operator+=() [2/2]
#include <opencv2/core/softfloat.hpp>
◆ operator-() [1/4]
|
inline |
#include <opencv2/core/softfloat.hpp>
◆ operator-() [2/4]
|
inline |
#include <opencv2/core/softfloat.hpp>
◆ operator-() [3/4]
softdouble cv::softdouble::operator- | ( | const softdouble & | ) | const |
#include <opencv2/core/softfloat.hpp>
◆ operator-() [4/4]
#include <opencv2/core/softfloat.hpp>
◆ operator-=() [1/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
◆ operator-=() [2/2]
#include <opencv2/core/softfloat.hpp>
◆ operator/() [1/2]
softdouble cv::softdouble::operator/ | ( | const softdouble & | ) | const |
#include <opencv2/core/softfloat.hpp>
◆ operator/() [2/2]
#include <opencv2/core/softfloat.hpp>
◆ operator/=() [1/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
◆ operator/=() [2/2]
#include <opencv2/core/softfloat.hpp>
◆ operator<() [1/2]
bool cv::softdouble::operator< | ( | const softdouble & | ) | const |
#include <opencv2/core/softfloat.hpp>
◆ operator<() [2/2]
bool cv::softfloat::operator< | ( | const softfloat & | ) | const |
#include <opencv2/core/softfloat.hpp>
◆ operator<=() [1/2]
bool cv::softdouble::operator<= | ( | const softdouble & | ) | const |
#include <opencv2/core/softfloat.hpp>
◆ operator<=() [2/2]
bool cv::softfloat::operator<= | ( | const softfloat & | ) | const |
#include <opencv2/core/softfloat.hpp>
◆ operator=() [1/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
Assign constructor.
◆ operator=() [2/2]
#include <opencv2/core/softfloat.hpp>
Assign constructor.
◆ operator==() [1/2]
bool cv::softdouble::operator== | ( | const softdouble & | ) | const |
#include <opencv2/core/softfloat.hpp>
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
◆ operator==() [2/2]
bool cv::softfloat::operator== | ( | const softfloat & | ) | const |
#include <opencv2/core/softfloat.hpp>
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
◆ operator>() [1/2]
bool cv::softdouble::operator> | ( | const softdouble & | ) | const |
#include <opencv2/core/softfloat.hpp>
◆ operator>() [2/2]
bool cv::softfloat::operator> | ( | const softfloat & | ) | const |
#include <opencv2/core/softfloat.hpp>
◆ operator>=() [1/2]
bool cv::softdouble::operator>= | ( | const softdouble & | ) | const |
#include <opencv2/core/softfloat.hpp>
◆ operator>=() [2/2]
bool cv::softfloat::operator>= | ( | const softfloat & | ) | const |
#include <opencv2/core/softfloat.hpp>
◆ pi() [1/2]
|
inlinestatic |
#include <opencv2/core/softfloat.hpp>
Correct pi approximation.
◆ pi() [2/2]
|
inlinestatic |
#include <opencv2/core/softfloat.hpp>
Correct pi approximation.
◆ pow() [1/2]
softdouble cv::pow | ( | const softdouble & | a, |
const softdouble & | b | ||
) |
#include <opencv2/core/softfloat.hpp>
◆ pow() [2/2]
#include <opencv2/core/softfloat.hpp>
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
◆ saturate_cast() [1/2]
|
inlinestatic |
#include <opencv2/core/softfloat.hpp>
◆ saturate_cast() [2/2]
#include <opencv2/core/softfloat.hpp>
Saturate casts.
◆ saturate_cast< int64_t >() [1/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
◆ saturate_cast< int64_t >() [2/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
◆ saturate_cast< schar >() [1/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
◆ saturate_cast< schar >() [2/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
◆ saturate_cast< short >() [1/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
◆ saturate_cast< short >() [2/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
◆ saturate_cast< uchar >() [1/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
◆ saturate_cast< uchar >() [2/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
◆ saturate_cast< uint64_t >() [1/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
◆ saturate_cast< uint64_t >() [2/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
◆ saturate_cast< unsigned >() [1/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
◆ saturate_cast< unsigned >() [2/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
Saturate cast to unsigned integer and unsigned long long integer We intentionally do not clip negative numbers, to make -1 become 0xffffffff etc.
◆ saturate_cast< ushort >() [1/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
◆ saturate_cast< ushort >() [2/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
◆ setExp() [1/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
Construct a copy with new 0-based exponent.
◆ setExp() [2/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
Construct a copy with new 0-based exponent.
◆ setFrac() [1/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
Construct a copy with provided significand.
Constructs a copy of a number with significand taken from parameter
◆ setFrac() [2/2]
#include <opencv2/core/softfloat.hpp>
Construct a copy with provided significand.
Constructs a copy of a number with significand taken from parameter
◆ setSign() [1/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
Construct a copy with new sign bit.
◆ setSign() [2/2]
|
inline |
#include <opencv2/core/softfloat.hpp>
Construct a copy with new sign bit.
◆ sin()
softdouble cv::sin | ( | const softdouble & | a | ) |
#include <opencv2/core/softfloat.hpp>
Sine.
Special cases:
- sin(Inf) or sin(NaN) is NaN
- sin(x) == x when sin(x) is close to zero
◆ sqrt() [1/2]
softdouble cv::sqrt | ( | const softdouble & | a | ) |
#include <opencv2/core/softfloat.hpp>
◆ sqrt() [2/2]
#include <opencv2/core/softfloat.hpp>
Square root.
◆ zero() [1/2]
|
inlinestatic |
#include <opencv2/core/softfloat.hpp>
Zero constant.
◆ zero() [2/2]
|
inlinestatic |
#include <opencv2/core/softfloat.hpp>
Zero constant.
Variable Documentation
◆ v [1/2]
uint32_t cv::softfloat::v |
◆ v [2/2]
uint64_t cv::softdouble::v |