Public Member Functions | Private Member Functions | Private Attributes | Friends | Related Functions | List of all members
vnl_bignum Class Reference

Infinite precision integers. More...

#include <vnl_bignum.h>

Public Member Functions

 vnl_bignum ()
 Creates a zero vnl_bignum. More...
 
 vnl_bignum (long)
 Creates a vnl_bignum from a long integer. More...
 
 vnl_bignum (unsigned long)
 Creates a vnl_bignum from an unsigned long integer. More...
 
 vnl_bignum (int)
 Creates a vnl_bignum from an integer. More...
 
 vnl_bignum (unsigned int)
 Creates a vnl_bignum from an unsigned integer. More...
 
 vnl_bignum (float)
 Creates a vnl_bignum from a single-precision floating point number. More...
 
 vnl_bignum (double)
 Creates a vnl_bignum from a double floating point number. More...
 
 vnl_bignum (long double)
 Creates a vnl_bignum from a "long double" floating point number. More...
 
 vnl_bignum (vnl_bignum const &)
 Copies the contents of vnl_bignum b. More...
 
 vnl_bignum (const char *)
 Creates a vnl_bignum from the character string representation. More...
 
 ~vnl_bignum ()
 Frees space for vnl_bignum. More...
 
 operator short () const
 Implicit conversion from a vnl_bignum to a short. More...
 
 operator int () const
 Implicit conversion from a vnl_bignum to an int. More...
 
 operator long () const
 Implicit conversion from a vnl_bignum to a long. More...
 
 operator float () const
 Implicit conversion from a vnl_bignum to a float. More...
 
 operator double () const
 Implicit conversion from a vnl_bignum to a double. More...
 
 operator long double () const
 Implicit conversion from a vnl_bignum to a long double. More...
 
 operator short ()
 
 operator int ()
 
 operator long ()
 
 operator float ()
 
 operator double ()
 
 operator long double ()
 
vnl_bignum operator- () const
 Returns the negation of a vnl_bignum. More...
 
vnl_bignum operator+ () const
 
vnl_bignumoperator= (const vnl_bignum &)
 Copies rhs vnl_bignum to lhs vnl_bignum. More...
 
vnl_bignum operator<< (int l) const
 Shifts bignum to the left l digits. More...
 
vnl_bignum operator>> (int l) const
 Shifts bignum to the right l digits. More...
 
vnl_bignum operator+ (vnl_bignum const &r) const
 Adds two vnl_bignums, and returns new sum. More...
 
vnl_bignumoperator+= (vnl_bignum const &r)
 
vnl_bignumoperator-= (vnl_bignum const &r)
 
vnl_bignumoperator *= (vnl_bignum const &r)
 Multiplies this with a vnl_bignum. More...
 
vnl_bignumoperator/= (vnl_bignum const &r)
 Divides this by a vnl_bignum. More...
 
vnl_bignumoperator%= (vnl_bignum const &r)
 Divides this by a vnl_bignum and replaces this by remainder. More...
 
vnl_bignumoperator<<= (int l)
 
vnl_bignumoperator>>= (int l)
 
vnl_bignumoperator++ ()
 prefix increment (++b). More...
 
vnl_bignumoperator-- ()
 decrement. More...
 
vnl_bignum operator++ (int)
 postfix increment (b++). More...
 
vnl_bignum operator-- (int)
 decrement. More...
 
bool operator== (vnl_bignum const &) const
 Two vnl_bignums are equal if and only if they have the same integer representation. More...
 
bool operator< (vnl_bignum const &) const
 Compares two vnl_bignums. More...
 
bool operator!= (vnl_bignum const &r) const
 
bool operator> (vnl_bignum const &r) const
 
bool operator<= (vnl_bignum const &r) const
 
bool operator>= (vnl_bignum const &r) const
 
bool operator== (long r) const
 
bool operator!= (long r) const
 
bool operator< (long r) const
 
bool operator> (long r) const
 
bool operator<= (long r) const
 
bool operator>= (long r) const
 
bool operator== (int r) const
 
bool operator!= (int r) const
 
bool operator< (int r) const
 
bool operator> (int r) const
 
