native 0.0.1
Vectors, masks and wide register packs for C++26
Loading...
Searching...
No Matches
Numerics

Concepts

concept  native::one_of
 N is one of the candidates
concept  native::not_one_of
 N is not one of the candidates

Classes

struct  native::fp16
struct  native::bf16

Typedefs

template<typename T>
using native::int_t
template<typename T>
using native::uint_t

Enumerations

enum class  native::CMPINT : std::size_t {
  native::CMPINT::EQ = 0x0uz , native::CMPINT::LT = 0x1uz , native::CMPINT::LE = 0x2uz , native::CMPINT::FALSE = 0x3uz ,
  native::CMPINT::NE = 0x4uz , native::CMPINT::NLT = 0x5uz , native::CMPINT::NLE = 0x6uz , native::CMPINT::TRUE = 0x7uz
}
 Scalar integer-comparison predicates, encoded like the corresponding x86 immediates. More...
enum class  native::CMP : std::size_t {
  native::CMP::EQ_OQ = 0x00uz , native::CMP::LT_OS = 0x01uz , native::CMP::LE_OS = 0x02uz , native::CMP::UNORD_Q = 0x03uz ,
  native::CMP::NEQ_UQ = 0x04uz , native::CMP::NLT_US = 0x05uz , native::CMP::NLE_US = 0x06uz , native::CMP::ORD_Q = 0x07uz ,
  native::CMP::EQ_UQ = 0x08uz , native::CMP::NGE_US = 0x09uz , native::CMP::NGT_US = 0x0Auz , native::CMP::FALSE_OQ = 0x0Buz ,
  native::CMP::NEQ_OQ = 0x0Cuz , native::CMP::GE_OS = 0x0Duz , native::CMP::GT_OS = 0x0Euz , native::CMP::TRUE_UQ = 0x0Fuz ,
  native::CMP::EQ_OS = 0x10uz , native::CMP::LT_OQ = 0x11uz , native::CMP::LE_OQ = 0x12uz , native::CMP::UNORD_S = 0x13uz ,
  native::CMP::NEQ_US = 0x14uz , native::CMP::NLT_UQ = 0x15uz , native::CMP::NLE_UQ = 0x16uz , native::CMP::ORD_S = 0x17uz ,
  native::CMP::EQ_US = 0x18uz , native::CMP::NGE_UQ = 0x19uz , native::CMP::NGT_UQ = 0x1Auz , native::CMP::FALSE_OS = 0x1Buz ,
  native::CMP::NEQ_OS = 0x1Cuz , native::CMP::GE_OQ = 0x1Duz , native::CMP::GT_OQ = 0x1Euz , native::CMP::TRUE_US = 0x1Fuz
}
 Scalar floating-comparison predicates, including ordered and unordered truth tables. More...

Functions

template<typename T>
constexpr bool native::cmp_unord (T a, T b) noexcept(noexcept(isnan(a)||isnan(b)))
 Return true if either argument is NaN.
template<typename T>
constexpr bool native::cmp_ord (T a, T b) noexcept(noexcept(!isnan(a) &&!isnan(b)))
 Return true if neither argument is NaN.
template<one_of_t< float, double > T>
constexpr T native::scalef (T x, T y) noexcept
template<CMPINT imm8, typename T>
requires (one_of_t<T, uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, uint64_t, int64_t> && (std::size_t(imm8) < 8uz))
constexpr bool native::cmpint (T a, T b) noexcept
template<CMP imm8, typename T>
requires (one_of_t<T, float, double> && (std::size_t(imm8) < 32uz))
constexpr bool native::cmp (T a, T b) noexcept

Variables

constexpr std::size_t native::max_fp_comparison_predicate

Detailed Description

Typedef Documentation

◆ int_t

template<typename T>
using native::int_t
export

returns a signed integer type of the same size as T suitable for std::bit_cast

Definition at line 580 of file native.numerics.ccm.

◆ uint_t

template<typename T>
using native::uint_t
export

returns an unsigned integer type of the same size as T suitable for std::bit_cast

Definition at line 586 of file native.numerics.ccm.

Enumeration Type Documentation

◆ CMP

enum class native::CMP : std::size_t
exportstrong

Scalar floating-comparison predicates, including ordered and unordered truth tables.

Ordered predicates require neither operand to be NaN; unordered predicates include NaNs as indicated by their truth table. The Q/S suffixes retain the x86 encoding names, not a promise about hardware exception flags.

Enumerator
EQ_OQ 0x00uz 

Equal (ordered, nonsignaling).

LT_OS 0x01uz 

Less-than (ordered, signaling).

LE_OS 0x02uz 

Less-than-or-equal (ordered, signaling).

UNORD_Q 0x03uz 

Unordered (nonsignaling).

NEQ_UQ 0x04uz 

Not-equal (unordered, nonsignaling).

NLT_US 0x05uz 

Not-less-than (unordered, signaling).

NLE_US 0x06uz 

Not-less-than-or-equal (unordered, signaling).

ORD_Q 0x07uz 

Ordered (nonsignaling).

EQ_UQ 0x08uz 

Equal (unordered, nonsignaling).

