Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
gnu.java.math.MPN
Method Summary | |
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static void |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static void |
|
static int |
|
static int |
|
static void |
|
static long |
|
static int |
|
static int |
|
static int |
|
static long |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public static int add_1(int[] dest, int[] x, int size, int y)
Add x[0:size-1] and y, and write the size least significant words of the result to dest. Return carry, either 0 or 1. All values are unsigned. This is basically the same as gmp's mpn_add_1.
public static int add_n(dest[] , int[] x, int[] y, int len)
Add x[0:len-1] and y[0:len-1] and write the len least significant words of the result to dest[0:len-1]. All words are treated as unsigned.
- Returns:
- the carry, either 0 or 1 This function is basically the same as gmp's mpn_add_n.
public static int chars_per_word(int radix)
Number of digits in the conversion base that always fits in a word. For example, for base 10 this is 9, since 10**9 is the largest number that fits into a words (assuming 32-bit words). This is the same as gmp's __mp_bases[radix].chars_per_limb.
- Parameters:
radix
- the base
- Returns:
- number of digits
public static int cmp(int[] x, int xlen, int[] y, int ylen)
Compare x[0:xlen-1] with y[0:ylen-1], treating them as unsigned integers.
- Returns:
- -1, 0, or 1 depending on if x<y, x==y, or x>y.
public static int cmp(int[] x, int[] y, int size)
Compare x[0:size-1] with y[0:size-1], treating them as unsigned integers.
public static int count_leading_zeros(int i)
Count the number of leading zero bits in an int.
public static void divide(int[] zds, int nx, int[] y, int ny)
Divide zds[0:nx] by y[0:ny-1]. The remainder ends up in zds[0:ny-1]. The quotient ends up in zds[ny:nx]. Assumes: nx>ny. (int)y[ny-1] <320 (i.e. most significant bit set)
public static int divmod_1(int[] quotient, int[] dividend, int len, int divisor)
Divide divident[0:len-1] by (unsigned int)divisor. Write result into quotient[0:len-1. Return the one-word (unsigned) remainder. OK for quotient==dividend.
public static int findLowestBit(int word)
Return least i such that word & (1<<i). Assumes word!=0.
public static int findLowestBit(int[] words)
Return least i such that words & (1<<i). Assumes there is such an i.
public static int gcd(int[] x, int[] y, int len)
Calculate Greatest Common Divisior of x[0:len-1] and y[0:len-1]. Assumes both arguments are non-zero. Leaves result in x, and returns len of result. Also destroys y (actually sets it to a copy of the result).
public static int intLength(int[] words, int len)
Calcaulte the Common Lisp "integer-length" function. Assumes input is canonicalized: len==BigInteger.wordsNeeded(words,len)
public static void mul(int[] dest, int[] x, int xlen, int[] y, int ylen)
Multiply x[0:xlen-1] and y[0:ylen-1], and write the result to dest[0:xlen+ylen-1]. The destination has to have space for xlen+ylen words, even if the result might be one limb smaller. This function requires that xlen >= ylen. The destination must be distinct from either input operands. All operands are unsigned. This function is basically the same gmp's mpn_mul.
public static int mul_1(int[] dest, int[] x, int len, int y)
Multiply x[0:len-1] by y, and write the len least significant words of the product to dest[0:len-1]. Return the most significant word of the product. All values are treated as if they were unsigned (i.e. masked with 0xffffffffL). OK if dest==x (not sure if this is guaranteed for mpn_mul_1). This function is basically the same as gmp's mpn_mul_1.
public static int rshift(int[] dest, int[] x, int x_start, int len, int count)
Shift x[x_start:x_start+len-1] count bits to the "right" (i.e. divide by 2**count). Store the len least significant words of the result at dest. The bits shifted out to the right are returned. OK if dest==x. Assumes: 0 < count < 32
public static void rshift0(int[] dest, int[] x, int x_start, int len, int count)
Shift x[x_start:x_start+len-1] count bits to the "right" (i.e. divide by 2**count). Store the len least significant words of the result at dest. OK if dest==x. Assumes: 0 <= count < 32 Same as rshift, but handles count==0 (and has no return value).
public static long rshift_long(int[] x, int len, int count)
Return the long-truncated value of right shifting.
- Parameters:
x
- a two's-complement "bignum"len
- the number of significant words in xcount
- the shift count
- Returns:
- (long)(x[0..len-1] >> count).
public static int sub_n(int[] dest, int[] X, int[] Y, int size)
Subtract Y[0:size-1] from X[0:size-1], and write the size least significant words of the result to dest[0:size-1]. Return borrow, either 0 or 1. This is basically the same as gmp's mpn_sub_n function.