|
sparrow 1.4.0
C++20 idiomatic APIs for the Apache Arrow Columnar Format
|
Classes | |
| struct | binary_t |
| Tag type for binary construction. More... | |
| struct | bits |
| Type traits for floating-point bits. More... | |
| struct | bits< const T > |
| struct | bits< const volatile T > |
| struct | bits< double > |
| Unsigned integer of (at least) 64 bits width. More... | |
| struct | bits< float > |
| Unsigned integer of (at least) 32 bits width. More... | |
| struct | bits< volatile T > |
| struct | bool_type |
| Helper for tag dispatching. More... | |
| struct | conditional |
| Conditional type. More... | |
| struct | f31 |
| Class for 1.31 unsigned floating-point computation. More... | |
| class | false_type |
| struct | half_caster |
| Helper class for half casts. More... | |
| struct | half_caster< half, half, R > |
| struct | half_caster< half, U, R > |
| struct | half_caster< T, half, R > |
| struct | is_float |
| Type traits for floating-point types. More... | |
| class | true_type |
Concepts | |
| concept | arithmetic |
Typedefs | |
| using | uint16 = std::uint_least16_t |
| Unsigned integer of (at least) 16 bits width. | |
| using | uint32 = std::uint_fast32_t |
| Fastest unsigned integer of (at least) 32 bits width. | |
| using | int32 = std::int_fast32_t |
| Fastest signed integer of (at least) 32 bits width. | |
| template<class T> | |
| using | bits_t = typename bits<T>::type |
Functions | |
Implementation defined classification and arithmetic | |
| template<class T> | |
| bool | builtin_isinf (T arg) |
| Check for infinity. | |
| template<class T> | |
| bool | builtin_isnan (T arg) |
| Check for NaN. | |
| template<class T> | |
| bool | builtin_signbit (T arg) |
| Check sign. | |
| uint32 | sign_mask (uint32 arg) |
| Platform-independent sign mask. | |
| uint32 | arithmetic_shift (uint32 arg, int i) |
| Platform-independent arithmetic right shift. | |
Error handling | |
| int & | errflags () |
| Internal exception flags. | |
| void | raise (int HALF_UNUSED_NOERR(flags), bool HALF_UNUSED_NOERR(cond)=true) |
| Raise floating-point exception. | |
| constexpr_NOERR bool | compsignal (unsigned int x, unsigned int y) |
| Check and signal for any NaN. | |
| constexpr_NOERR unsigned int | signal (unsigned int nan) |
| Signal and silence signaling NaN. | |
| constexpr_NOERR unsigned int | signal (unsigned int x, unsigned int y) |
| Signal and silence signaling NaNs. | |
| constexpr_NOERR unsigned int | signal (unsigned int x, unsigned int y, unsigned int z) |
| Signal and silence signaling NaNs. | |
| constexpr_NOERR unsigned int | select (unsigned int x, unsigned int HALF_UNUSED_NOERR(y)) |
| Select value or signaling NaN. | |
| constexpr_NOERR unsigned int | invalid () |
| Raise domain error and return NaN. | |
| constexpr_NOERR unsigned int | pole (unsigned int sign=0) |
| Raise pole error and return infinity. | |
| constexpr_NOERR unsigned int | check_underflow (unsigned int arg) |
| Check value for underflow. | |
Conversion and rounding | |
| template<std::float_round_style R> | |
| constexpr_NOERR unsigned int | overflow (unsigned int sign=0) |
| Half-precision overflow. | |
| template<std::float_round_style R> | |
| constexpr_NOERR unsigned int | underflow (unsigned int sign=0) |
| Half-precision underflow. | |
| template<std::float_round_style R, bool I> | |
| constexpr_NOERR unsigned int | rounded (unsigned int value, int g, int s) |
| Round half-precision number. | |
| template<std::float_round_style R, bool E, bool I> | |
| unsigned int | integral (unsigned int value) |
| Round half-precision number to nearest integer value. | |
| template<std::float_round_style R, unsigned int F, bool S, bool N, bool I> | |
| unsigned int | fixed2half (uint32 m, int exp=14, unsigned int sign=0, int s=0) |
| Convert fixed point to half-precision floating-point. | |
| template<std::float_round_style R> | |
| unsigned int | float2half_impl (float value, true_type) |
| Convert IEEE single-precision to half-precision. | |
| template<std::float_round_style R> | |
| unsigned int | float2half_impl (double value, true_type) |
| Convert IEEE double-precision to half-precision. | |
| template<std::float_round_style R, class T> | |
| unsigned int | float2half_impl (T value,...) |
| Convert non-IEEE floating-point to half-precision. | |
| template<std::float_round_style R, class T> | |
| unsigned int | float2half (T value) |
| Convert floating-point to half-precision. | |
| template<class T> | |
| unsigned int | float2half (T value) |
| template<std::float_round_style R, class T> | |
| unsigned int | int2half (T value) |
| Convert integer to half-precision floating-point. | |
| float | half2float_impl (unsigned int value, float, true_type) |
| Convert half-precision to IEEE single-precision. | |
| double | half2float_impl (unsigned int value, double, true_type) |
| Convert half-precision to IEEE double-precision. | |
| template<class T> | |
| T | half2float_impl (unsigned int value, T,...) |
| Convert half-precision to non-IEEE floating-point. | |
| template<class T> | |
| T | half2float (unsigned int value) |
| Convert half-precision to floating-point. | |
| template<std::float_round_style R, bool E, bool I, class T> | |
| T | half2int (unsigned int value) |
| Convert half-precision floating-point to integer. | |
Mathematics | |
| template<std::float_round_style R> | |
| uint32 | mulhi (uint32 x, uint32 y) |
| upper part of 64-bit multiplication. | |
| uint32 | multiply64 (uint32 x, uint32 y) |
| 64-bit multiplication. | |
| uint32 | divide64 (uint32 x, uint32 y, int &s) |
| 64-bit division. | |
| template<bool Q, bool R> | |
| unsigned int | mod (unsigned int x, unsigned int y, int *quo=NULL) |
| Half precision positive modulus. | |
| template<unsigned int F> | |
| uint32 | sqrt (uint32 &r, int &exp) |
| Fixed point square root. | |
| uint32 | exp2 (uint32 m, unsigned int n=32) |
| Fixed point binary exponential. | |
| uint32 | log2 (uint32 m, unsigned int n=32) |
| Fixed point binary logarithm. | |
| std::pair< uint32, uint32 > | sincos (uint32 mz, unsigned int n=31) |
| Fixed point sine and cosine. | |
| uint32 | atan2 (uint32 my, uint32 mx, unsigned int n=31) |
| Fixed point arc tangent. | |
| uint32 | angle_arg (unsigned int abs, int &k) |
| Reduce argument for trigonometric functions. | |
| std::pair< uint32, uint32 > | atan2_args (unsigned int abs) |
| Get arguments for atan2 function. | |
| std::pair< uint32, uint32 > | hyperbolic_args (unsigned int abs, int &exp, unsigned int n=32) |
| Get exponentials for hyperbolic computation. | |
| template<std::float_round_style R, bool I> | |
| unsigned int | exp2_post (uint32 m, int exp, bool esign, unsigned int sign=0) |
| Postprocessing for binary exponential. | |
| template<std::float_round_style R, uint32 L> | |
| unsigned int | log2_post (uint32 m, int ilog, int exp, unsigned int sign=0) |
| Postprocessing for binary logarithm. | |
| template<std::float_round_style R> | |
| unsigned int | hypot_post (uint32 r, int exp) |
| Hypotenuse square root and postprocessing. | |
| template<std::float_round_style R> | |
| unsigned int | tangent_post (uint32 my, uint32 mx, int exp, unsigned int sign=0) |
| Division and postprocessing for tangents. | |
| template<std::float_round_style R, bool S> | |
| unsigned int | area (unsigned int arg) |
| Area function and postprocessing. | |
| template<std::float_round_style R, bool C> | |
| unsigned int | erf (unsigned int arg) |
| Error function and postprocessing. | |
| template<std::float_round_style R, bool L> | |
| unsigned int | gamma (unsigned int arg) |
| Gamma function and postprocessing. | |
Variables | |
| constexpr binary_t | binary = binary_t() |
| Tag for binary construction. | |
| using half_float::detail::bits_t = typename bits<T>::type |
Definition at line 306 of file float16_t.hpp.
| using half_float::detail::int32 = std::int_fast32_t |
Fastest signed integer of (at least) 32 bits width.
Definition at line 299 of file float16_t.hpp.
| using half_float::detail::uint16 = std::uint_least16_t |
Unsigned integer of (at least) 16 bits width.
Definition at line 293 of file float16_t.hpp.
| using half_float::detail::uint32 = std::uint_fast32_t |
Fastest unsigned integer of (at least) 32 bits width.
Definition at line 296 of file float16_t.hpp.
|
inline |
Reduce argument for trigonometric functions.
| abs | half-precision floating-point value |
| k | value to take quarter period |
Definition at line 1283 of file float16_t.hpp.
| unsigned int half_float::detail::area | ( | unsigned int | arg | ) |
Area function and postprocessing.
This computes the value directly in Q2.30 using the representation asinh|acosh(x) = log(x+sqrt(x^2+|-1)).
| R | rounding mode to use |
| S | true for asinh, false for acosh |
| arg | half-precision argument |
| FE_OVERFLOW | on overflows |
| FE_UNDERFLOW | on underflows |
| FE_INEXACT | if no other exception occurred |
Definition at line 1444 of file float16_t.hpp.
Platform-independent arithmetic right shift.
| arg | integer value in two's complement |
| i | shift amount (at most 31) |
Definition at line 360 of file float16_t.hpp.
Fixed point arc tangent.
This uses the CORDIC algorithm in vectoring mode.
| my | y coordinate as Q0.30 |
| mx | x coordinate as Q0.30 |
| n | number of iterations (at most 31) |
Definition at line 1263 of file float16_t.hpp.
Get arguments for atan2 function.
| abs | half-precision floating-point value |
Definition at line 1297 of file float16_t.hpp.
| bool half_float::detail::builtin_isinf | ( | T | arg | ) |
Check for infinity.
| T | argument type (builtin floating-point type) |
| arg | value to query |
| true | if infinity |
| false | else |
Definition at line 327 of file float16_t.hpp.
| bool half_float::detail::builtin_isnan | ( | T | arg | ) |
Check for NaN.
| T | argument type (builtin floating-point type) |
| arg | value to query |
| true | if not a number |
| false | else |
Definition at line 334 of file float16_t.hpp.
| bool half_float::detail::builtin_signbit | ( | T | arg | ) |
Check sign.
| T | argument type (builtin floating-point type) |
| arg | value to query |
| true | if signbit set |
| false | else |
Definition at line 341 of file float16_t.hpp.
|
inline |
Check value for underflow.
| arg | non-zero half-precision value to check |
| FE_UNDERFLOW | if arg is subnormal |
Definition at line 513 of file float16_t.hpp.
|
inline |
Check and signal for any NaN.
| x | first half-precision value to check |
| y | second half-precision value to check |
| true | if either x or y is NaN |
| false | else |
| FE_INVALID | if x or y is NaN |
Definition at line 432 of file float16_t.hpp.
64-bit division.
| x | upper 32 bit of dividend |
| y | divisor |
| s | variable to store sticky bit for rounding |
Definition at line 1100 of file float16_t.hpp.
| unsigned int half_float::detail::erf | ( | unsigned int | arg | ) |
Error function and postprocessing.
This computes the value directly in Q1.31 using the approximations given here.
| R | rounding mode to use |
| C | true for comlementary error function, false else |
| arg | half-precision function argument |
| FE_OVERFLOW | on overflows |
| FE_UNDERFLOW | on underflows |
| FE_INEXACT | if no other exception occurred |
Definition at line 1558 of file float16_t.hpp.
|
inline |
Internal exception flags.
Definition at line 374 of file float16_t.hpp.
Fixed point binary exponential.
This uses the BKM algorithm in E-mode.
| m | exponent in [0,1) as Q0.31 |
| n | number of iterations (at most 32) |
Definition at line 1193 of file float16_t.hpp.
| unsigned int half_float::detail::exp2_post | ( | uint32 | m, |
| int | exp, | ||
| bool | esign, | ||
| unsigned int | sign = 0 ) |
Postprocessing for binary exponential.
| R | rounding mode to use |
| I | true to always raise INEXACT exception, false to raise only for rounded results |
| m | mantissa as Q1.31 |
| exp | absolute value of unbiased exponent |
| esign | sign of actual exponent |
| sign | sign bit of result |
| FE_OVERFLOW | on overflows |
| FE_UNDERFLOW | on underflows |
| FE_INEXACT | if value had to be rounded or I is `true` |
Definition at line 1351 of file float16_t.hpp.
| unsigned int half_float::detail::fixed2half | ( | uint32 | m, |
| int | exp = 14, | ||
| unsigned int | sign = 0, | ||
| int | s = 0 ) |
Convert fixed point to half-precision floating-point.
| R | rounding mode to use |
| F | number of fractional bits (at least 11) |
| S | true for signed, false for unsigned |
| N | true for additional normalization step, false if already normalized to 1.F |
| I | true to always raise INEXACT exception, false to raise only for rounded results |
| m | mantissa in Q1.F fixed point format |
| exp | exponent |
| sign | half-precision value with sign bit only |
| s | sticky bit (or of all but the most significant already discarded bits) |
| FE_OVERFLOW | on overflows |
| FE_UNDERFLOW | on underflows |
| FE_INEXACT | if value had to be rounded or I is `true` |
Definition at line 624 of file float16_t.hpp.
| unsigned int half_float::detail::float2half | ( | T | value | ) |
Convert floating-point to half-precision.
| R | rounding mode to use |
| T | source type (builtin floating-point type) |
| value | floating-point value to convert |
| FE_OVERFLOW | on overflows |
| FE_UNDERFLOW | on underflows |
| FE_INEXACT | if value had to be rounded |
Definition at line 797 of file float16_t.hpp.
| unsigned int half_float::detail::float2half | ( | T | value | ) |
| unsigned int half_float::detail::float2half_impl | ( | double | value, |
| true_type | ) |
Convert IEEE double-precision to half-precision.
| R | rounding mode to use |
| value | double-precision value to convert |
| FE_OVERFLOW | on overflows |
| FE_UNDERFLOW | on underflows |
| FE_INEXACT | if value had to be rounded |
Definition at line 732 of file float16_t.hpp.
| unsigned int half_float::detail::float2half_impl | ( | float | value, |
| true_type | ) |
Convert IEEE single-precision to half-precision.
Credit for this goes to Jeroen van der Zijp.
| R | rounding mode to use |
| value | single-precision value to convert |
| FE_OVERFLOW | on overflows |
| FE_UNDERFLOW | on underflows |
| FE_INEXACT | if value had to be rounded |
Definition at line 645 of file float16_t.hpp.
| unsigned int half_float::detail::float2half_impl | ( | T | value, |
| ... ) |
Convert non-IEEE floating-point to half-precision.
| R | rounding mode to use |
| T | source type (builtin floating-point type) |
| value | floating-point value to convert |
| FE_OVERFLOW | on overflows |
| FE_UNDERFLOW | on underflows |
| FE_INEXACT | if value had to be rounded |
Definition at line 766 of file float16_t.hpp.
| unsigned int half_float::detail::gamma | ( | unsigned int | arg | ) |
Gamma function and postprocessing.
This approximates the value of either the gamma function or its logarithm directly in Q1.31.
| R | rounding mode to use |
| L | true for lograithm of gamma function, false for gamma function |
| arg | half-precision floating-point value |
| FE_OVERFLOW | on overflows |
| FE_UNDERFLOW | on underflows |
| FE_INEXACT | if arg is not a positive integer |
Definition at line 1576 of file float16_t.hpp.
| T half_float::detail::half2float | ( | unsigned int | value | ) |
Convert half-precision to floating-point.
| T | type to convert to (builtin integer type) |
| value | half-precision value to convert |
Definition at line 1033 of file float16_t.hpp.
|
inline |
Convert half-precision to IEEE double-precision.
| value | half-precision value to convert |
Definition at line 992 of file float16_t.hpp.
|
inline |
Convert half-precision to IEEE single-precision.
Credit for this goes to Jeroen van der Zijp.
| value | half-precision value to convert |
Definition at line 830 of file float16_t.hpp.
| T half_float::detail::half2float_impl | ( | unsigned int | value, |
| T | , | ||
| ... ) |
Convert half-precision to non-IEEE floating-point.
| T | type to convert to (builtin integer type) |
| value | half-precision value to convert |
Definition at line 1014 of file float16_t.hpp.
| T half_float::detail::half2int | ( | unsigned int | value | ) |
Convert half-precision floating-point to integer.
| R | rounding mode to use |
| E | true for round to even, false for round away from zero |
| I | true to raise INEXACT exception (if inexact), false to never raise it |
| T | type to convert to (buitlin integer type with at least 16 bits precision, excluding any implicit sign bits) |
| value | half-precision value to convert |
| FE_INVALID | if value is not representable in type T |
| FE_INEXACT | if value had to be rounded and I is `true` |
Definition at line 1046 of file float16_t.hpp.
|
inline |
Get exponentials for hyperbolic computation.
| abs | half-precision floating-point value |
| exp | variable to take unbiased exponent of larger result |
| n | number of BKM iterations (at most 32) |
Definition at line 1319 of file float16_t.hpp.
| unsigned int half_float::detail::hypot_post | ( | uint32 | r, |
| int | exp ) |
Hypotenuse square root and postprocessing.
| R | rounding mode to use |
| r | mantissa as Q2.30 |
| exp | unbiased exponent |
| FE_OVERFLOW | on overflows |
| FE_UNDERFLOW | on underflows |
| FE_INEXACT | if value had to be rounded |
Definition at line 1403 of file float16_t.hpp.
| unsigned int half_float::detail::int2half | ( | T | value | ) |
Convert integer to half-precision floating-point.
| R | rounding mode to use |
| T | type to convert (builtin integer type) |
| value | integral value to convert |
| FE_OVERFLOW | on overflows |
| FE_INEXACT | if value had to be rounded |
Definition at line 811 of file float16_t.hpp.
| unsigned int half_float::detail::integral | ( | unsigned int | value | ) |
Round half-precision number to nearest integer value.
| R | rounding mode to use |
| E | true for round to even, false for round away from zero |
| I | true to raise INEXACT exception (if inexact), false to never raise it |
| value | half-precision value to round |
| FE_INVALID | for signaling NaN |
| FE_INEXACT | if value had to be rounded and I is `true` |
Definition at line 591 of file float16_t.hpp.
|
inline |
Raise domain error and return NaN.
return quiet NaN
| FE_INVALID |
Definition at line 491 of file float16_t.hpp.
Fixed point binary logarithm.
This uses the BKM algorithm in L-mode.
| m | mantissa in [1,2) as Q1.30 |
| n | number of iterations (at most 32) |
Definition at line 1217 of file float16_t.hpp.
| unsigned int half_float::detail::log2_post | ( | uint32 | m, |
| int | ilog, | ||
| int | exp, | ||
| unsigned int | sign = 0 ) |
Postprocessing for binary logarithm.
| R | rounding mode to use |
| L | logarithm for base transformation as Q1.31 |
| m | fractional part of logarithm as Q0.31 |
| ilog | signed integer part of logarithm |
| exp | biased exponent of result |
| sign | sign bit of result |
| FE_OVERFLOW | on overflows |
| FE_UNDERFLOW | on underflows |
| FE_INEXACT | if no other exception occurred |
Definition at line 1379 of file float16_t.hpp.
| unsigned int half_float::detail::mod | ( | unsigned int | x, |
| unsigned int | y, | ||
| int * | quo = NULL ) |
Half precision positive modulus.
| Q | true to compute full quotient, false else |
| R | true to compute signed remainder, false for positive remainder |
| x | first operand as positive finite half-precision value |
| y | second operand as positive finite half-precision value |
| quo | adress to store quotient at, nullptr if Q false |
Definition at line 1112 of file float16_t.hpp.
upper part of 64-bit multiplication.
| R | rounding mode to use |
| x | first factor |
| y | second factor |
Definition at line 1081 of file float16_t.hpp.
64-bit multiplication.
| x | first factor |
| y | second factor |
Definition at line 1091 of file float16_t.hpp.
| constexpr_NOERR unsigned int half_float::detail::overflow | ( | unsigned int | sign = 0 | ) |
Half-precision overflow.
| R | rounding mode to use |
| sign | half-precision value with sign bit only |
| FE_OVERFLOW |
Definition at line 529 of file float16_t.hpp.
|
inline |
Raise pole error and return infinity.
| sign | half-precision value with sign bit only |
| FE_DIVBYZERO |
Definition at line 502 of file float16_t.hpp.
|
inline |
Raise floating-point exception.
| flags | exceptions to raise |
| cond | condition to raise exceptions for |
Definition at line 379 of file float16_t.hpp.
| constexpr_NOERR unsigned int half_float::detail::rounded | ( | unsigned int | value, |
| int | g, | ||
| int | s ) |
Round half-precision number.
| R | rounding mode to use |
| I | true to always raise INEXACT exception, false to raise only for rounded results |
| value | finite half-precision number to round |
| g | guard bit (most significant discarded bit) |
| s | sticky bit (or of all but the most significant discarded bits) |
| FE_OVERFLOW | on overflows |
| FE_UNDERFLOW | on underflows |
| FE_INEXACT | if value had to be rounded or I is `true` |
Definition at line 563 of file float16_t.hpp.
|
inline |
Select value or signaling NaN.
| x | preferred half-precision value |
| y | ignored half-precision value except for signaling NaN |
| FE_INVALID | if y is signaling NaN |
Definition at line 480 of file float16_t.hpp.
Platform-independent sign mask.
| arg | integer value in two's complement |
| -1 | if arg negative |
| 0 | if arg positive |
Definition at line 347 of file float16_t.hpp.
|
inline |
Signal and silence signaling NaN.
| nan | half-precision NaN value |
| FE_INVALID | if nan is signaling NaN |
Definition at line 443 of file float16_t.hpp.
|
inline |
Signal and silence signaling NaNs.
| x | first half-precision value to check |
| y | second half-precision value to check |
| FE_INVALID | if x or y is signaling NaN |
Definition at line 455 of file float16_t.hpp.
|
inline |
Signal and silence signaling NaNs.
| x | first half-precision value to check |
| y | second half-precision value to check |
| z | third half-precision value to check |
| FE_INVALID | if x, y or z is signaling NaN |
Definition at line 468 of file float16_t.hpp.
Fixed point sine and cosine.
This uses the CORDIC algorithm in rotation mode.
| mz | angle in [-pi/2,pi/2] as Q1.30 |
| n | number of iterations (at most 31) |
Definition at line 1241 of file float16_t.hpp.
Fixed point square root.
| F | number of fractional bits |
| r | radicand in Q1.F fixed point format |
| exp | exponent |
Definition at line 1172 of file float16_t.hpp.
| unsigned int half_float::detail::tangent_post | ( | uint32 | my, |
| uint32 | mx, | ||
| int | exp, | ||
| unsigned int | sign = 0 ) |
Division and postprocessing for tangents.
| R | rounding mode to use |
| my | dividend as Q1.31 |
| mx | divisor as Q1.31 |
| exp | biased exponent of result |
| sign | sign bit of result |
| FE_OVERFLOW | on overflows |
| FE_UNDERFLOW | on underflows |
| FE_INEXACT | if no other exception occurred |
Definition at line 1424 of file float16_t.hpp.
| constexpr_NOERR unsigned int half_float::detail::underflow | ( | unsigned int | sign = 0 | ) |
Half-precision underflow.
| R | rounding mode to use |
| sign | half-precision value with sign bit only |
| FE_UNDERFLOW |
Definition at line 544 of file float16_t.hpp.
Tag for binary construction.
Definition at line 317 of file float16_t.hpp.