Aesi Multiprecision
C++ class library of long integer arithmetic for GPU parallelization
Loading...
Searching...
No Matches
Aeu< bitness > Class Template Referencefinal

Long precision unsigned integer. More...

#include <Aeu.h>

Public Member Functions

gpu constexpr Aeu () noexcept=default
 Default constructor.
 
gpu constexpr ~Aeu () noexcept=default
 Destructor.
 
gpu constexpr Aeu (const Aeu &copy) noexcept=default
 Copy constructor.
 
gpu constexpr Aeuoperator= (const Aeu &other)=default
 Copy assignment operator.
 
template<typename Integral >
requires (std::is_unsigned_v<Integral>)
gpu constexpr Aeu (Integral value) noexcept
 Integral constructor.
 
template<typename Char >
requires (std::is_same_v<Char, char> || std::is_same_v<Char, wchar_t>)
gpu constexpr Aeu (const Char *data, std::size_t size) noexcept
 Pointer-based character constructor.
 
template<typename Char , std::size_t arrayLength>
requires (arrayLength > 1 && (std::is_same_v<Char, char> || std::is_same_v<Char, wchar_t>))
gpu constexpr Aeu (const Char(&literal)[arrayLength]) noexcept
 C-style string literal constructor.
 
template<typename String , typename Char = typename String::value_type>
requires (std::is_same_v<std::basic_string<Char>, std::decay_t<String>> || std::is_same_v<std::basic_string_view<Char>, std::decay_t<String>>)
gpu constexpr Aeu (String &&stringView) noexcept
 String or string-view based constructor.
 
template<typename String , typename Char = typename String::value_type>
requires (std::is_same_v<std::basic_string<Char>, std::decay_t<String>> || std::is_same_v<std::basic_string_view<Char>, std::decay_t<String>>)
gpu constexpr Aeu (const String &stringView) noexcept
 
gpu constexpr auto operator+ () const noexcept -> Aeu
 Unary plus operator.
 
gpu constexpr auto operator- () const noexcept -> Aeu
 Unary minus operator.
 
gpu constexpr auto operator++ () noexcept -> Aeu &
 Prefix increment.
 
gpu constexpr auto operator++ (int) &noexcept -> Aeu
 Postfix increment.
 
gpu constexpr auto operator-- () noexcept -> Aeu &
 Prefix decrement.
 
gpu constexpr auto operator-- (int) &noexcept -> Aeu
 Postfix decrement.
 
gpu constexpr auto operator~ () const noexcept -> Aeu
 Bitwise complement operator.
 
template<typename Unsigned >
requires (std::is_unsigned_v<Unsigned> && sizeof(Unsigned) < 8)
gpu constexpr auto compareTo (Unsigned other) const noexcept -> Comparison
 Internal comparison operator for built-in integral types uint8_t, uint16_t, uint32_t.
 
gpu constexpr auto compareTo (uint64_t other) const noexcept -> Comparison
 Internal comparison operator for type uint64_t.
 
template<std::size_t otherBitness = bitness>
gpu constexpr auto compareTo (const Aeu< otherBitness > &other) const noexcept -> Comparison
 Internal comparison operator.
 
gpu constexpr auto operator<=> (const Aeu &other) const noexcept -> std::strong_ordering
 Three-way comparison operator.
 
template<typename Unsigned >
gpu constexpr auto operator<=> (const Unsigned &other) const noexcept -> std::strong_ordering
 Three-way comparison operator for numbers of different precision and built-in integral types.
 
gpu constexpr auto setBit (std::size_t index, bool bit) noexcept -> void
 Set a bit in number by index starting from the right.
 
gpu constexpr auto getBit (std::size_t index) const noexcept -> bool
 Get bit in number by index staring from the right.
 
gpu constexpr auto setByte (std::size_t index, byte byte) noexcept -> void
 Set byte in number by index starting from the right.
 
gpu constexpr auto getByte (std::size_t index) const noexcept -> byte
 Get byte in number by index starting from the right.
 
gpu constexpr auto setBlock (std::size_t index, block block) noexcept -> void
 Set block in number by index starting from the right.
 
gpu constexpr auto getBlock (std::size_t index) const noexcept -> block
 Get block in number by index starting from the right.
 
gpu constexpr auto byteCount () const noexcept -> std::size_t
 Get amount of non-empty bytes in number right to left.
 
gpu constexpr auto bitCount () const noexcept -> std::size_t
 Get amount of non-empty bits in number right to left.
 
gpu constexpr auto isOdd () const noexcept -> bool
 Check whether number is odd.
 
gpu constexpr auto isEven () const noexcept -> bool
 Check whether number is even.
 
gpu constexpr auto isZero () const noexcept -> bool
 Check whether number is zero.
 
gpu constexpr auto filledBlocksNumber () const noexcept -> std::size_t
 Get number of non-empty blocks inside object starting from the right.
 
gpu constexpr auto swap (Aeu &other) noexcept -> void
 Make swap between two objects.
 
gpu constexpr auto squareRoot () const noexcept -> Aeu
 Get square root.
 
template<byte base, typename Char >
requires (std::is_same_v<Char, char> || std::is_same_v<Char, wchar_t> && (base == 2 || base == 8 || base == 10 || base == 16))
gpu constexpr auto getString (Char *const buffer, std::size_t bufferSize, bool showBase=false, bool hexUppercase=false) const noexcept -> std::size_t
 Character buffer output operator.
 
template<typename Char >
requires (std::is_same_v<Char, char> || std::is_same_v<Char, wchar_t>)
constexpr auto readBinary (std::basic_istream< Char > &is, bool bigEndian=true) -> void
 STD stream binary reading operator.
 
template<typename Char >
requires (std::is_same_v<Char, char> || std::is_same_v<Char, wchar_t>)
constexpr auto writeBinary (std::basic_ostream< Char > &os, bool bigEndian=true) const noexcept -> void
 STD stream binary writing operator.
 
template<typename Integral >
requires (std::is_integral_v<Integral>)
gpu constexpr auto integralCast () const noexcept -> Integral
 Integral type cast operator for built-in types.
 
template<std::size_t newBitness>
requires (newBitness != bitness)
gpu constexpr auto precisionCast () const noexcept -> Aeu< newBitness >
 Precision cast operator.
 

Static Public Member Functions

static gpu constexpr auto getBitness () noexcept -> std::size_t
 Get number's precision.
 
static gpu constexpr auto totalBlocksNumber () noexcept -> std::size_t
 Get the number of blocks (length of array of uint32_t integers) inside object.
 
static gpu constexpr auto divide (const Aeu &number, const Aeu &divisor, Aeu &quotient, Aeu &remainder) noexcept -> void
 Integer division. Returns results by reference.
 
static gpu constexpr auto divide (const Aeu &number, const Aeu &divisor) noexcept -> pair< Aeu, Aeu >
 Integer division. Returns results by value.
 
static gpu constexpr auto gcd (const Aeu &first, const Aeu &second, Aeu &bezoutX, Aeu &bezoutY) noexcept -> Aeu
 Extended Euclidean algorithm for greatest common divisor.
 
static gpu constexpr auto gcd (const Aeu &first, const Aeu &second) noexcept -> Aeu
 Greatest common divisor.
 
static gpu constexpr auto lcm (const Aeu &first, const Aeu &second) noexcept -> Aeu
 Least common multiplier.
 
template<std::size_t powerBitness = bitness>
static gpu constexpr auto powm (const Aeu &base, const Aeu< powerBitness > &power, const Aeu &modulo) noexcept -> Aeu
 Exponentiation by modulo.
 
static gpu constexpr auto powm (const Aeu &base, const Aeu &power, const Aeu &mod) noexcept -> Aeu
 
static gpu constexpr auto power2 (std::size_t power) noexcept -> Aeu
 Fast exponentiation for powers of 2.
 

Friends

template<typename Unsigned >
requires (std::is_unsigned_v<Unsigned>)
gpu constexpr friend auto operator+ (const Aeu &addition, Unsigned addendum) noexcept -> Aeu
 Addition operator for built-in integral types.
 
gpu constexpr friend auto operator+ (const Aeu &addition, const Aeu &addendum) noexcept -> Aeu
 Addition operator.
 
template<typename Unsigned >
requires (std::is_unsigned_v<Unsigned>)
gpu constexpr friend auto operator+= (Aeu &addition, Unsigned addendum) noexcept -> Aeu &
 Assignment addition operator for built-in integral types.
 
gpu constexpr friend auto operator+= (Aeu &addition, const Aeu &addendum) noexcept -> Aeu &
 Assignment addition operator.
 
gpu constexpr friend auto operator- (const Aeu &subtraction, const Aeu &subtrahend) noexcept -> Aeu
 Subtraction operator.
 
gpu constexpr friend auto operator-= (Aeu &subtraction, const Aeu &subtrahend) noexcept -> Aeu &
 Assignment subtraction operator.
 
template<typename Unsigned >
requires (std::is_unsigned_v<Unsigned>)
gpu constexpr friend auto operator* (Aeu &multiplication, Unsigned factor) noexcept -> Aeu
 Multiplication operator for built-in integral types.
 
gpu constexpr friend auto operator* (const Aeu &multiplication, const Aeu &factor) noexcept -> Aeu
 Multiplication operator.
 
template<typename Unsigned >
requires (std::is_unsigned_v<Unsigned>)
gpu constexpr friend auto operator*= (Aeu &multiplication, Unsigned factor) noexcept -> Aeu &
 Assignment multiplication operator for built-in integral types.
 
gpu constexpr friend auto operator*= (Aeu &multiplication, const Aeu &factor) noexcept -> Aeu &
 Assignment multiplication operator.
 
gpu constexpr friend auto operator/ (const Aeu &division, const Aeu &divisor) noexcept -> Aeu
 Division operator.
 
gpu constexpr friend auto operator/= (Aeu &division, const Aeu &divisor) noexcept -> Aeu &
 Assignment division operator.
 
gpu constexpr friend auto operator% (const Aeu &modulation, const Aeu &modulo) noexcept -> Aeu
 Modulo operator.
 
gpu constexpr friend auto operator%= (Aeu &modulation, const Aeu &modulo) noexcept -> Aeu &
 Assignment modulo operator.
 
gpu constexpr friend auto operator^ (const Aeu &left, const Aeu &right) noexcept -> Aeu
 Bitwise XOR operator.
 
gpu constexpr friend auto operator^= (Aeu &left, const Aeu &right) noexcept -> Aeu &
 Assignment bitwise XOR operator.
 
gpu constexpr friend auto operator& (const Aeu &left, const Aeu &right) noexcept -> Aeu
 Bitwise AND operator.
 
gpu constexpr friend auto operator&= (Aeu &left, const Aeu &right) noexcept -> Aeu &
 Assignment bitwise AND operator.
 
gpu constexpr friend auto operator| (const Aeu &left, const Aeu &right) noexcept -> Aeu
 Bitwise OR operator.
 
gpu constexpr friend auto operator|= (Aeu &left, const Aeu &right) noexcept -> Aeu &
 Assignment bitwise OR operator.
 
template<typename Unsigned >
requires (std::is_integral_v<Unsigned> && std::is_unsigned_v<Unsigned>)
gpu constexpr friend auto operator<< (const Aeu &value, Unsigned bitShift) noexcept -> Aeu
 Left shift operator.
 
template<typename Unsigned >
requires (std::is_integral_v<Unsigned> && std::is_unsigned_v<Unsigned>)
gpu constexpr friend auto operator<<= (Aeu &value, Unsigned bitShift) noexcept -> Aeu &
 Left shift assignment operator.
 
template<typename Unsigned >
requires (std::is_integral_v<Unsigned> && std::is_unsigned_v<Unsigned>)
gpu constexpr friend auto operator>> (const Aeu &value, Unsigned bitShift) noexcept -> Aeu
 Right shift operator.
 
template<typename Unsigned >
requires (std::is_integral_v<Unsigned> && std::is_unsigned_v<Unsigned>)
gpu constexpr friend auto operator>>= (Aeu &value, Unsigned bitShift) noexcept -> Aeu &
 Right shift assignment operator.
 
template<typename Unsigned >
requires (std::is_unsigned_v<Unsigned> && sizeof(Unsigned) < 8)
gpu constexpr friend auto operator== (const Aeu &our, Unsigned other) noexcept -> bool
 Equality check operator for built-in types uint8_t, uint16_t, uint32_t.
 
gpu constexpr friend auto operator== (const Aeu &our, uint64_t other) noexcept -> bool
 
gpu constexpr friend auto operator== (const Aeu &our, const Aeu &other) noexcept -> bool=default
 Equality check operator for numbers of the same precision.
 
template<std::size_t otherBitness>
requires (otherBitness != bitness)
gpu constexpr friend auto operator== (const Aeu &our, const Aeu< otherBitness > &other) noexcept -> bool
 Templated Equality check operator for numbers of different precision.
 
template<typename Char >
requires (std::is_same_v<Char, char> || std::is_same_v<Char, wchar_t>)
constexpr auto operator<< (std::basic_ostream< Char > &os, const Aeu &number) -> std::basic_ostream< Char > &
 STD stream output operator.
 

Detailed Description

template<std::size_t bitness = 512>
requires (bitness % blockBitLength == 0)
class Aeu< bitness >

Long precision unsigned integer.

May be used to represent only positive integers. Number precision is set in template parameter bitness.

Constructor & Destructor Documentation

◆ Aeu() [1/4]

template<std::size_t bitness = 512>
template<typename Integral >
requires (std::is_unsigned_v<Integral>)
gpu constexpr Aeu< bitness >::Aeu ( Integral value)
inlineconstexprnoexcept

Integral constructor.

Parameters
valueIntegral

Accepts both signed and unsigned built-in integral types. When calling this constructor on negative value, final blocks would be inverted.

Note
Be aware of calling this constructor explicitly

◆ Aeu() [2/4]

template<std::size_t bitness = 512>
template<typename Char >
requires (std::is_same_v<Char, char> || std::is_same_v<Char, wchar_t>)
gpu constexpr Aeu< bitness >::Aeu ( const Char * data,
std::size_t size )
inlineconstexprnoexcept

Pointer-based character constructor.

Parameters
dataChar*
sizeSize_t

Accepts decimal strings (no prefix), binary (0b/0B), octal (0o/0O) and hexadecimal (0x/0X)

◆ Aeu() [3/4]

template<std::size_t bitness = 512>
template<typename Char , std::size_t arrayLength>
requires (arrayLength > 1 && (std::is_same_v<Char, char> || std::is_same_v<Char, wchar_t>))
gpu constexpr Aeu< bitness >::Aeu ( const Char(&) literal[arrayLength])
inlineconstexprnoexcept

C-style string literal constructor.

Parameters
literalChar[]

Accepts decimal literals along with binary (starting with 0b/0B), octal (0o/0O) and hexadecimal (0x/0X)

◆ Aeu() [4/4]