NGE_US 0x09uz 

Not-greater-than-or-equal (unordered, signaling).

NGT_US 0x0Auz 

Not-greater-than (unordered, signaling).

FALSE_OQ 0x0Buz 

False (ordered, nonsignaling).

NEQ_OQ 0x0Cuz 

Not-equal (ordered, nonsignaling).

GE_OS 0x0Duz 

Greater-than-or-equal (ordered, signaling).

GT_OS 0x0Euz 

Greater-than (ordered, signaling).

TRUE_UQ 0x0Fuz 

True (unordered, nonsignaling).

EQ_OS 0x10uz 

Equal (ordered, signaling).

LT_OQ 0x11uz 

Less-than (ordered, nonsignaling).

LE_OQ 0x12uz 

Less-than-or-equal (ordered, nonsignaling).

UNORD_S 0x13uz 

Unordered (signaling).

NEQ_US 0x14uz 

Not-equal (unordered, signaling).

NLT_UQ 0x15uz 

Not-less-than (unordered, nonsignaling).

NLE_UQ 0x16uz 

Not-less-than-or-equal (unordered, nonsignaling).

ORD_S 0x17uz 

Ordered (signaling).

EQ_US 0x18uz 

Equal (unordered, signaling).

NGE_UQ 0x19uz 

Not-greater-than-or-equal (unordered, nonsignaling).

NGT_UQ 0x1Auz 

Not-greater-than (unordered, nonsignaling).

FALSE_OS 0x1Buz 

False (ordered, signaling).

NEQ_OS 0x1Cuz 

Not-equal (ordered, signaling).

GE_OQ 0x1Duz 

Greater-than-or-equal (ordered, nonsignaling).

GT_OQ 0x1Euz 

Greater-than (ordered, nonsignaling).

TRUE_US 0x1Fuz 

True (unordered, signaling).

Definition at line 734 of file native.numerics.ccm.

◆ CMPINT

enum class native::CMPINT : std::size_t
exportstrong

Scalar integer-comparison predicates, encoded like the corresponding x86 immediates.

Select a truth table for cmpint(); comparison uses the signedness of its operands.

Enumerator
EQ 0x0uz 

==

LT 0x1uz 

<

LE 0x2uz 

<=

FALSE 0x3uz 

always false

NE 0x4uz 

!=

NLT 0x5uz 

>=

NLE 0x6uz 

>

TRUE 0x7uz 

always true

Definition at line 689 of file native.numerics.ccm.

Function Documentation

◆ cmp()

template<CMP imm8, typename T>
requires (one_of_t<T, float, double> && (std::size_t(imm8) < 32uz))
bool native::cmp ( T a,
T b )
inlineconstexprexportnoexcept

Evaluate the selected ordered/unordered truth table on two float or double values. The Q/S immediate variants have the same truth values; this helper does not emulate the x86 signaling versus nonsignaling exception behavior.

Definition at line 775 of file native.numerics.ccm.

Here is the caller graph for this function:

◆ cmp_ord()

template<typename T>
bool native::cmp_ord ( T a,
T b )
inlineconstexprexportnoexcept

Return true if neither argument is NaN.

This corresponds to checking if the two arguments are "ordered" with respect to the IEEE floating point comparison predicates

Definition at line 615 of file native.numerics.ccm.

Here is the caller graph for this function:

◆ cmp_unord()

template<typename T>
bool native::cmp_unord ( T a,
T b )
inlineconstexprexportnoexcept

Return true if either argument is NaN.

This corresponds to checking if the two arguments are "unordered" with respect to the IEEE floating point comparison predicates

Definition at line 598 of file native.numerics.ccm.

Here is the caller graph for this function:

◆ cmpint()

template<CMPINT imm8, typename T>
requires (one_of_t<T, uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, uint64_t, int64_t> && (std::size_t(imm8) < 8uz))
bool native::cmpint ( T a,
T b )
inlineconstexprexportnoexcept

Evaluate the selected integer truth table on two values of the same integer type. Signed and unsigned ordering follow T; the immediate selects one of eight predicates.

Definition at line 705 of file native.numerics.ccm.

Here is the caller graph for this function:

◆ scalef()

template<one_of_t< float, double > T>
T native::scalef ( T x,
T y )
inlineconstexprexportnoexcept

Scale x by 2 raised to the exponent obtained by truncating y toward zero.

Precondition
The truncated value of y is representable as int. Constant evaluation uses round-to-nearest, ties-to-even with gradual underflow. Runtime uses std::scalbn and follows the active rounding and denormal modes; it agrees with constant evaluation under the same floating-point assumptions. Signed zeros and overflow signs are preserved; NaN payloads are not promised. This scalar truncation contract differs from the vector scaleb API.

Definition at line 634 of file native.numerics.ccm.

Here is the caller graph for this function:

Variable Documentation

◆ max_fp_comparison_predicate

std::size_t native::max_fp_comparison_predicate
inlineconstexprexport

Number of floating comparison immediates selected by the compile-time AVX-512 feature macro. This constant does not query the running CPU or admit any instruction set.

Definition at line 721 of file native.numerics.ccm.