bool operator<= (int r) const
 
bool operator>= (int r) const
 
bool operator== (double r) const
 
bool operator!= (double r) const
 
bool operator< (double r) const
 
bool operator> (double r) const
 
bool operator<= (double r) const
 
bool operator>= (double r) const
 
bool operator== (long double r) const
 
bool operator!= (long double r) const
 
bool operator< (long double r) const
 
bool operator> (long double r) const
 
bool operator<= (long double r) const
 
bool operator>= (long double r) const
 
vnl_bignum abs () const
 
bool is_infinity () const
 
bool is_plus_infinity () const
 
bool is_minus_infinity () const
 
void dump (std::ostream &=std::cout) const
 dump the contents of a vnl_bignum to a stream, default cout. More...
 

Private Member Functions

void xtoBigNum (const char *s)
 convert hex string to vnl_bignum. More...
 
int dtoBigNum (const char *s)
 Converts decimal string to a vnl_bignum. More...
 
void otoBigNum (const char *s)
 convert octal string to vnl_bignum. More...
 
void exptoBigNum (const char *s)
 convert exponential string to a vnl_bignum. More...
 
void resize (short)
 change the data allotment for a vnl_bignum. More...
 
vnl_bignumtrim ()
 trim non-infinite vnl_bignum of excess data allotment. More...
 

Private Attributes

unsigned short count
 
int sign
 
unsigned short * data
 

Friends

int magnitude_cmp (const vnl_bignum &, const vnl_bignum &)
 compare absolute values of two vnl_bignums. More...
 
void add (const vnl_bignum &, const vnl_bignum &, vnl_bignum &)
 add two non-infinite vnl_bignum values and save their sum. More...
 
void subtract (const vnl_bignum &, const vnl_bignum &, vnl_bignum &)
 subtract bmin from bmax (unsigned, non-infinite), result in diff. More...
 
void increment (vnl_bignum &bnum)
 Add 1 to bnum (unsigned, non-infinite). More...
 
void decrement (vnl_bignum &bnum)
 Subtract 1 from bnum (unsigned, non-infinite, non-zero). More...
 
void multiply_aux (const vnl_bignum &, unsigned short, vnl_bignum &, unsigned short)
 multiply a non-infinite vnl_bignum by a "single digit". More...
 
unsigned short normalize (const vnl_bignum &, const vnl_bignum &, vnl_bignum &, vnl_bignum &)
 normalize two vnl_bignums. More...
 
void divide_aux (const vnl_bignum &, unsigned short, vnl_bignum &, unsigned short &)
 divide a vnl_bignum by a "single digit". More...
 
unsigned short estimate_q_hat (const vnl_bignum &, const vnl_bignum &, unsigned short)
 estimate next dividend. More...
 
unsigned short multiply_subtract (vnl_bignum &, const vnl_bignum &, unsigned short, unsigned short)
 calculate u - v*q_hat. More...
 
void divide (const vnl_bignum &, const vnl_bignum &, vnl_bignum &, vnl_bignum &)
 divide b2 into b1, getting quotient q and remainder r. More...
 
vnl_bignum left_shift (const vnl_bignum &b1, int l)
 left shift (arithmetic) non-infinite vnl_bignum by positive number. More...
 
vnl_bignum right_shift (const vnl_bignum &b1, int l)
 right shift (arithmetic) non-infinite vnl_bignum by positive number. More...
 
std::ostream & operator<< (std::ostream &, const vnl_bignum &)
 Formatted output for bignum. More...
 
std::istream & operator>> (std::istream &, vnl_bignum &)
 Reads a vnl_bignum from a stream. More...
 
VNL_EXPORT std::string & vnl_bignum_to_string (std::string &s, const vnl_bignum &b)
 Convert the number to a decimal representation in a string. More...
 
VNL_EXPORT vnl_bignumvnl_bignum_from_string (vnl_bignum &b, const std::string &s)
 Convert the number from a decimal representation in a string. More...
 

Related Functions

(Note that these are not member functions.)

void vsl_b_write (vsl_b_ostream &os, vnl_bignum const &v)
 Binary save vnl_bignum to stream. More...
 
void vsl_b_read (vsl_b_istream &is, vnl_bignum &v)
 Binary load vnl_bignum from stream. More...
 
void vsl_print_summary (std::ostream &os, vnl_bignum const &b)
 Print human readable summary of object to a stream. More...
 
vnl_bignum operator+ (vnl_bignum const &r1, long r2)
 Returns the sum of two bignum numbers. More...
 
vnl_bignum operator- (vnl_bignum const &r1, vnl_bignum const &r2)
 Returns the difference of two bignum numbers. More...
 
vnl_bignum operator * (vnl_bignum const &r1, vnl_bignum const &r2)
 Returns the product of two bignum numbers. More...
 
vnl_bignum operator/ (vnl_bignum const &r1, vnl_bignum const &r2)
 Returns the division of two bignum numbers. More...
 
vnl_bignum operator% (vnl_bignum const &r1, vnl_bignum const &r2)
 Returns the remainder of r1 divided by r2. More...
 

Detailed Description

Infinite precision integers.

The vnl_bignum class implements near-infinite precision integers and arithmetic by using a dynamic bit vector. A vnl_bignum object will grow in size as necessary to hold its integer value. Implicit conversion to the system defined types: short, int, long, float, double and long double is supported by overloaded operator member functions. Addition and subtraction operators are performed by simple bitwise addition and subtraction on unsigned short boundaries with checks for carry flag propagation. The multiplication, division, and remainder operations utilize the algorithms from Knuth's Volume 2 of "The Art of Computer Programming". However, despite the use of these algorithms and inline member functions, arithmetic operations on vnl_bignum objects are considerably slower than the built-in integer types that use hardware integer arithmetic capabilities.

The vnl_bignum class supports the parsing of character string representations of all the literal number formats, PLUS the strings "Infinity", "+Infinity" and "-Infinity". The following table shows an example of a character string representation on the left and a brief description of the interpreted meaning on the right:

Character String Interpreted Meaning 1234 1234 1234l 1234 1234L 1234 1234u 1234 1234U 1234 1234ul 1234 1234UL 1234 01234 1234 in octal (leading 0) 0x1234 1234 in hexadecimal (leading 0x) 0X1234 1234 in hexadecimal (leading 0X) 123.4 123 (value truncated) 1.234e2 123 (exponent expanded/truncated) 1.234e-5 0 (truncated value less than 1) Infinity +Inf ("maxval", obeying all conventional arithmetic)

Definition at line 143 of file vnl_bignum.h.

Constructor & Destructor Documentation

◆ vnl_bignum() [1/10]

vnl_bignum::vnl_bignum ( )

Creates a zero vnl_bignum.

Definition at line 20 of file vnl_bignum.cxx.

◆ vnl_bignum() [2/10]

vnl_bignum::vnl_bignum ( long  l)

Creates a vnl_bignum from a long integer.

Definition at line 27 of file vnl_bignum.cxx.

◆ vnl_bignum() [3/10]

vnl_bignum::vnl_bignum ( unsigned long  l)

Creates a vnl_bignum from an unsigned long integer.

Definition at line 75 of file vnl_bignum.cxx.

◆ vnl_bignum() [4/10]

vnl_bignum::vnl_bignum ( int  l)

Creates a vnl_bignum from an integer.

Definition at line 51 of file vnl_bignum.cxx.

◆ vnl_bignum() [5/10]

vnl_bignum::vnl_bignum ( unsigned int  l)

Creates a vnl_bignum from an unsigned integer.

Definition at line 95 of file vnl_bignum.cxx.

◆ vnl_bignum() [6/10]

vnl_bignum::vnl_bignum ( float  f)

Creates a vnl_bignum from a single-precision floating point number.

Definition at line 115 of file vnl_bignum.cxx.

◆ vnl_bignum() [7/10]

vnl_bignum::vnl_bignum ( double  d)

Creates a vnl_bignum from a double floating point number.

Definition at line 147 of file vnl_bignum.cxx.

◆ vnl_bignum() [8/10]

vnl_bignum::vnl_bignum ( long double  d)

Creates a vnl_bignum from a "long double" floating point number.

Definition at line 178 of file vnl_bignum.cxx.