template<std::size_t bitness = 512>
template<typename String , typename Char = typename String::value_type>
requires (std::is_same_v<std::basic_string<Char>, std::decay_t<String>> || std::is_same_v<std::basic_string_view<Char>, std::decay_t<String>>)
gpu constexpr Aeu< bitness >::Aeu ( String && stringView)
inlineconstexprnoexcept

String or string-view based constructor.

Parameters
stringViewString/String-View

Constructs object from STD::Basic_String or STD::Basic_String_View. Accepts objects based on char or wchar_t

Member Function Documentation

◆ operator=()

template<std::size_t bitness = 512>
gpu constexpr Aeu & Aeu< bitness >::operator= ( const Aeu< bitness > & other)
constexprdefault

Copy assignment operator.

Parameters
otherAeu

◆ operator+()

template<std::size_t bitness = 512>
gpu constexpr auto Aeu< bitness >::operator+ ( ) const -> Aeu
inlinenodiscardconstexprnoexcept

Unary plus operator.

Returns
Aeu
Note
Does basically nothing

◆ operator-()

template<std::size_t bitness = 512>
gpu constexpr auto Aeu< bitness >::operator- ( ) const -> Aeu
inlinenodiscardconstexprnoexcept

Unary minus operator.

Returns
Aeu

◆ operator++() [1/2]

template<std::size_t bitness = 512>
gpu constexpr auto Aeu< bitness >::operator++ ( ) -> Aeu&
inlineconstexprnoexcept

Prefix increment.

Returns
Aeu&

◆ operator++() [2/2]

template<std::size_t bitness = 512>
gpu constexpr auto Aeu< bitness >::operator++ ( int ) & -> Aeu
inlineconstexprnoexcept

Postfix increment.

Returns
Aeu

◆ operator--() [1/2]

template<std::size_t bitness = 512>
gpu constexpr auto Aeu< bitness >::operator-- ( ) -> Aeu&
inlineconstexprnoexcept

Prefix decrement.

Returns
Aeu&

◆ operator--() [2/2]

template<std::size_t bitness = 512>
gpu constexpr auto Aeu< bitness >::operator-- ( int ) & -> Aeu
inlineconstexprnoexcept

Postfix decrement.

Returns
Aeu

◆ operator~()

template<std::size_t bitness = 512>
gpu constexpr auto Aeu< bitness >::operator~ ( ) const -> Aeu
inlinenodiscardconstexprnoexcept

Bitwise complement operator.

Returns
Aeu

◆ compareTo() [1/3]

template<std::size_t bitness = 512>
template<typename Unsigned >
requires (std::is_unsigned_v<Unsigned> && sizeof(Unsigned) < 8)
gpu constexpr auto Aeu< bitness >::compareTo ( Unsigned other) const -> Comparison
inlinenodiscardconstexprnoexcept

Internal comparison operator for built-in integral types uint8_t, uint16_t, uint32_t.

Parameters
otherUnsigned
Returns
Comparison
Note
Should almost never return Comparison::Equivalent

◆ compareTo() [2/3]

template<std::size_t bitness = 512>
gpu constexpr auto Aeu< bitness >::compareTo ( uint64_t other) const -> Comparison
inlinenodiscardconstexprnoexcept

Internal comparison operator for type uint64_t.

Parameters
otheruint64_t
Returns
Comparison
Note
Should almost never return Comparison::Equivalent

◆ compareTo() [3/3]

template<std::size_t bitness = 512>
template<std::size_t otherBitness = bitness>
gpu constexpr auto Aeu< bitness >::compareTo ( const Aeu< otherBitness > & other) const -> Comparison
inlinenodiscardconstexprnoexcept

Internal comparison operator.

Parameters
otherAeu
Returns
Comparison
Note
Should almost never return Comparison::Equivalent

◆ operator<=>() [1/2]

template<std::size_t bitness = 512>
gpu constexpr auto Aeu< bitness >::operator<=> ( const Aeu< bitness > & other) const -> std::strong_ordering
inlineconstexprnoexcept

Three-way comparison operator.

Parameters
otherAeu
Returns
Std::Strong_ordering
Note
Available from C++20 standard and further. Should almost never return Strong_ordering::Equivalent

◆ operator<=>() [2/2]

template<std::size_t bitness = 512>
template<typename Unsigned >
gpu constexpr auto Aeu< bitness >::operator<=> ( const Unsigned & other) const -> std::strong_ordering
inlineconstexprnoexcept

Three-way comparison operator for numbers of different precision and built-in integral types.

Parameters
otherIntegral
Returns
Std::Strong_ordering
Note
Available from C++20 standard and further. Should almost never return Strong_ordering::Equivalent

◆ setBit()

template<std::size_t bitness = 512>
gpu constexpr auto Aeu< bitness >::setBit ( std::size_t index,
bool bit ) -> void
inlineconstexprnoexcept

Set a bit in number by index starting from the right.

Parameters
indexSize_t
bitBoolean
Note
Does nothing for index out of range

◆ getBit()

template<std::size_t bitness = 512>
gpu constexpr auto Aeu< bitness >::getBit ( std::size_t index) const -> bool
inlinenodiscardconstexprnoexcept

