Typedefs | Functions
core/vnl/vnl_bignum.cxx File Reference
#include "vnl_bignum.h"
#include <vcl_cstdlib.h>
#include <vcl_cstring.h>
#include <vcl_cmath.h>
#include <vcl_algorithm.h>
#include <vcl_vector.h>
#include <vcl_cassert.h>
#include <vcl_iostream.h>
#include <vcl_limits.h>
#include <vnl/vnl_math.h>

Go to the source code of this file.

Typedefs

typedef unsigned short Counter
typedef unsigned short Data

Functions

vcl_istream & operator>> (vcl_istream &is, vnl_bignum &x)
 Reads a vnl_bignum from a stream.
vcl_ostream & operator<< (vcl_ostream &os, const vnl_bignum &b)
 Formatted output for bignum.
vcl_string & vnl_bignum_to_string (vcl_string &s, const vnl_bignum &b)
 Convert the number to a decimal representation in a string.
vnl_bignumvnl_bignum_from_string (vnl_bignum &b, const vcl_string &s)
 Convert the number from a decimal representation in a string.
unsigned int ctox (int c)
 convert hex character to integer hex value (ASCII or EBCDIC).
void add (const vnl_bignum &b1, const vnl_bignum &b2, vnl_bignum &sum)
 add two non-infinite vnl_bignum values and save their sum.
void increment (vnl_bignum &bnum)
 Add 1 to bnum (unsigned, non-infinite).
void subtract (const vnl_bignum &bmax, const vnl_bignum &bmin, vnl_bignum &diff)
 subtract bmin from bmax (unsigned, non-infinite), result in diff.
void decrement (vnl_bignum &bnum)
 Subtract 1 from bnum (unsigned, non-infinite, non-zero).
int magnitude_cmp (const vnl_bignum &b1, const vnl_bignum &b2)
 compare absolute values of two vnl_bignums.
void multiply_aux (const vnl_bignum &b, Data d, vnl_bignum &prod, Counter i)
 multiply a non-infinite vnl_bignum by a "single digit".
Data normalize (const vnl_bignum &b1, const vnl_bignum &b2, vnl_bignum &u, vnl_bignum &v)
 normalize two vnl_bignums.
void divide_aux (const vnl_bignum &b1, Data d, vnl_bignum &q, Data &r)
 divide a vnl_bignum by a "single digit".
Data estimate_q_hat (const vnl_bignum &u, const vnl_bignum &v, Counter j)
 estimate next dividend.
Data multiply_subtract (vnl_bignum &u, const vnl_bignum &v, Data q_hat, Counter j)
 calculate u - v*q_hat.
void divide (const vnl_bignum &b1, const vnl_bignum &b2, vnl_bignum &q, vnl_bignum &r)
 divide b2 into b1, getting quotient q and remainder r.
vnl_bignum left_shift (const vnl_bignum &b1, int l)
 left shift (arithmetic) non-infinite vnl_bignum by positive number.
vnl_bignum right_shift (const vnl_bignum &b1, int l)
 right shift (arithmetic) non-infinite vnl_bignum by positive number.

Detailed Description

Definition in file vnl_bignum.cxx.


Typedef Documentation

typedef unsigned short Counter

Definition at line 16 of file vnl_bignum.cxx.

typedef unsigned short Data

Definition at line 17 of file vnl_bignum.cxx.


Function Documentation

void add ( const vnl_bignum b1,
const vnl_bignum b2,
vnl_bignum sum 
)

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

Definition at line 924 of file vnl_bignum.cxx.

unsigned int ctox ( int  c)

convert hex character to integer hex value (ASCII or EBCDIC).

  • Inputs: character representation of a hex number
  • Outputs: integer value of the hex number

Definition at line 842 of file vnl_bignum.cxx.

void decrement ( vnl_bignum bnum)

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

Definition at line 1000 of file vnl_bignum.cxx.

void divide ( const vnl_bignum b1,
const vnl_bignum b2,
vnl_bignum q,
vnl_bignum r 
)

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 1218 of file vnl_bignum.cxx.

void divide_aux ( const vnl_bignum b1,
Data  d,
vnl_bignum q,
Data r 
)

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 1093 of file vnl_bignum.cxx.

Data estimate_q_hat ( const vnl_bignum u,
const vnl_bignum v,
Counter  j 
)

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 1113 of file vnl_bignum.cxx.

void increment ( vnl_bignum bnum)

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

Definition at line 959 of file vnl_bignum.cxx.

vnl_bignum left_shift ( const vnl_bignum b1,
int  l 
)

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 1277 of file vnl_bignum.cxx.

int magnitude_cmp ( const vnl_bignum b1,
const vnl_bignum b2 
)

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 1019 of file vnl_bignum.cxx.

void multiply_aux ( const vnl_bignum b,
Data  d,
vnl_bignum prod,
Counter  i 
)

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 1040 of file vnl_bignum.cxx.

Data multiply_subtract ( vnl_bignum u,
const vnl_bignum v,
Data  q_hat,
Counter  j 
)

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 1160 of file vnl_bignum.cxx.

Data normalize ( const vnl_bignum b1,
const vnl_bignum b2,
vnl_bignum u,
vnl_bignum v 
)

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 1076 of file vnl_bignum.cxx.

vcl_ostream & operator<< ( vcl_ostream &  os,
const vnl_bignum b 
)

Formatted output for bignum.

formatted output.

Definition at line 657 of file vnl_bignum.cxx.

vcl_istream & operator>> ( vcl_istream &  is,
vnl_bignum x 
)

Reads a vnl_bignum from a stream.

simple input.

Definition at line 404 of file vnl_bignum.cxx.

vnl_bignum right_shift ( const vnl_bignum b1,
int  l 
)

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 1315 of file vnl_bignum.cxx.

void subtract ( const vnl_bignum bmax,
const vnl_bignum bmin,
vnl_bignum diff 
)

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

Definition at line 978 of file vnl_bignum.cxx.

vnl_bignum & vnl_bignum_from_string ( vnl_bignum b,
const vcl_string &  s 
)

Convert the number from a decimal representation in a string.

Definition at line 707 of file vnl_bignum.cxx.

vcl_string & vnl_bignum_to_string ( vcl_string &  s,
const vnl_bignum b 
)

Convert the number to a decimal representation in a string.

Definition at line 683 of file vnl_bignum.cxx.