◆ vnl_bignum() [9/10]

vnl_bignum::vnl_bignum ( vnl_bignum const &  b)

Copies the contents of vnl_bignum b.

Definition at line 384 of file vnl_bignum.cxx.

◆ vnl_bignum() [10/10]

vnl_bignum::vnl_bignum ( const char *  s)

Creates a vnl_bignum from the character string representation.

Definition at line 326 of file vnl_bignum.cxx.

◆ ~vnl_bignum()

vnl_bignum::~vnl_bignum ( )

Frees space for vnl_bignum.

Definition at line 399 of file vnl_bignum.cxx.

Member Function Documentation

◆ abs()

vnl_bignum vnl_bignum::abs ( ) const
inline

Definition at line 231 of file vnl_bignum.h.

◆ dtoBigNum()

int vnl_bignum::dtoBigNum ( const char *  s)
private

Converts decimal string to a vnl_bignum.

Definition at line 771 of file vnl_bignum.cxx.

◆ dump()

void vnl_bignum::dump ( std::ostream &  os = std::cout) const

dump the contents of a vnl_bignum to a stream, default cout.

Definition at line 744 of file vnl_bignum.cxx.

◆ exptoBigNum()

void vnl_bignum::exptoBigNum ( const char *  s)
private

convert exponential string to a vnl_bignum.

Definition at line 789 of file vnl_bignum.cxx.

◆ is_infinity()

bool vnl_bignum::is_infinity ( ) const
inline

Definition at line 234 of file vnl_bignum.h.

◆ is_minus_infinity()

bool vnl_bignum::is_minus_infinity ( ) const
inline

Definition at line 236 of file vnl_bignum.h.

◆ is_plus_infinity()

bool vnl_bignum::is_plus_infinity ( ) const
inline

Definition at line 235 of file vnl_bignum.h.

◆ operator *=()

vnl_bignum & vnl_bignum::operator *= ( vnl_bignum const &  r)

Multiplies this with a vnl_bignum.

Definition at line 503 of file vnl_bignum.cxx.

◆ operator double() [1/2]

vnl_bignum::operator double ( ) const

Implicit conversion from a vnl_bignum to a double.

Definition at line 722 of file vnl_bignum.cxx.

◆ operator double() [2/2]

vnl_bignum::operator double ( )
inline

Definition at line 172 of file vnl_bignum.h.

◆ operator float() [1/2]

vnl_bignum::operator float ( ) const

Implicit conversion from a vnl_bignum to a float.

Definition at line 711 of file vnl_bignum.cxx.

◆ operator float() [2/2]

vnl_bignum::operator float ( )
inline

Definition at line 171 of file vnl_bignum.h.

◆ operator int() [1/2]

vnl_bignum::operator int ( ) const

Implicit conversion from a vnl_bignum to an int.

Definition at line 691 of file vnl_bignum.cxx.

◆ operator int() [2/2]

vnl_bignum::operator int ( )
inline

Definition at line 169 of file vnl_bignum.h.

◆ operator long() [1/2]

vnl_bignum::operator long ( ) const

Implicit conversion from a vnl_bignum to a long.

Definition at line 701 of file vnl_bignum.cxx.

◆ operator long() [2/2]

vnl_bignum::operator long ( )
inline

Definition at line 170 of file vnl_bignum.h.

◆ operator long double() [1/2]

vnl_bignum::operator long double ( ) const

Implicit conversion from a vnl_bignum to a long double.

Definition at line 733 of file vnl_bignum.cxx.

◆ operator long double() [2/2]

vnl_bignum::operator long double ( )
inline

Definition at line 173 of file vnl_bignum.h.

◆ operator short() [1/2]

vnl_bignum::operator short ( ) const

Implicit conversion from a vnl_bignum to a short.

Definition at line 683 of file vnl_bignum.cxx.

◆ operator short() [2/2]

vnl_bignum::operator short ( )
inline

Definition at line 168 of file vnl_bignum.h.

◆ operator!=() [1/5]

bool vnl_bignum::operator!= ( vnl_bignum const &  r) const
inline

Definition at line 202 of file vnl_bignum.h.