Get bit in number by index staring from the right.

Parameters
indexSize_t
Returns
Boolean
Note
Returns zero for index out of range

◆ setByte()

template<std::size_t bitness = 512>
gpu constexpr auto Aeu< bitness >::setByte ( std::size_t index,
byte byte ) -> void
inlineconstexprnoexcept

Set byte in number by index starting from the right.

Parameters
indexSize_t
byteByte
Note
Does nothing for index out of range

◆ getByte()

template<std::size_t bitness = 512>
gpu constexpr auto Aeu< bitness >::getByte ( std::size_t index) const -> byte
inlinenodiscardconstexprnoexcept

Get byte in number by index starting from the right.

Parameters
indexSize_t
Returns
Byte
Note
Returns zero for index out of range

◆ setBlock()

template<std::size_t bitness = 512>
gpu constexpr auto Aeu< bitness >::setBlock ( std::size_t index,
block block ) -> void
inlineconstexprnoexcept

Set block in number by index starting from the right.

Parameters
indexSize_t
blockBlock
Note
Does nothing for index out of range. Index check is disabled in unsafe mode.

◆ getBlock()

template<std::size_t bitness = 512>
gpu constexpr auto Aeu< bitness >::getBlock ( std::size_t index) const -> block
inlinenodiscardconstexprnoexcept

Get block in number by index starting from the right.

Parameters
indexSize_t
Returns
Block
Note
Returns zero for index out of range. Index check is disabled in unsafe mode.

◆ byteCount()

template<std::size_t bitness = 512>
gpu constexpr auto Aeu< bitness >::byteCount ( ) const -> std::size_t
inlinenodiscardconstexprnoexcept

Get amount of non-empty bytes in number right to left.

Returns
Size_t

◆ bitCount()

template<std::size_t bitness = 512>
gpu constexpr auto Aeu< bitness >::bitCount ( ) const -> std::size_t
inlinenodiscardconstexprnoexcept

Get amount of non-empty bits in number right to left.

Returns
Size_t

◆ isOdd()

template<std::size_t bitness = 512>
gpu constexpr auto Aeu< bitness >::isOdd ( ) const -> bool
inlinenodiscardconstexprnoexcept

Check whether number is odd.

Returns
Boolean: true is number is odd and false otherwise

◆ isEven()

template<std::size_t bitness = 512>
gpu constexpr auto Aeu< bitness >::isEven ( ) const -> bool
inlinenodiscardconstexprnoexcept

Check whether number is even.

Returns
Boolean: true if the number is even and false otherwise

◆ isZero()

template<std::size_t bitness = 512>
gpu constexpr auto Aeu< bitness >::isZero ( ) const -> bool
inlinenodiscardconstexprnoexcept

Check whether number is zero.

Returns
Boolean: true if the number is zero and false otherwise

◆ filledBlocksNumber()

template<std::size_t bitness = 512>
gpu constexpr auto Aeu< bitness >::filledBlocksNumber ( ) const -> std::size_t
inlinenodiscardconstexprnoexcept

Get number of non-empty blocks inside object starting from the right.

Returns
Size_t

◆ getBitness()

template<std::size_t bitness = 512>
static gpu constexpr auto Aeu< bitness >::getBitness ( ) -> std::size_t
inlinestaticnodiscardconstexprnoexcept

Get number's precision.

Returns
Size_t

◆ totalBlocksNumber()

template<std::size_t bitness = 512>
static gpu constexpr auto Aeu< bitness >::totalBlocksNumber ( ) -> std::size_t
inlinestaticnodiscardconstexprnoexcept

Get the number of blocks (length of array of uint32_t integers) inside object.

Returns
Size_t

◆ swap()

template<std::size_t bitness = 512>
gpu constexpr auto Aeu< bitness >::swap ( Aeu< bitness > & other) -> void
inlineconstexprnoexcept

Make swap between two objects.

Parameters
otherAeu

◆ divide() [1/2]

template<std::size_t bitness = 512>
static gpu constexpr auto Aeu< bitness >::divide ( const Aeu< bitness > & number,
const Aeu< bitness > & divisor,
Aeu< bitness > & quotient,
Aeu< bitness > & remainder ) -> void
inlinestaticconstexprnoexcept

Integer division. Returns results by reference.

Parameters
numberAeu
divisorAeu
quotientAeu OUT
remainderAeu OUT
Returns
Quotient and remainder by reference

◆ divide() [2/2]

template<std::size_t bitness = 512>
static gpu constexpr auto Aeu< bitness >::divide ( const Aeu< bitness > & number,
const Aeu< bitness > & divisor ) -> pair<Aeu, Aeu>
inlinestaticnodiscardconstexprnoexcept

Integer division. Returns results by value.

Parameters
numberAeu
divisorAeu
Returns
Pair(Quotient, Remainder)

◆ gcd() [1/2]

template<std::size_t bitness = 512>
static gpu constexpr auto Aeu< bitness >::gcd ( const Aeu< bitness > & first,
const Aeu< bitness > & second,
Aeu< bitness > & bezoutX,
Aeu< bitness > & bezoutY ) -> Aeu
inlinestaticconstexprnoexcept

