| java.lang.Object gnu.math.MPN
MPN | class MPN (Code) | | This contains various low-level routines for unsigned bigints.
The interfaces match the mpn interfaces in gmp,
so it should be easy to replace them with fast native functions
that are trivial wrappers around the mpn_ functions in gmp
(at least on platforms that use 32-bit "limbs").
|
Method Summary | |
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(int 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]. | public static int | chars_per_word(int radix) Number of digits in the conversion base that always fits in a word. | 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 | cmp(int[] x, int xlen, int[] y, int ylen) Compare
x[0:xlen-1] with
y[0:ylen-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] < 0 (i.e. | public static int | divmod_1(int[] quotient, int[] dividend, int len, int divisor) Divide divident[0:len-1] by (unsigned int)divisor. | static int | findLowestBit(int word) Return least i such that word&(1< | static int | findLowestBit(int[] words) Return least i such that words & (1< | 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 i) | public static int | intLength(int[] words, int len) Calcaulte the Common Lisp "integer-length" function. | public static int | lshift(int[] dest, int d_offset, int[] x, int len, int count) | 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. | public static int | rshift(int[] dest, int[] x, int x_start, int len, int count) | public static void | rshift0(int[] dest, int[] x, int x_start, int len, int count) | public static long | rshift_long(int[] x, int len, int count) Return the long-truncated value of right shifting. | public static int | set_str(int dest, byte[] str, int str_len, int base) | 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]. | public static int | submul_1(int[] dest, int offset, int[] x, int len, int y) | public static long | udiv_qrnnd(long N, int D) |
add_1 | public static int add_1(int[] dest, int[] x, int size, int y)(Code) | | 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.
|
add_n | public static int add_n(int dest, int[] x, int[] y, int len)(Code) | | 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.
the carry, either 0 or 1This function is basically the same as gmp's mpn_add_n. |
chars_per_word | public static int chars_per_word(int radix)(Code) | | 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 number of digits |
cmp | public static int cmp(int[] x, int[] y, int size)(Code) | | Compare
x[0:size-1] with
y[0:size-1] , treating them as unsigned integers.
-1, 0, or 1 depending on if xy .This is basically the same as gmp's mpn_cmp function. |
cmp | public static int cmp(int[] x, int xlen, int[] y, int ylen)(Code) | | Compare
x[0:xlen-1] with
y[0:ylen-1] , treating them as unsigned integers.
-1, 0, or 1 depending onwhether xy . |
count_leading_zeros | public static int count_leading_zeros(int i)(Code) | | Count the number of leading zero bits in an int.
|
divide | public static void divide(int[] zds, int nx, int[] y, int ny)(Code) | | 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] < 0 (i.e. most significant bit set)
|
divmod_1 | public static int divmod_1(int[] quotient, int[] dividend, int len, int divisor)(Code) | | 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.
|
findLowestBit | static int findLowestBit(int word)(Code) | | Return least i such that word&(1< |
findLowestBit | static int findLowestBit(int[] words)(Code) | | Return least i such that words & (1< |
gcd | public static int gcd(int[] x, int[] y, int len)(Code) | | 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).
|
intLength | public static int intLength(int i)(Code) | | |
intLength | public static int intLength(int[] words, int len)(Code) | | Calcaulte the Common Lisp "integer-length" function.
Assumes input is canonicalized: len==IntNum.wordsNeeded(words,len)
|
lshift | public static int lshift(int[] dest, int d_offset, int[] x, int len, int count)(Code) | | |
mul | public static void mul(int[] dest, int[] x, int xlen, int[] y, int ylen)(Code) | | 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.
|
mul_1 | public static int mul_1(int[] dest, int[] x, int len, int y)(Code) | | 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.
|
rshift | public static int rshift(int[] dest, int[] x, int x_start, int len, int count)(Code) | | |
rshift0 | public static void rshift0(int[] dest, int[] x, int x_start, int len, int count)(Code) | | |
rshift_long | public static long rshift_long(int[] x, int len, int count)(Code) | | Return the long-truncated value of right shifting.
Parameters: x - a two's-complement "bignum" Parameters: len - the number of significant words in x Parameters: count - the shift count (long)(x[0..len-1] >> count). |
set_str | public static int set_str(int dest, byte[] str, int str_len, int base)(Code) | | |
sub_n | public static int sub_n(int[] dest, int[] X, int[] Y, int size)(Code) | | 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.
|
submul_1 | public static int submul_1(int[] dest, int offset, int[] x, int len, int y)(Code) | | |
udiv_qrnnd | public static long udiv_qrnnd(long N, int D)(Code) | | |
|
|