◆ operator!=() [2/5]

bool vnl_bignum::operator!= ( long  r) const
inline

Definition at line 207 of file vnl_bignum.h.

◆ operator!=() [3/5]

bool vnl_bignum::operator!= ( int  r) const
inline

Definition at line 213 of file vnl_bignum.h.

◆ operator!=() [4/5]

bool vnl_bignum::operator!= ( double  r) const
inline

Definition at line 219 of file vnl_bignum.h.

◆ operator!=() [5/5]

bool vnl_bignum::operator!= ( long double  r) const
inline

Definition at line 225 of file vnl_bignum.h.

◆ operator%=()

vnl_bignum & vnl_bignum::operator%= ( vnl_bignum const &  r)

Divides this by a vnl_bignum and replaces this by remainder.

Definition at line 541 of file vnl_bignum.cxx.

◆ operator+() [1/2]

vnl_bignum vnl_bignum::operator+ ( ) const
inline

Definition at line 176 of file vnl_bignum.h.

◆ operator+() [2/2]

vnl_bignum vnl_bignum::operator+ ( vnl_bignum const &  r) const

Adds two vnl_bignums, and returns new sum.

Definition at line 474 of file vnl_bignum.cxx.

◆ operator++() [1/2]

vnl_bignum & vnl_bignum::operator++ ( )

prefix increment (++b).

Prefix increment. Increments a vnl_bignum by 1, and returns it.

Definition at line 436 of file vnl_bignum.cxx.

◆ operator++() [2/2]

vnl_bignum vnl_bignum::operator++ ( int  )
inline

postfix increment (b++).

Definition at line 196 of file vnl_bignum.h.

◆ operator+=()

vnl_bignum& vnl_bignum::operator+= ( vnl_bignum const &  r)
inline

Definition at line 183 of file vnl_bignum.h.

◆ operator-()

vnl_bignum vnl_bignum::operator- ( ) const

Returns the negation of a vnl_bignum.

Definition at line 426 of file vnl_bignum.cxx.

◆ operator--() [1/2]

vnl_bignum & vnl_bignum::operator-- ( )

decrement.

Prefix decrement. Decrements a vnl_bignum by 1, and returns it.

Definition at line 455 of file vnl_bignum.cxx.

◆ operator--() [2/2]

vnl_bignum vnl_bignum::operator-- ( int  )
inline

decrement.

Definition at line 198 of file vnl_bignum.h.

◆ operator-=()

vnl_bignum& vnl_bignum::operator-= ( vnl_bignum const &  r)
inline

Definition at line 184 of file vnl_bignum.h.

◆ operator/=()

vnl_bignum & vnl_bignum::operator/= ( vnl_bignum const &  r)

Divides this by a vnl_bignum.

Definition at line 524 of file vnl_bignum.cxx.

◆ operator<() [1/5]

bool vnl_bignum::operator< ( vnl_bignum const &  rhs) const

Compares two vnl_bignums.

Definition at line 605 of file vnl_bignum.cxx.

◆ operator<() [2/5]

bool vnl_bignum::operator< ( long  r) const
inline

Definition at line 208 of file vnl_bignum.h.

◆ operator<() [3/5]

bool vnl_bignum::operator< ( int  r) const
inline

Definition at line 214 of file vnl_bignum.h.

◆ operator<() [4/5]

bool vnl_bignum::operator< ( double  r) const
inline

Definition at line 220 of file vnl_bignum.h.

◆ operator<() [5/5]

bool vnl_bignum::operator< ( long double  r) const
inline

Definition at line 226 of file vnl_bignum.h.

◆ operator<<()

vnl_bignum vnl_bignum::operator<< ( int  l) const

Shifts bignum to the left l digits.

Definition at line 557 of file vnl_bignum.cxx.

◆ operator<<=()

vnl_bignum& vnl_bignum::operator<<= ( int  l)
inline

Definition at line 188 of file vnl_bignum.h.

◆ operator<=() [1/5]

bool vnl_bignum::operator<= ( vnl_bignum const &  r) const
inline

Definition at line 204 of file vnl_bignum.h.

◆ operator<=() [2/5]