Extended Euclidean algorithm for greatest common divisor.

Parameters
firstAeu
secondAeu
bezoutXAeu OUT
bezoutYAeu OUT
Returns
Aeu

Counts Bézout coefficients along with the greatest common divisor. Returns coefficients by reference

◆ gcd() [2/2]

template<std::size_t bitness = 512>
static gpu constexpr auto Aeu< bitness >::gcd ( const Aeu< bitness > & first,
const Aeu< bitness > & second ) -> Aeu
inlinestaticconstexprnoexcept

Greatest common divisor.

Parameters
firstAeu
secondAeu
Returns
Aeu

Faster version, ignoring bezout coefficients

◆ lcm()

template<std::size_t bitness = 512>
static gpu constexpr auto Aeu< bitness >::lcm ( const Aeu< bitness > & first,
const Aeu< bitness > & second ) -> Aeu
inlinestaticnodiscardconstexprnoexcept

Least common multiplier.

Parameters
firstAeu
secondAeu
Returns
Aeu

◆ powm()

template<std::size_t bitness = 512>
template<std::size_t powerBitness = bitness>
static gpu constexpr auto Aeu< bitness >::powm ( const Aeu< bitness > & base,
const Aeu< powerBitness > & power,
const Aeu< bitness > & modulo ) -> Aeu
inlinestaticnodiscardconstexprnoexcept

Exponentiation by modulo.

Parameters
baseAeu
powerAeu
moduloAeu
Returns
Aeu
Note
Be aware of overflow

Accepts power of different precision rather than base and modulo

◆ power2()

template<std::size_t bitness = 512>
static gpu constexpr auto Aeu< bitness >::power2 ( std::size_t power) -> Aeu
inlinestaticnodiscardconstexprnoexcept

Fast exponentiation for powers of 2.

Parameters
powerSize_t
Returns
Aeu

Returns zero for power greater than current bitness

◆ squareRoot()

template<std::size_t bitness = 512>
gpu constexpr auto Aeu< bitness >::squareRoot ( ) const -> Aeu
inlinenodiscardconstexprnoexcept

Get square root.

Returns
Aeu
Note
Returns zero for negative value or zero

◆ getString()

template<std::size_t bitness = 512>
template<byte base, typename Char >
requires (std::is_same_v<Char, char> || std::is_same_v<Char, wchar_t> && (base == 2 || base == 8 || base == 10 || base == 16))
gpu constexpr auto Aeu< bitness >::getString ( Char *const buffer,
std::size_t bufferSize,
bool showBase = false,
bool hexUppercase = false ) const -> std::size_t
inlineconstexprnoexcept

Character buffer output operator.

Parameters
bufferChar*
bufferSizeSize_t
showBaseBoolean
hexUppercaseBoolean
Returns
Size_t - amount of symbols written

Places the maximum possible amount of number's characters in buffer. Base parameter should be 2, 8, 10, or 16

Note
Works significantly faster for hexadecimal notation

◆ readBinary()

template<std::size_t bitness = 512>
template<typename Char >
requires (std::is_same_v<Char, char> || std::is_same_v<Char, wchar_t>)
auto Aeu< bitness >::readBinary ( std::basic_istream< Char > & is,
bool bigEndian = true ) -> void
inlineconstexpr

STD stream binary reading operator.

Parameters
isIstream
bigEndianBoolean
Returns
Aeu

Reads number from stream using .read method. Accepts STD streams based on char or wchar_t.

Note
Fills empty bits with 0s on EOF of the stream

◆ writeBinary()

template<std::size_t bitness = 512>
template<typename Char >
requires (std::is_same_v<Char, char> || std::is_same_v<Char, wchar_t>)
auto Aeu< bitness >::writeBinary ( std::basic_ostream< Char > & os,
bool bigEndian = true ) const -> void
inlineconstexprnoexcept

STD stream binary writing operator.

Parameters
osOstream
bigEndianBoolean

Writes number in stream using .write method. Accepts STD streams based on char or wchar_t.

◆ integralCast()

template<std::size_t bitness = 512>
template<typename Integral >
requires (std::is_integral_v<Integral>)
gpu constexpr auto Aeu< bitness >::integralCast ( ) const -> Integral
inlinenodiscardconstexprnoexcept

Integral type cast operator for built-in types.

Returns
Integral

Takes the lowest part of Aeu for conversion. Accepts signed and unsigned types

◆ precisionCast()

template<std::size_t bitness = 512>
template<std::size_t newBitness>
requires (newBitness != bitness)
gpu constexpr auto Aeu< bitness >::precisionCast ( ) const -> Aeu<newBitness>
inlinenodiscardconstexprnoexcept

Precision cast operator.

Returns
Aeu<new_bitness>

If required precision greater than current precision, remaining blocks are filled with zeros. Otherwise - number is cropped inside smaller blocks array

Note
Using this method directly is not recommended, cause it leads to redundant copying and may be slow

Friends And Related Symbol Documentation

◆ operator+ [1/2]

