Aesi Multiprecision
C++ class library of long integer arithmetic for GPU parallelization
Typedefs | Functions | Variables
Aesi.h File Reference

Long precision signed integer with arithmetic operations. More...

Go to the source code of this file.

Typedefs

using Aesi128 = Aesi< 128 >
 Number with precision 128-bit.
 
using Aesi256 = Aesi< 256 >
 Number with precision 128-bit.
 
using Aesi512 = Aesi< 512 >
 Number with precision 512-bit.
 
using Aesi768 = Aesi< 768 >
 Number with precision 768-bit.
 
using Aesi1024 = Aesi< 1024 >
 Number with precision 1024-bit.
 
using Aesi1536 = Aesi< 1536 >
 Number with precision 1536-bit.
 
using Aesi2048 = Aesi< 2048 >
 Number with precision 2048-bit.
 
using Aesi3072 = Aesi< 3072 >
 Number with precision 3072-bit.
 
using Aesi4096 = Aesi< 4096 >
 Number with precision 4096-bit.
 
using Aesi6144 = Aesi< 6144 >
 Number with precision 6144-bit.
 
using Aesi8192 = Aesi< 8192 >
 Number with precision 8192-bit.
 

Functions

template<std::size_t bitness = 512>
 requires (bitness % blockBitLength==0) class Aesi final
 
template<std::size_t bitness, typename Integral >
 requires (std::is_integral_v< Integral >) gpu const expr auto operator+(Integral number
 Integral conversion addition operator. More...
 
template<std::size_t bitness, typename Integral >
 requires (std::is_integral_v< Integral >) gpu const expr auto operator&(Integral number
 Integral conversion bitwise AND operator. More...
 

Variables

const Aesi< bitness > &value noexcept { return Aesi<bitness>(number) + value
 

Detailed Description

Long precision signed integer with arithmetic operations.

Function Documentation

◆ requires() [1/3]

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

Default constructor

Copy constructor

Parameters
copyAesi&

Integral constructor

Parameters
valueIntegral

Pointer-based character constructor

Parameters
ptrChar*
sizeSize_t

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

Note
An odd number of dashes makes the number negative

C-style string literal constructor

Parameters
literalChar[]

String / String-view constructor

Parameters
stringViewString

Unsigned integer conversion

Parameters
valueAeu&

Integral assignment operator

Parameters
valueIntegral

Copy assignment operator

Parameters
otherAesi&

Unary plus operator

Does basically nothing

Returns
Aesi

Unary minus operator

Returns
Aesi

Prefix increment operator

Returns
Aesi&

Postfix increment operator

Returns
Aesi

Prefix decrement operator

Returns
Aesi&

Postfix decrement operator

Returns
Aesi

Adition operator

Parameters
addendumAesi&
Returns
Aesi

Addition assignment operator

Parameters
addendumAesi&
Returns
Aesi&

Subtraction operator

Parameters
subtrahendAesi&
Returns
Aesi

Subtraction assignment operator

Parameters
subtrahendAesi&
Returns
Aesi&

Multiplication operator for built-in types

Parameters
factorIntegral
Returns
Aesi

Multiplication operator

Parameters
factorAesi&
Returns
Aesi

Multiplication assignment operator for built-in types

Parameters
factorIntegral
Returns
Aesi&

Multiplication assignment operator

Parameters
factorAesi&
Returns
Aesi&

Division operator for built-in integral types

Parameters
divisorIntegral
Returns
Aesi
Note
Undefined behaviour for division by zero

Division operator

Parameters
divisorAesi
Returns
Aesi
Note
Undefined behaviour for division by zero

Assignment division operator for built-in integral types

Parameters
divisorIntegral
Returns
Aesi&
Note
Undefined behaviour for division by zero

Assignment division operator

Parameters
divisorAesi
Returns
Aesi&
Note
Undefined behaviour for division by zero

Modulo operator for built-in types

Parameters
moduloIntegral
Returns
Aesi
Note
Returns zero for the modulo of zero

Modulo operator

Parameters
moduloAesi&
Returns
Aesi

DETAILS

Note
Returns zero for the modulo of zero

Modulo assignment operator for built-in types

Parameters
moduloIntegral
Returns
Aesi&
Note
Returns zero for the modulo of zero

Modulo assignment operator

Parameters
moduloAesi&
Returns
Aesi&

DETAILS

Note
Returns zero for the modulo of zero

Equality operator for built-in types

Parameters
integralIntegral
Returns
bool

Equality operator

Parameters
otherAesi&
Returns
bool

Different precision equlity operator

Parameters
otherAesi&
Returns
bool

Comparison operator for built-in types

Parameters
integralIntegral
Returns
Comparison

Different precision comparison operator

Parameters
valueAesi&
Returns
Comparison

Comparison operator

Parameters
valueAesi&
Returns
Comparison

Three-way comparison operator

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

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

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

Set bit in number by index starting from the right

Parameters
indexSize_t
bitBoolean
Note
Does nothing for index out of range. Does not affect sign

Get bit in number by index starting from the right

Parameters
indexSize_t
Returns
Boolean
Note
Returns zero for index out of range. Does not affect the sign

Set byte in number by index starting from the right

Parameters
indexSize_t
byteByte
Note
Does nothing for index out of range. Does not affect the sign

Get byte in number by index starting from the right

Parameters
indexSize_t
Returns
Byte
Note
Returns zero for index out of range. Does not affect the sign

Set block in number by index starting from the right

Parameters
indexSize_t
blockBlock
Note
Does nothing for index out of range. Does not affect the sign

Get block in number by index starting from the right

Parameters
indexSize_t
Returns
Block
Note
Returns zero for index out of range. Does not affect the sign

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

Returns
Size_t

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

Returns
Size_t

Check whether number is odd

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

Check whether number is even

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

Check whether number is zero

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

Check whether number is positive

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

Check whether number is negative

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

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

Returns
Size_t

Get number's precision

Returns
Size_t

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

Returns
Size_t

Make swap between two objects

Parameters
otherAesi

Invertes number's bitness

Turns negative to positive and otherwise. Leaves zero unchanges

Integral division

Parameters
numberAesi&
divisorAesi&
quotientAesi& OUT
remainderAesi& OUT

Returns values by references

Square root

Returns
Aesi

Returns zero for negative

Fast exponentiation of 2

Returns
Aesi

Cast for built-in integral types

Returns
Integral

Number's precision cast

Returns
Aesi<newBitness>

Unsigned cast

Returns
Aeu

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

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
    Atomicity-oriented object assignment operator
    Parameters
    Aesiassigning
    Note
    Method itself is not fully-atomic. There may be race conditions between two consecutive atomic calls on number blocks. This method is an interface for assigning encapsulated class members atomically one by one
    Atomicity-oriented object exchangement operator
    Parameters
    Aesiexchangeable
    Note
    Method itself is not fully-atomic. There may be race conditions between two consecutive atomic calls on number blocks. This method is an interface for exchanging encapsulated class members atomically one by one

◆ requires() [2/3]

template<std::size_t bitness, typename Integral >
requires ( std::is_integral_v< Integral >  ) const

Integral conversion addition operator.

Integral conversion bitwise OR operator.

Integral conversion bitwise XOR operator.

Integral conversion modulo operator.

Integral conversion division operator.

Integral conversion multiplication operator.

Integral conversion subtraction operator.

Parameters
numberIntegral
valueAesi
Returns
Aesi
Parameters
numberIntegral
valueAeu
Returns
Aeu

◆ requires() [3/3]

template<std::size_t bitness, typename Integral >
requires ( std::is_integral_v< Integral >  ) const &

Integral conversion bitwise AND operator.

Parameters
numberIntegral
valueAesi
Returns
Aesi