bool vnl_bignum::operator<= ( long  r) const
inline

Definition at line 210 of file vnl_bignum.h.

◆ operator<=() [3/5]

bool vnl_bignum::operator<= ( int  r) const
inline

Definition at line 216 of file vnl_bignum.h.

◆ operator<=() [4/5]

bool vnl_bignum::operator<= ( double  r) const
inline

Definition at line 222 of file vnl_bignum.h.

◆ operator<=() [5/5]

bool vnl_bignum::operator<= ( long double  r) const
inline

Definition at line 228 of file vnl_bignum.h.

◆ operator=()

vnl_bignum & vnl_bignum::operator= ( const vnl_bignum rhs)

Copies rhs vnl_bignum to lhs vnl_bignum.

Definition at line 406 of file vnl_bignum.cxx.

◆ operator==() [1/5]

bool vnl_bignum::operator== ( vnl_bignum const &  rhs) const

Two vnl_bignums are equal if and only if they have the same integer representation.

Definition at line 587 of file vnl_bignum.cxx.

◆ operator==() [2/5]

bool vnl_bignum::operator== ( long  r) const
inline

Definition at line 206 of file vnl_bignum.h.

◆ operator==() [3/5]

bool vnl_bignum::operator== ( int  r) const
inline

Definition at line 212 of file vnl_bignum.h.

◆ operator==() [4/5]

bool vnl_bignum::operator== ( double  r) const
inline

Definition at line 218 of file vnl_bignum.h.

◆ operator==() [5/5]

bool vnl_bignum::operator== ( long double  r) const
inline

Definition at line 224 of file vnl_bignum.h.

◆ operator>() [1/5]

bool vnl_bignum::operator> ( vnl_bignum const &  r) const
inline

Definition at line 203 of file vnl_bignum.h.

◆ operator>() [2/5]

bool vnl_bignum::operator> ( long  r) const
inline

Definition at line 209 of file vnl_bignum.h.

◆ operator>() [3/5]

bool vnl_bignum::operator> ( int  r) const
inline

Definition at line 215 of file vnl_bignum.h.

◆ operator>() [4/5]

bool vnl_bignum::operator> ( double  r) const
inline

Definition at line 221 of file vnl_bignum.h.

◆ operator>() [5/5]

bool vnl_bignum::operator> ( long double  r) const
inline

Definition at line 227 of file vnl_bignum.h.

◆ operator>=() [1/5]

bool vnl_bignum::operator>= ( vnl_bignum const &  r) const
inline

Definition at line 205 of file vnl_bignum.h.

◆ operator>=() [2/5]

bool vnl_bignum::operator>= ( long  r) const
inline

Definition at line 211 of file vnl_bignum.h.

◆ operator>=() [3/5]

bool vnl_bignum::operator>= ( int  r) const
inline

Definition at line 217 of file vnl_bignum.h.

◆ operator>=() [4/5]

bool vnl_bignum::operator>= ( double  r) const
inline

Definition at line 223 of file vnl_bignum.h.

◆ operator>=() [5/5]

bool vnl_bignum::operator>= ( long double  r) const
inline

Definition at line 229 of file vnl_bignum.h.

◆ operator>>()

vnl_bignum vnl_bignum::operator>> ( int  l) const

Shifts bignum to the right l digits.

Definition at line 572 of file vnl_bignum.cxx.

◆ operator>>=()

vnl_bignum& vnl_bignum::operator>>= ( int  l)
inline

Definition at line 189 of file vnl_bignum.h.

◆ otoBigNum()

void vnl_bignum::otoBigNum ( const char *  s)
private

convert octal string to vnl_bignum.

Definition at line 827 of file vnl_bignum.cxx.

◆ resize()

void vnl_bignum::resize ( short  new_count)
private

change the data allotment for a vnl_bignum.

Definition at line 841 of file vnl_bignum.cxx.

◆ trim()

vnl_bignum & vnl_bignum::trim ( )
private

trim non-infinite vnl_bignum of excess data allotment.

Definition at line 869 of file vnl_bignum.cxx.

◆ xtoBigNum()

void vnl_bignum::xtoBigNum ( const char *  s)
private

convert hex string to vnl_bignum.

Definition at line 813 of file vnl_bignum.cxx.

Friends And Related Function Documentation

◆ add

void add ( const vnl_bignum ,
const vnl_bignum ,
vnl_bignum  
)
friend

add two non-infinite vnl_bignum values and save their sum.

Definition at line 887 of file vnl_bignum.cxx.

◆ decrement

void decrement ( vnl_bignum bnum)
friend

Subtract 1 from bnum (unsigned, non-infinite, non-zero).

Definition at line 969 of file vnl_bignum.cxx.

◆ divide

void divide ( const vnl_bignum ,
const vnl_bignum ,
vnl_bignum ,
vnl_bignum  
)
friend

divide b2 into b1, getting quotient q and remainder r.

(Refer to Knuth, V.2, Section 4.3.1, Algorithm D for details. This function implements Algorithm D.)

  • Inputs: references to a vnl_bignum dividend b1, divisor b2, quotient q, and remainder r.

Definition at line 1187 of file vnl_bignum.cxx.

◆ divide_aux

void divide_aux ( const vnl_bignum ,
unsigned short  ,
vnl_bignum ,
unsigned short &   
)
friend

divide a vnl_bignum by a "single digit".

(Refer to Knuth, V.2, Section 4.3.2, exercise 16 for details. A digit here is one data element in the radix 2**2.)

  • Inputs: reference to vnl_bignum dividend, single digit divisor d, vnl_bignum quotient, and single digit remainder r

Definition at line 1062 of file vnl_bignum.cxx.

◆ estimate_q_hat

unsigned short estimate_q_hat ( const vnl_bignum ,
const vnl_bignum ,
unsigned short   
)
friend

estimate next dividend.

(Refer to Knuth, V.2, Section 4.3.1, Algorithm D for details. This function estimates how many times v goes into u, starting at u's jth digit. A digit here is actually a data element, thought of as being in the radix 2**2.)

  • Inputs: reference to vnl_bignum dividend and divisor and starting digit j
  • Outputs: estimated number of times v goes into u

Definition at line 1082 of file vnl_bignum.cxx.

◆ increment

void increment ( vnl_bignum bnum)
friend

Add 1 to bnum (unsigned, non-infinite).

Definition at line 928 of file vnl_bignum.cxx.

◆ left_shift

vnl_bignum left_shift ( const vnl_bignum b1,
int  l 
)
friend

left shift (arithmetic) non-infinite vnl_bignum by positive number.

  • Inputs: reference to vnl_bignum, positive shift value
  • Outputs: vnl_bignum, multiplied by the corresponding power of two

Definition at line 1246 of file vnl_bignum.cxx.

◆ magnitude_cmp

int magnitude_cmp ( const vnl_bignum ,
const vnl_bignum  
)
friend

compare absolute values of two vnl_bignums.

Outputs: result of comparison: -1 if abs(b1) < abs(b2) 0 if abs(b1) == abs(b2) +1 if abs(b1) > abs(b2)

Definition at line 988 of file vnl_bignum.cxx.

◆ multiply_aux

void multiply_aux ( const vnl_bignum ,
unsigned short  ,
vnl_bignum ,
unsigned short   
)
friend

multiply a non-infinite vnl_bignum by a "single digit".

  • Inputs: vnl_bignum reference, single word multiplier, reference to the product, and index of starting storage location to use in product

Definition at line 1009 of file vnl_bignum.cxx.

◆ multiply_subtract

unsigned short multiply_subtract ( vnl_bignum ,
const vnl_bignum ,
unsigned short  ,
unsigned short   
)
friend

calculate u - v*q_hat.

(Refer to Knuth, V. 2, Section 4.3.1, Algorithm D for details. A digit here is a data element, thought of as being in the radix 2**2.)

  • Inputs: reference to vnl_bignum dividend, divisor, estimated result, and index into jth digit of dividend
  • Outputs: true number of times v goes into u

Definition at line 1129 of file vnl_bignum.cxx.

◆ normalize

unsigned short normalize ( const vnl_bignum ,
const vnl_bignum ,
vnl_bignum ,
vnl_bignum  
)
friend

normalize two vnl_bignums.

(Refer to Knuth, V.2, Section 4.3.1, Algorithm D for details. A digit here is one data element in the radix 2**2.)

  • Inputs: references to two vnl_bignums b1, b2
  • Outputs: their normalized counterparts u and v, and the integral normalization factor used

Definition at line 1045 of file vnl_bignum.cxx.

◆ operator *()

vnl_bignum operator * ( vnl_bignum const &  r1,
vnl_bignum const &  r2 
)
related

Returns the product of two bignum numbers.

Definition at line 302 of file vnl_bignum.h.

◆ operator%()

vnl_bignum operator% ( vnl_bignum const &  r1,
vnl_bignum const &  r2 
)
related

Returns the remainder of r1 divided by r2.

Definition at line 396 of file vnl_bignum.h.

◆ operator+()

vnl_bignum operator+ ( vnl_bignum const &  r1,
long  r2 
)
related

Returns the sum of two bignum numbers.

Definition at line 279 of file vnl_bignum.h.

◆ operator-()

vnl_bignum operator- ( vnl_bignum const &  r1,
vnl_bignum const &  r2 
)
related

Returns the difference of two bignum numbers.

Definition at line 290 of file vnl_bignum.h.

◆ operator/()

vnl_bignum operator/ ( vnl_bignum const &  r1,
vnl_bignum const &  r2 
)
related

Returns the division of two bignum numbers.

Definition at line 349 of file vnl_bignum.h.

◆ operator<<

VNL_EXPORT std::ostream & operator<< ( std::ostream &  ,
const vnl_bignum  
)
friend

Formatted output for bignum.

formatted output.

Definition at line 617 of file vnl_bignum.cxx.

◆ operator>>

VNL_EXPORT std::istream & operator>> ( std::istream &  ,
vnl_bignum  
)
friend

Reads a vnl_bignum from a stream.

simple input.

Definition at line 354 of file vnl_bignum.cxx.

◆ right_shift

vnl_bignum right_shift ( const vnl_bignum b1,
int  l 
)
friend

right shift (arithmetic) non-infinite vnl_bignum by positive number.

  • Inputs: reference to vnl_bignum, positive shift value
  • Outputs: vnl_bignum, divided by the corresponding power of two

Definition at line 1284 of file vnl_bignum.cxx.

◆ subtract

void subtract ( const vnl_bignum ,
const vnl_bignum ,
vnl_bignum  
)
friend

subtract bmin from bmax (unsigned, non-infinite), result in diff.

Definition at line 947 of file vnl_bignum.cxx.

◆ vnl_bignum_from_string

VNL_EXPORT vnl_bignum & vnl_bignum_from_string ( vnl_bignum b,
const std::string &  s 
)
friend

Convert the number from a decimal representation in a string.

Definition at line 667 of file vnl_bignum.cxx.

◆ vnl_bignum_to_string

VNL_EXPORT std::string & vnl_bignum_to_string ( std::string &  s,
const vnl_bignum b 
)
friend

Convert the number to a decimal representation in a string.

Definition at line 643 of file vnl_bignum.cxx.

◆ vsl_b_read()

void vsl_b_read ( vsl_b_istream &  is,
vnl_bignum v 
)
related

Binary load vnl_bignum from stream.

Definition at line 21 of file vnl_io_bignum.cxx.

◆ vsl_b_write()

void vsl_b_write ( vsl_b_ostream &  os,
vnl_bignum const &  v 
)
related

Binary save vnl_bignum to stream.

Definition at line 10 of file vnl_io_bignum.cxx.

◆ vsl_print_summary()

void vsl_print_summary ( std::ostream &  os,
vnl_bignum const &  b 
)
related

Print human readable summary of object to a stream.

Definition at line 44 of file vnl_io_bignum.cxx.

Member Data Documentation

◆ count

unsigned short vnl_bignum::count
private

Definition at line 146 of file vnl_bignum.h.

◆ data

unsigned short* vnl_bignum::data
private

Definition at line 148 of file vnl_bignum.h.

◆ sign

int vnl_bignum::sign
private

Definition at line 147 of file vnl_bignum.h.


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