template<std::size_t bitness = 512>
template<typename Unsigned >
requires (std::is_unsigned_v<Unsigned>)
gpu constexpr friend auto operator+ ( const Aeu< bitness > & addition,
Unsigned addendum ) -> Aeu
friend

Addition operator for built-in integral types.

Parameters
additionAeu
addendumUnsigned
Returns
Aeu

◆ operator+ [2/2]

template<std::size_t bitness = 512>
gpu constexpr friend auto operator+ ( const Aeu< bitness > & addition,
const Aeu< bitness > & addendum ) -> Aeu
friend

Addition operator.

Parameters
additionAeu
addendumAeu
Returns
Aeu

◆ operator+= [1/2]

template<std::size_t bitness = 512>
template<typename Unsigned >
requires (std::is_unsigned_v<Unsigned>)
gpu constexpr friend auto operator+= ( Aeu< bitness > & addition,
Unsigned addendum ) -> Aeu&
friend

Assignment addition operator for built-in integral types.

Parameters
additionAeu
addendumUnsigned
Returns
Aeu&

◆ operator+= [2/2]

template<std::size_t bitness = 512>
gpu constexpr friend auto operator+= ( Aeu< bitness > & addition,
const Aeu< bitness > & addendum ) -> Aeu&
friend

Assignment addition operator.

Parameters
additionAeu
addendumAeu
Returns
Aeu&

◆ operator-

template<std::size_t bitness = 512>
gpu constexpr friend auto operator- ( const Aeu< bitness > & subtraction,
const Aeu< bitness > & subtrahend ) -> Aeu
friend

Subtraction operator.

Parameters
subtractionAeu
subtrahendAeu
Returns
Aeu

◆ operator-=

template<std::size_t bitness = 512>
gpu constexpr friend auto operator-= ( Aeu< bitness > & subtraction,
const Aeu< bitness > & subtrahend ) -> Aeu&
friend

Assignment subtraction operator.

Parameters
subtractionAeu
subtrahendAeu
Returns
Aeu&

◆ operator* [1/2]

template<std::size_t bitness = 512>
template<typename Unsigned >
requires (std::is_unsigned_v<Unsigned>)
gpu constexpr friend auto operator* ( Aeu< bitness > & multiplication,
Unsigned factor ) -> Aeu
friend

Multiplication operator for built-in integral types.

Parameters
multiplicationAeu
factorUnsigned
Returns
Aeu

◆ operator* [2/2]

template<std::size_t bitness = 512>
gpu constexpr friend auto operator* ( const Aeu< bitness > & multiplication,
const Aeu< bitness > & factor ) -> Aeu
friend

Multiplication operator.

Parameters
multiplicationAeu
factorAeu
Returns
Aeu

◆ operator*= [1/2]

template<std::size_t bitness = 512>
template<typename Unsigned >
requires (std::is_unsigned_v<Unsigned>)
gpu constexpr friend auto operator*= ( Aeu< bitness > & multiplication,
Unsigned factor ) -> Aeu&
friend

Assignment multiplication operator for built-in integral types.

Parameters
multiplicationAeu
factorUnsigned
Returns
Aeu&

Works with the greatest performance with types smaller than uint64_t

◆ operator*= [2/2]

template<std::size_t bitness = 512>
gpu constexpr friend auto operator*= ( Aeu< bitness > & multiplication,
const Aeu< bitness > & factor ) -> Aeu&
friend

Assignment multiplication operator.

Parameters
multiplicationAeu
factorAeu
Returns
Aeu&

◆ operator/

template<std::size_t bitness = 512>
gpu constexpr friend auto operator/ ( const Aeu< bitness > & division,
const Aeu< bitness > & divisor ) -> Aeu
friend

Division operator.

Parameters
divisionAeu
divisorAeu
Returns
Aeu
Note
Undefined behaviour for division by zero

◆ operator/=

template<std::size_t bitness = 512>
gpu constexpr friend auto operator/= ( Aeu< bitness > & division,
const Aeu< bitness > & divisor ) -> Aeu&
friend

Assignment division operator.

Parameters
divisionAeu
divisorAeu
Returns
Aeu&
Note
Undefined behaviour for division by zero

◆ operator%

template<std::size_t bitness = 512>
gpu constexpr friend auto operator% ( const Aeu< bitness > & modulation,
const Aeu< bitness > & modulo ) -> Aeu
friend

Modulo operator.

Parameters
modulationAeu
moduloAeu
Returns
Aeu

◆ operator%=

template<std::size_t bitness = 512>
gpu constexpr friend auto operator%= ( Aeu< bitness > & modulation,
const Aeu< bitness > & modulo ) -> Aeu&
friend

Assignment modulo operator.

Parameters
modulationAeu
moduloAeu
Returns
Aeu&

◆ operator^

template<std::size_t bitness = 512>
gpu constexpr friend auto operator^ ( const Aeu< bitness > & left,
const Aeu< bitness > & right ) -> Aeu
friend

Bitwise XOR operator.

Parameters
leftAeu
rightAeu
Returns
Aeu

◆ operator^=

template<std::size_t bitness = 512>
gpu constexpr friend auto operator^= ( Aeu< bitness > & left,
const Aeu< bitness > & right ) -> Aeu&
friend

