y-cruncher Multi-Precision Library

A Multi-threaded Multi-Precision Arithmetic Library

(Powered by y-cruncher)

(Last updated: March 3, 2016)

 

Shortcuts:

YMP Library:

Large Number Objects:

Low-Level Programming:

BigIntR - Large Integer (no RAII)

 

BigIntR is a "raw" subclass of BigInt.

 

 

Raw classes are bare metal objects that do not own the memory they reside in. While they are extremely difficult to use, they also provide the greatest degree of control and flexibility. For this reason, raw classes are the most performant object if used correctly.

 

More on "raw" classes.

 

 

BigIntR is not nearly as mature as BigFloatR since it is not used at all with y-cruncher.

 

 

 

 

 

 

 

 

 

 

 

 

Function List:

 

Inherited from BigInt:

Constructors:

Setters:

Basic Arithmetic:

Large Multiplication:

 

 

Constructors:

 

Since BigIntR does not own the buffers that it holds, they are all constructed from either raw pointers, or aliased from existing bignum objects.

 

 

Default:

BigIntR<u32_t>::BigIntR ();

BigIntR<u64_t>::BigIntR ();

 

Construct a new object in state 1 with everything uninitialized.

 

Construct from Raw Pointer:

BigIntR<u32_t>::BigIntR (u32_t* ptr, upL_t size);

BigIntR<u64_t>::BigIntR (u64_t* ptr, upL_t size);

 

Construct a new object in state 2 who's internal buffer is {ptr, size}.

 

Alias/Overlap to bottom of existing BigIntR object:

BigIntR<u32_t>::BigIntR (const BigIntR<u32_t>& x, upL_t L);

BigIntR<u64_t>::BigIntR (const BigIntR<u64_t>& x, upL_t L);

 

Construct a new object in state 2 who's internal buffer aliases with the bottom L words of the buffer of x. The new object will have a buffer size of L.

 

Alias/Overlap to middle of existing BigIntR object:

BigIntR<u32_t>::BigIntR (const BigIntR<u32_t>& x, upL_t s, upL_t L);

BigIntR<u64_t>::BigIntR (const BigIntR<u64_t>& x, upL_t s, upL_t L);

 

Construct a new object in state 2 who's internal buffer aliases the buffer range [s, s + L) of x. The new object will have a buffer size of L.

 

Alias/Overlap to end of existing BigIntR object:

BigIntR<u32_t>::BigIntR (upL_t L, const BigIntR<u32_t>& x);

BigIntR<u64_t>::BigIntR (upL_t L, const BigIntR<u64_t>& x);

 

Construct a new object in state 2 who's internal buffer aliases the upper L words of the buffer of x. The new object will have a buffer size of L.

 

Setters:

 

Set to Zero:

void BigIntR<u32_t>::set_zero ();

void BigIntR<u64_t>::set_zero ();

Description:

Set the current object to a value of zero.

Notes:

 


Set to Small Integer:

void BigIntR<u32_t>::set_uW (u32_t x);

void BigIntR<u64_t>::set_uW (u64_t x);

 

void BigIntR<u32_t>::set_uL (uiL_t x);

void BigIntR<u64_t>::set_uL (uiL_t x);

Description:

Set the current object to a value of x.

Notes:

 


Truncate from BigFloat:

void BigIntR<u32_t>::set_BigFloat (const BigFloat<u32_t>& x, upL_t p);

void BigIntR<u64_t>::set_BigFloat (const BigFloat<u64_t>& x, upL_t p);

Description:

Set the current object to a value of x. Rounding is done by truncating towards zero to the nearest integer.

Due to zero-filling, BigFloats with large exponents will require a large buffer.

Notes:

 

Basic Arithmetic:

 

Negate:

void BigIntR<u32_t>::negate ();

void BigIntR<u64_t>::negate ();

Description:

Negates this object.

Performance:

Notes:

 


Multiply by Power-of-Two:

void BigIntR<u32_t>::operator<<= (upL_t bits);

void BigIntR<u64_t>::operator<<= (upL_t bits);

Description:

Multiplies this object by 2pow.

Performance:

Notes:

 


Divide by Power-of-Two:

void BigIntR<u32_t>::operator>>= (upL_t bits);

void BigIntR<u64_t>::operator>>= (upL_t bits);

Description:

Divides this object by 2bits rounding towards zero.

Performance:

Notes:

 


Single-Word Multiply (In-Place):

void BigIntR<u32_t>::operator*= (u32_t x);

void BigIntR<u64_t>::operator*= (u64_t x);

Description:

Multiplies this object by x.

Performance:

Notes:

 


Single-Word Multiply (Out-of-Place):

void BigIntR<u32_t>::set_mul_uW (const BigInt<u32_t>& A, u32_t x);

void BigIntR<u64_t>::set_mul_uW (const BigInt<u64_t>& A, u64_t x);

Description:

Computes A * x and sets the value of the current object to the result.

Performance:

Notes:

 


Addition/Subtraction:

void BigIntR<u32_t>::set_add (const BigInt<u32_t>& A, const BigInt<u32_t>& B);

void BigIntR<u64_t>::set_add (const BigInt<u64_t>& A, const BigInt<u64_t>& B);

 

void BigIntR<u32_t>::set_sub (const BigInt<u32_t>& A, const BigInt<u32_t>& B);

void BigIntR<u64_t>::set_sub (const BigInt<u64_t>& A, const BigInt<u64_t>& B);

Description:

Computes A + B or A - B and sets the value of the current object to the result.

Performance:

Notes:

 

Large Multiplication:

 

Large Multiplication:

void BigIntR<u32_t>::set_sqr (const BasicParameters& mp, const BigInt<u32_t>& A);

void BigIntR<u64_t>::set_sqr (const BasicParameters& mp, const BigInt<u64_t>& A);

 

void BigIntR<u32_t>::set_mul (const BasicParameters& mp, const BigInt<u32_t>& A, const BigInt<u32_t>& B);

void BigIntR<u64_t>::set_mul (const BasicParameters& mp, const BigInt<u64_t>& A, const BigInt<u64_t>& B);

Description:

Computes A2 or A * B and sets the value of the current object to the result.

Performance:

BasicParameter (mp) Required Fields:

Notes: