MeshLib C++ Docs
Loading...
Searching...
No Matches
MR::detail Namespace Reference

Namespaces

namespace  AffineXf3f
namespace  Units

Classes

class  FuncCallHelper
struct  MakeScopeGuard
class  ScopeGuard

Functions

constexpr std::uint64_t addCarry64 (std::uint64_t a, std::uint64_t b, std::uint64_t &carry) noexcept
 returns a + b + carry modulo 2^64, and replaces carry with the carry-out (0 or 1)
constexpr std::uint64_t subBorrow64 (std::uint64_t a, std::uint64_t b, std::uint64_t &borrow) noexcept
 returns a - b - borrow modulo 2^64, and replaces borrow with the borrow-out (0 or 1)
constexpr std::uint64_t signWord (std::uint64_t hi) noexcept
 all ones if the highest bit of the given word is set, and zeros otherwise
template<std::size_t n, std::size_t m>
constexpr std::array< std::uint64_t, n+m > mulWords (const std::array< std::uint64_t, n > &a, const std::array< std::uint64_t, m > &b) noexcept
 std::size_t and not int, to be deducible from std::array
template<typename T>
constexpr auto mulWordsOf (T v) noexcept
 the words of a multiplier of FastInt, sign-extended if it is signed
double doubleFromWords (const std::uint64_t *w, int n) noexcept
std::vector< std::filesystem::path > runCocoaFileDialog (const MR::FileDialog::Parameters &params)
 Open Cocoa file dialog.
bool isPortalFileDialogSupported ()
 Checks if XDG Desktop Portal file dialogs are supported.
std::vector< std::filesystem::path > runPortalFileDialog (const MR::FileDialog::Parameters &params)
 Open XDG Desktop Portal file dialog.

Variables

template<typename T>
constexpr bool cFitsFastInt128 = std::is_integral_v<T> || std::is_same_v<T, FastInt128>
 the integer types that FastInt128 represents exactly, and which the classes below accept
template<typename T>
constexpr int cMulBits = std::is_same_v<T, FastInt128> || ( std::is_unsigned_v<T> && sizeof( T ) >= 8 ) ? 128 : 64

Function Documentation

◆ addCarry64()

std::uint64_t MR::detail::addCarry64 ( std::uint64_t a,
std::uint64_t b,
std::uint64_t & carry )
inlinenodiscardconstexprnoexcept

returns a + b + carry modulo 2^64, and replaces carry with the carry-out (0 or 1)

the two functions below are spelled via FastUInt128, where the carry-out is simply the higher word, as in mulWords below

◆ doubleFromWords()

double MR::detail::doubleFromWords ( const std::uint64_t * w,
int n )
nodiscardnoexcept

the nearest double to the two's-complement value in the n words at w, least significant first; see toDouble below for the guarantees, which this function alone provides for the whole family

◆ isPortalFileDialogSupported()

bool MR::detail::isPortalFileDialogSupported ( )

Checks if XDG Desktop Portal file dialogs are supported.

◆ mulWords()

template<std::size_t n, std::size_t m>
std::array< std::uint64_t, n+m > MR::detail::mulWords ( const std::array< std::uint64_t, n > & a,
const std::array< std::uint64_t, m > & b )
nodiscardconstexprnoexcept

std::size_t and not int, to be deducible from std::array

the exact product of two two's-complement values given by their 64-bit words, which always fits in the sum of their word counts; the only multiplication of this file

schoolbook multiplication of unsigned values

this row adds nothing: 0 * b[j] leaves every res[i + j] unchanged, and res[i + m] is still 0 (never written before this row), so the skipped res[i + m] = carry (carry stays 0 here) would be a no-op. Small-magnitude values keep their high words at 0, so this is the common fast path; negative operands are sign-extended to all-ones top words and are not skipped.

at most ( 2^64 - 1 )^2 + 2 * ( 2^64 - 1 ) < 2^128 here

never written before, since the loop above stops at i + m - 1

a negative argument was taken 2^(64*words) times larger than it is; both subtractions below end exactly at the end of res, so the borrow never leaves it

◆ mulWordsOf()

template<typename T>
auto MR::detail::mulWordsOf ( T v)
nodiscardconstexprnoexcept

the words of a multiplier of FastInt, sign-extended if it is signed

◆ runCocoaFileDialog()

std::vector< std::filesystem::path > MR::detail::runCocoaFileDialog ( const MR::FileDialog::Parameters & params)

Open Cocoa file dialog.

◆ runPortalFileDialog()

std::vector< std::filesystem::path > MR::detail::runPortalFileDialog ( const MR::FileDialog::Parameters & params)

Open XDG Desktop Portal file dialog.

◆ signWord()

std::uint64_t MR::detail::signWord ( std::uint64_t hi)
inlinenodiscardconstexprnoexcept

all ones if the highest bit of the given word is set, and zeros otherwise

◆ subBorrow64()

std::uint64_t MR::detail::subBorrow64 ( std::uint64_t a,
std::uint64_t b,
std::uint64_t & borrow )
inlinenodiscardconstexprnoexcept

returns a - b - borrow modulo 2^64, and replaces borrow with the borrow-out (0 or 1)

Variable Documentation

◆ cFitsFastInt128

template<typename T>
bool MR::detail::cFitsFastInt128 = std::is_integral_v<T> || std::is_same_v<T, FastInt128>
constexpr

the integer types that FastInt128 represents exactly, and which the classes below accept

◆ cMulBits

template<typename T>
int MR::detail::cMulBits = std::is_same_v<T, FastInt128> || ( std::is_unsigned_v<T> && sizeof( T ) >= 8 ) ? 128 : 64
constexpr

the number of bits a multiplier of FastInt occupies: 128 for FastInt128 and for an unsigned 64-bit integer, both of which need two words, and 64 for anything signed or narrower