Assignment bitwise XOR operator.

Parameters
leftAeu
rightAeu
Returns
Aeu&

◆ operator&

template<std::size_t bitness = 512>
gpu constexpr friend auto operator& ( const Aeu< bitness > & left,
const Aeu< bitness > & right ) -> Aeu
friend

Bitwise AND operator.

Parameters
leftAeu
rightAeu
Returns
Aeu

◆ operator&=

template<std::size_t bitness = 512>
gpu constexpr friend auto operator&= ( Aeu< bitness > & left,
const Aeu< bitness > & right ) -> Aeu&
friend

Assignment bitwise AND operator.

Parameters
leftAeu
rightAeu
Returns
Aeu&

◆ operator|

template<std::size_t bitness = 512>
gpu constexpr friend auto operator| ( const Aeu< bitness > & left,
const Aeu< bitness > & right ) -> Aeu
friend

Bitwise OR operator.

Parameters
leftAeu
rightAeu
Returns
Aeu

◆ operator|=

template<std::size_t bitness = 512>
gpu constexpr friend auto operator|= ( Aeu< bitness > & left,
const Aeu< bitness > & right ) -> Aeu&
friend

Assignment bitwise OR operator.

Parameters
leftAeu
rightAeu
Returns
Aeu&

◆ operator<< [1/2]

template<std::size_t bitness = 512>
template<typename Unsigned >
requires (std::is_integral_v<Unsigned> && std::is_unsigned_v<Unsigned>)
gpu constexpr friend auto operator<< ( const Aeu< bitness > & value,
Unsigned bitShift ) -> Aeu
friend

Left shift operator.

Parameters
valueAeu
bitShiftUnsigned
Returns
Aeu
Note
Does nothing for shift greater than precision

◆ operator<<=

template<std::size_t bitness = 512>
template<typename Unsigned >
requires (std::is_integral_v<Unsigned> && std::is_unsigned_v<Unsigned>)
gpu constexpr friend auto operator<<= ( Aeu< bitness > & value,
Unsigned bitShift ) -> Aeu&
friend

Left shift assignment operator.

Parameters
valueAeu
bitShiftUnsigned
Returns
Aeu&
Note
Does nothing for shift greater than precision

◆ operator>>

template<std::size_t bitness = 512>
template<typename Unsigned >
requires (std::is_integral_v<Unsigned> && std::is_unsigned_v<Unsigned>)
gpu constexpr friend auto operator>> ( const Aeu< bitness > & value,
Unsigned bitShift ) -> Aeu
friend

Right shift operator.

Parameters
valueAeu
bitShiftUnsigned
Returns
Aeu
Note
Does nothing for shift greater than precision

◆ operator>>=

template<std::size_t bitness = 512>
template<typename Unsigned >
requires (std::is_integral_v<Unsigned> && std::is_unsigned_v<Unsigned>)
gpu constexpr friend auto operator>>= ( Aeu< bitness > & value,
Unsigned bitShift ) -> Aeu&
friend

Right shift assignment operator.

Parameters
valueAeu
bitShiftUnsigned
Returns
Aeu&
Note
Does nothing for shift greater than precision

◆ operator== [1/3]

template<std::size_t bitness = 512>
template<typename Unsigned >
requires (std::is_unsigned_v<Unsigned> && sizeof(Unsigned) < 8)
gpu constexpr friend auto operator== ( const Aeu< bitness > & our,
Unsigned other ) -> bool
friend

Equality check operator for built-in types uint8_t, uint16_t, uint32_t.

Parameters
ourAeu
otherUnsigned
Returns
Boolean

◆ operator== [2/3]

template<std::size_t bitness = 512>
gpu constexpr friend auto operator== ( const Aeu< bitness > & our,
const Aeu< bitness > & other ) -> bool=default
friend

Equality check operator for numbers of the same precision.

Parameters
ourAeu
otherAeu
Returns
Boolean

◆ operator== [3/3]

template<std::size_t bitness = 512>
template<std::size_t otherBitness>
requires (otherBitness != bitness)
gpu constexpr friend auto operator== ( const Aeu< bitness > & our,
const Aeu< otherBitness > & other ) -> bool
friend

Templated Equality check operator for numbers of different precision.

Parameters
ourAeu
otherAeu
Returns
Boolean

◆ operator<< [2/2]

template<std::size_t bitness = 512>
template<typename Char >
requires (std::is_same_v<Char, char> || std::is_same_v<Char, wchar_t>)
auto operator<< ( std::basic_ostream< Char > & os,
const Aeu< bitness > & number ) -> std::basic_ostream<Char>&
friend

STD stream output operator.

Parameters
osOstream
numberAeu
Returns
Ostream

Writes number in stream. Accepts STD streams based on char or wchar_t. Supports stream manipulators:

  • Number's notation (std::hex, std::dec, std::oct);
  • Number's base (std::showbase);
  • Hexadecimal letters case (std::uppercase, std::lowercase)
    Note
    Works significantly faster for hexadecimal notation

The documentation for this class was generated from the following file: