Function
Static Public Summary | ||
public |
add(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number, c: Array, ci: Number, cj: Number): * Adds two big endian arrays and puts result in a destination array. |
|
public |
Compares two big endian arrays with little constraints on the operands. |
|
public |
Converts the input number A represented in base f to a number B represented in base t. |
|
public |
Converts the input number A represented in base f to a number B represented in base t. |
|
public |
Subtracts 1 from a big endian array. |
|
public |
Tests whether two big endian arrays are equal. |
|
public |
euclidean_algorithm(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number): Array No constraints on the input. |
|
public |
extended_euclidean_algorithm(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number): undefined[] No constraints on the input. |
|
public |
Compares two big endian arrays: returns true if the first is greater or equal to the second. |
|
public |
Compares two big endian arrays: returns true if the first is greater than the second. |
|
public |
Adds a big endian array to another in-place. |
|
public |
Adds 1 to a big endian array. |
|
public |
Returns true if and only if input number A is 0. |
|
public |
Compares two big endian arrays: returns true if the first is less or equal to the second. |
|
public |
Compares two big endian arrays: returns true if the first is less than the second. |
|
public |
mul(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number, c: Array, ci: Number, cj: Number): * Multiplies two big endian arrays and puts result in a destination array. |
|
public |
Tests whether two big endian arrays are not equal. |
|
public |
Converts a string representation in base f to a limb array in base t. |
|
public |
parse_keep_zeros(f: number, t: number, string: string): number[] Converts a string representation in base f to a limb array in base t keeping all leading zeros resulting from the conversion process. |
|
public |
Converts a limb array in base f to a string representation in base t. |
|
public |
Converts a string representation in base f to a string representation in base t. |
|
public |
trim_natural(a: number[], ai: number, aj: number): number[] Trim a limb array so that it is either [0] or does not start with any leading zeros. |
Static Private Summary | ||
private |
_add(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number, c: Array, ci: Number, cj: Number) Adds two big endian arrays and puts result in a destination array. |
|
private |
Allocate a new limb array. |
|
private |
_build(base: *, number: *, data: *, n: *): * |
|
private |
Converts a limb to a character representation. |
|
private |
Compares two big endian arrays. |
|
private |
Compares a number A with size n = |A| to R = (r^n)/2. |
|
private |
_cmp_half_even_radix(_r: *, a: *, ai: *, aj: *): * |
|
private |
_cmp_half_odd_radix(_r: *, a: *, ai: *, aj: *): * |
|
private |
Compares two big endian arrays. |
|
private |
_convert(f: number, t: number, a: number[], ai: number, aj: number, b: number[], bi: number, bj: number): * Dispatcher for the various base conversion implementations. |
|
private |
_convert_dc(size_small_block: Number, f: Number, t: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number) O(M(N) log N) where M(N) is multiplication time complexity. |
|
private |
_convert_slow(f: Number, t: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number): * F != t |
|
private |
_convert_to_larger(f: Number, t: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number): * |
|
private |
_convert_to_larger_fast(ar: Number, z: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number) |
|
private |
_convert_to_larger_slow(f: Number, t: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number) O(N^2). |
|
private |
_convert_to_smaller(f: Number, t: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number): * |
|
private |
_convert_to_smaller_fast(br: Number, z: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number) |
|
private |
_convert_to_smaller_slow(f: Number, t: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number) O(N^2). |
|
private |
Copy a limb array into another limb array. |
|
private |
_div_limb_with_prefix(r: Number, tmp: Number, d: Number, D: Array, Di: Number, Dj: Number, Q: Array, Qi: Number) Divides a big endian number by a single limb number. |
|
private |
_divmod(r: Number, D: Array, Di: Number, Dj: Number, d: Array, di: Number, dj: Number, Q: Array, Qi: Number, Qj: Number, R: Array, Ri: Number, Rj: Number) Computes the quotient and remainder of two numbers. |
|
private |
_euclidean_algorithm_loop(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number): Array Euclidean algorithm. |
|
private |
_extended_euclidean_algorithm(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number): * Precondition:
|
|
private |
_extended_euclidean_algorithm_allocate(m: *, n: *): undefined[] M >= n >= 0 m >= 1 |
|
private |
_extended_euclidean_algorithm_loop(r: *, R0: *, R1: *, S0: *, T0: *, S1: *, T1: *, Q: *, X: *): undefined[] Extended Euclidean algorithm. |
|
private |
Fill the input limb array with a fixed value. |
|
private |
_from_string(string: string): number[] Converts a string representation to a limb array representation without radix conversion. |
|
private |
Adds a big endian array to another. |
|
private |
Adds single limb to a big endian array. |
|
private |
_idivmod(r: Number, D: Array, Di: Number, Dj: Number, d: Array, di: Number, dj: Number, Q: Array, Qi: Number, Qj: Number): * Computes the quotient and remainder of two numbers. |
|
private |
_idivmod_dc(X: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number, c: Array, ci: Number, cj: Number) Input
|
|
private |
_idivmod_dc_21(r: *, a: *, ai: *, aj: *, b: *, bi: *, bj: *, c: *, ci: *, cj: *): * Algorithm 3.3 Divide-and-conquer division (2 by 1) |
|
private |
_idivmod_dc_32(r: *, a: *, ai: *, aj: *, b: *, bi: *, bj: *, c: *, ci: *, cj: *) Algorithm 3.4 Divide-and-conquer division (3 by 2) |
|
private |
Divides a big endian number by a single limb number. |
|
private |
_idivmod_limb_with_prefix(r: Number, tmp: Number, d: Number, D: Array, Di: Number, Dj: Number, Q: Array, Qi: Number) Divides a big endian number by a single limb number. |
|
private |
_idivmod_schoolbook(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number, q: Array, qi: Number) Computes q <- a / b and a <- a % b. |
|
private |
_idivmod_schoolbook_large_divisor(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number, q: Array, qi: Number): * Input
|
|
private |
_idivmod_schoolbook_subroutine(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number, q: Array, qi: Number) Input
|
|
private |
_idivmod_schoolbook_subroutine_do(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number, q: Array, qi: Number) Input
|
|
private |
_idivmod_slow(x: Number, r: array, ri: Number, rj: Number, b: array, bi: Number, bj: Number, q: array, qi: Number) Computes quotient and remainder of two big endian arrays. |
|
private |
_imod(r: Number, D: Array, Di: Number, Dj: Number, d: Array, di: Number, dj: Number, _: Array, _i: Number, _j: Number): * Computes the remainder of two numbers. |
|
private |
Divides a big endian number by a single limb number and writes the remainder to the dividend array. |
|
private |
Divides a big endian number by another big endian number and writes the remainder to the dividend array. |
|
private |
_imod_schoolbook_large_divisor(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number): * Input
|
|
private |
_imod_schoolbook_subroutine(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number) Input
|
|
private |
_imod_schoolbook_subroutine_do(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number) Input
|
|
private |
Converts an input character representation to a limb. |
|
private |
Subtracts B from A, |A| >= |B|. |
|
private |
_karatsuba(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number, c: Array, ci: Number, cj: Number): * Multiply two big endian arrays using karatsuba algorithm, |A| >= |B| >= 1, |C| >= |A| + |B|, |A| >= 2. |
|
private |
_karatsuba_right_op_is_small(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number, c: Array, ci: Number, cj: Number) Multiply two big endian arrays using karatsuba algorithm, WHEN THE SECOND OPERAND IS SMALL. |
|
private |
|
|
private |
Divides a big endian number by a single limb number and returns only the remainder. |
|
private |
_mul(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number, c: Array, ci: Number, cj: Number): * Computes C = A+B. |
|
private |
_mul_limb(r: *, x: *, b: *, bi: *, bj: *, c: *, ci: *, cj: *) Compute x * b where x is a single limb. |
|
private |
_pow_double(r: Number, x: Number, a: Array, ai: Number, aj: Number, c: Array, ci: Number, cj: Number) Computes |
|
private |
_pow_double_recursive(r: Number, x: Number, a: Array, ai: Number, aj: Number, c: Array, ci: Number, cj: Number) Computes |
|
private |
Fill the input limb array with zeros. |
|
private |
_schoolbook_mul(r: *, a: *, ai: *, aj: *, b: *, bi: *, bj: *, c: *, ci: *, cj: *) Computes the product of two big endian arrays using schoolbook multiplication. |
|
private |
_sub(r: Number, a: array, ai: Number, aj: Number, b: array, bi: Number, bj: Number, c: array, ci: Number, cj: Number) Subtracts two big endian arrays, |C| >= |A| >= |B|. |
|
private |
_to_string(b: number[]): string Convert an entire limb array to a string representation (without changing the radix). |
|
private |
_trim_positive(a: number[], ai: number, aj: number): number Compute the new inclusive left bound of a limb array by skipping all leading zeros. |
|
private |
|
|
private |
Allocate a new limb array filled with zeros. |
Static Public
public add(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number, c: Array, ci: Number, cj: Number): * source
Adds two big endian arrays and puts result in a destination array. Wraps on overflow. Works with any combination of array sizes.
Return:
* |
public cmp(a: number[], ai: number, aj: number, b: number[], bi: number, bj: number): number source
import cmp from '@arithmetic-operations-for/naturals-big-endian/src/api/compare/cmp.js'
Compares two big endian arrays with little constraints on the operands.
Input:
- |A| >= 0
- |B| >= 0
public convert(f: number, t: number, a: number[], ai: number, aj: number): number[] source
import convert from '@arithmetic-operations-for/naturals-big-endian/src/api/convert/convert.js'
Converts the input number A represented in base f to a number B represented in base t. If A is 0 the output is B = [0], otherwise all leading zeros are trimmed.
public convert_keep_zeros(f: number, t: number, a: number[], ai: number, aj: number): number[] source
import convert_keep_zeros from '@arithmetic-operations-for/naturals-big-endian/src/core/convert/convert_keep_zeros.js'
Converts the input number A represented in base f to a number B represented in base t. All leading zeros resulting from the conversion are kept.
public decrement(r: Number, a: Array, ai: Number, aj: Number) source
import decrement from '@arithmetic-operations-for/naturals-big-endian/src/api/arithmetic/sub/decrement.js'
Subtracts 1 from a big endian array.
Wraps on underflow. Hence, does nothing if aj <= ai.
O(|A|) time in the worst case. O(1) amortized time over any number of successive operations starting with A = O(1). O(1) amortized time over O(|A|) successive operations starting with any A.
public eq(a: number[], ai: number, aj: number, b: number[], bi: number, bj: number): boolean source
import eq from '@arithmetic-operations-for/naturals-big-endian/src/api/compare/eq.js'
Tests whether two big endian arrays are equal.
Input:
- |A| >= 0
- |B| >= 0
public euclidean_algorithm(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number): Array source
import euclidean_algorithm from '@arithmetic-operations-for/naturals-big-endian/src/api/arithmetic/gcd/euclidean_algorithm.js'
No constraints on the input.
Return:
Array | The array containing the gcd of A and B (one of A and B). Return as [ d , di , dj ], where d is the array and di and dj are its left and right bounds. |
public extended_euclidean_algorithm(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number): undefined[] source
import extended_euclidean_algorithm from '@arithmetic-operations-for/naturals-big-endian/src/api/arithmetic/gcd/extended_euclidean_algorithm.js'
No constraints on the input.
public ge(a: number[], ai: number, aj: number, b: number[], bi: number, bj: number): boolean source
import ge from '@arithmetic-operations-for/naturals-big-endian/src/api/compare/ge.js'
Compares two big endian arrays: returns true if the first is greater or equal to the second.
Input:
- |A| >= 0
- |B| >= 0
public gt(a: number[], ai: number, aj: number, b: number[], bi: number, bj: number): boolean source
import gt from '@arithmetic-operations-for/naturals-big-endian/src/api/compare/gt.js'
Compares two big endian arrays: returns true if the first is greater than the second.
Input:
- |A| >= 0
- |B| >= 0
public iadd(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number): * source
Adds a big endian array to another in-place. Wraps on overflow. Works with any combination of array sizes.
Return:
* |
public increment(r: Number, a: Array, ai: Number, aj: Number) source
import increment from '@arithmetic-operations-for/naturals-big-endian/src/api/arithmetic/add/increment.js'
Adds 1 to a big endian array.
Wraps on overflow. Hence, does nothing if aj <= ai.
O(|A|) time in the worst case. O(1) amortized time over any number of successive operations starting with A = O(1). O(1) amortized time over O(|A|) successive operations starting with any A.
public jz(a: number[], ai: number, aj: number): boolean source
import jz from '@arithmetic-operations-for/naturals-big-endian/src/api/compare/jz.js'
Returns true if and only if input number A is 0.
Returns true if aj <= ai. O(|A|) time in the worst case. O(1) time if A has no leading zero.
public le(a: number[], ai: number, aj: number, b: number[], bi: number, bj: number): boolean source
import le from '@arithmetic-operations-for/naturals-big-endian/src/api/compare/le.js'
Compares two big endian arrays: returns true if the first is less or equal to the second.
Input:
- |A| >= 0
- |B| >= 0
public lt(a: number[], ai: number, aj: number, b: number[], bi: number, bj: number): boolean source
import lt from '@arithmetic-operations-for/naturals-big-endian/src/api/compare/lt.js'
Compares two big endian arrays: returns true if the first is less than the second.
Input:
- |A| >= 0
- |B| >= 0
public mul(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number, c: Array, ci: Number, cj: Number): * source
Multiplies two big endian arrays and puts result in a destination array.
Constraints:
- C is zero initialized,
- |A| >= 0,
- |B| >= 0,
- |C| >= |A| + |B|.
Return:
* |
public ne(a: number[], ai: number, aj: number, b: number[], bi: number, bj: number): boolean source
import ne from '@arithmetic-operations-for/naturals-big-endian/src/api/compare/ne.js'
Tests whether two big endian arrays are not equal.
Input:
- |A| >= 0
- |B| >= 0
public parse(f: number, t: number, string: string): number[] source
import parse from '@arithmetic-operations-for/naturals-big-endian/src/api/convert/parse.js'
Converts a string representation in base f to a limb array in base t.
public parse_keep_zeros(f: number, t: number, string: string): number[] source
import parse_keep_zeros from '@arithmetic-operations-for/naturals-big-endian/src/core/convert/parse_keep_zeros.js'
Converts a string representation in base f to a limb array in base t keeping all leading zeros resulting from the conversion process.
public stringify(f: number, t: number, a: number[], ai: number, aj: number): string source
import stringify from '@arithmetic-operations-for/naturals-big-endian/src/api/convert/stringify.js'
Converts a limb array in base f to a string representation in base t.
public translate(f: number, t: number, string: string): string source
import translate from '@arithmetic-operations-for/naturals-big-endian/src/api/convert/translate.js'
Converts a string representation in base f to a string representation in base t.
public trim_natural(a: number[], ai: number, aj: number): number[] source
import trim_natural from '@arithmetic-operations-for/naturals-big-endian/src/core/convert/trim_natural.js'
Trim a limb array so that it is either [0] or does not start with any leading zeros. Return a newly allocated array and does not modify the input.
Static Private
private _add(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number, c: Array, ci: Number, cj: Number) source
Adds two big endian arrays and puts result in a destination array. Wraps on overflow. |C| >= |A| >= |B|.
private _alloc(n: number): number[] source
import _alloc from '@arithmetic-operations-for/naturals-big-endian/src/core/array/_alloc.js'
Allocate a new limb array.
Params:
Name | Type | Attribute | Description |
n | number | The size of the array to allocate. |
private _build(base: *, number: *, data: *, n: *): * source
import _build from '@arithmetic-operations-for/naturals-big-endian/src/core/array/_build.js'
Params:
Name | Type | Attribute | Description |
base | * | ||
number | * | ||
data | * | ||
n | * |
Return:
* |
private _chr(x: number): string source
import _chr from '@arithmetic-operations-for/naturals-big-endian/src/core/convert/_chr.js'
Converts a limb to a character representation. This only works if the limb is at most 35.
Params:
Name | Type | Attribute | Description |
x | number | The input limb. |
private _cmp(a: number[], ai: number, aj: number, b: number[], bi: number, bj: number): number source
import _cmp from '@arithmetic-operations-for/naturals-big-endian/src/core/compare/_cmp.js'
Compares two big endian arrays. The second operand cannot have more limbs than the first.
Input:
- |A| >= |B| >= 0
private _cmp_half(r: Number, a: array, ai: Number, aj: Number): Number source
import _cmp_half from '@arithmetic-operations-for/naturals-big-endian/src/core/compare/_cmp_half.js'
Compares a number A with size n = |A| to R = (r^n)/2. When n=0, R=1/2, hence result is -1.
private _cmp_half_even_radix(_r: *, a: *, ai: *, aj: *): * source
import _cmp_half_even_radix from '@arithmetic-operations-for/naturals-big-endian/src/core/compare/_cmp_half_even_radix.js'
Params:
Name | Type | Attribute | Description |
_r | * | ||
a | * | ||
ai | * | ||
aj | * |
Return:
* |
private _cmp_half_odd_radix(_r: *, a: *, ai: *, aj: *): * source
import _cmp_half_odd_radix from '@arithmetic-operations-for/naturals-big-endian/src/core/compare/_cmp_half_odd_radix.js'
Params:
Name | Type | Attribute | Description |
_r | * | ||
a | * | ||
ai | * | ||
aj | * |
Return:
* |
private _cmp_n(a: number[], ai: number, aj: number, b: number[], bi: number): number source
import _cmp_n from '@arithmetic-operations-for/naturals-big-endian/src/core/compare/_cmp_n.js'
Compares two big endian arrays.
Input:
- |A| = |B|
private _convert(f: number, t: number, a: number[], ai: number, aj: number, b: number[], bi: number, bj: number): * source
import _convert from '@arithmetic-operations-for/naturals-big-endian/src/core/convert/_convert.js'
Dispatcher for the various base conversion implementations. The decision is based on the relation f <= t.
Params:
Name | Type | Attribute | Description |
f | number | the base to convert from |
|
t | number | the base to convert to |
|
a | number[] | the origin array |
|
ai | number | start offset in the origin array |
|
aj | number | end offset in the origin array |
|
b | number[] | the destination array |
|
bi | number | start offset in the destination array |
|
bj | number | end offset in the destination array |
Return:
* |
private _convert_dc(size_small_block: Number, f: Number, t: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number) source
import _convert_dc from '@arithmetic-operations-for/naturals-big-endian/src/core/convert/_convert_dc.js'
O(M(N) log N) where M(N) is multiplication time complexity.
- bj - bi >= log_t(f) * ( aj - ai ) ;
Roughly, split number A into two halves A0 * f^l + A1. Convert A0 to B0 and A1 to B1 recursively. Then multiply B0 by f^l in base t and finally add B1.
This implementation is not recursive. It is iterative, and will call a simpler subroutine for the base case.
Params:
Name | Type | Attribute | Description |
size_small_block | Number | the size of a small block |
|
f | Number | the base to convert from |
|
t | Number | the base to convert to |
|
a | Array | the origin array |
|
ai | Number | start offset in the origin array |
|
aj | Number | end offset in the origin array |
|
b | Array | the destination array |
|
bi | Number | start offset in the destination array |
|
bj | Number | end offset in the destination array |
private _convert_slow(f: Number, t: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number): * source
import _convert_slow from '@arithmetic-operations-for/naturals-big-endian/src/core/convert/_convert_slow.js'
F != t
Params:
Name | Type | Attribute | Description |
f | Number | the base to convert from |
|
t | Number | the base to convert to |
|
a | Array | the origin array |
|
ai | Number | start offset in the origin array |
|
aj | Number | end offset in the origin array |
|
b | Array | the destination array |
|
bi | Number | start offset in the destination array |
|
bj | Number | end offset in the destination array |
Return:
* |
private _convert_to_larger(f: Number, t: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number): * source
import _convert_to_larger from '@arithmetic-operations-for/naturals-big-endian/src/core/convert/_convert_to_larger.js'
Params:
Name | Type | Attribute | Description |
f | Number | the base to convert from |
|
t | Number | the base to convert to |
|
a | Array | the origin array |
|
ai | Number | start offset in the origin array |
|
aj | Number | end offset in the origin array |
|
b | Array | the destination array |
|
bi | Number | start offset in the destination array |
|
bj | Number | end offset in the destination array |
Return:
* |
private _convert_to_larger_fast(ar: Number, z: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number) source
import _convert_to_larger_fast from '@arithmetic-operations-for/naturals-big-endian/src/core/convert/_convert_to_larger_fast.js'
Params:
Name | Type | Attribute | Description |
ar | Number | the base to convert from |
|
z | Number | if br is the base to convert to then log(br) = z log(ar) |
|
a | Array | the origin array |
|
ai | Number | start offset in the origin array |
|
aj | Number | end offset in the origin array |
|
b | Array | the destination array |
|
bi | Number | start offset in the destination array |
|
bj | Number | end offset in the destination array |
private _convert_to_larger_slow(f: Number, t: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number) source
import _convert_to_larger_slow from '@arithmetic-operations-for/naturals-big-endian/src/core/convert/_convert_to_larger_slow.js'
O(N^2). f < t.
Params:
Name | Type | Attribute | Description |
f | Number | the base to convert from |
|
t | Number | the base to convert to |
|
a | Array | the origin array |
|
ai | Number | start offset in the origin array |
|
aj | Number | end offset in the origin array |
|
b | Array | the destination array |
|
bi | Number | start offset in the destination array |
|
bj | Number | end offset in the destination array |
private _convert_to_smaller(f: Number, t: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number): * source
import _convert_to_smaller from '@arithmetic-operations-for/naturals-big-endian/src/core/convert/_convert_to_smaller.js'
Params:
Name | Type | Attribute | Description |
f | Number | the base to convert from |
|
t | Number | the base to convert to |
|
a | Array | the origin array |
|
ai | Number | start offset in the origin array |
|
aj | Number | end offset in the origin array |
|
b | Array | the destination array |
|
bi | Number | start offset in the destination array |
|
bj | Number | end offset in the destination array |
Return:
* |
private _convert_to_smaller_fast(br: Number, z: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number) source
import _convert_to_smaller_fast from '@arithmetic-operations-for/naturals-big-endian/src/core/convert/_convert_to_smaller_fast.js'
Params:
Name | Type | Attribute | Description |
br | Number | the base to convert to |
|
z | Number | if ar is the base to convert to then log(ar) = z log(br) |
|
a | Array | the origin array |
|
ai | Number | start offset in the origin array |
|
aj | Number | end offset in the origin array |
|
b | Array | the destination array |
|
bi | Number | start offset in the destination array |
|
bj | Number | end offset in the destination array |
private _convert_to_smaller_slow(f: Number, t: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number) source
import _convert_to_smaller_slow from '@arithmetic-operations-for/naturals-big-endian/src/core/convert/_convert_to_smaller_slow.js'
O(N^2). f > t.
|A| >= 1 |B| is large enough to hold the result
Params:
Name | Type | Attribute | Description |
f | Number | the base to convert from |
|
t | Number | the base to convert to |
|
a | Array | the origin array |
|
ai | Number | start offset in the origin array |
|
aj | Number | end offset in the origin array |
|
b | Array | the destination array |
|
bi | Number | start offset in the destination array |
|
bj | Number | end offset in the destination array |
private _copy(a: number[], ai: number, aj: number, b: number[], bi: number) source
import _copy from '@arithmetic-operations-for/naturals-big-endian/src/core/array/_copy.js'
Copy a limb array into another limb array.
private _div_limb_with_prefix(r: Number, tmp: Number, d: Number, D: Array, Di: Number, Dj: Number, Q: Array, Qi: Number) source
import _div_limb_with_prefix from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/div/_div_limb_with_prefix.js'
Divides a big endian number by a single limb number. Can only work with limbs of size at most sqrt( 2^53 ). Allows to prefix the dividend with an intermediate remainder.
Does not update the remainder.
Input
- 0 <= tmp <= d - 1
- 1 <= d <= r - 1
- |Q| = |D|
private _divmod(r: Number, D: Array, Di: Number, Dj: Number, d: Array, di: Number, dj: Number, Q: Array, Qi: Number, Qj: Number, R: Array, Ri: Number, Rj: Number) source
import _divmod from '@arithmetic-operations-for/naturals-big-endian/src/api/arithmetic/div/_divmod.js'
Computes the quotient and remainder of two numbers. Uses the most appropriate algorithms depending on the size of the operands. The remainder is written to the dividend array. There are a few assumptions made on the input.
Input
- No leading zeros in D or Q.
- |D| = |Q| = |R|
Params:
Name | Type | Attribute | Description |
r | Number | The base to work with. |
|
D | Array | Dividend array. |
|
Di | Number | Left of dividend. |
|
Dj | Number | Right of dividend. |
|
d | Array | Divisor array. |
|
di | Number | Left of divisor. |
|
dj | Number | Right of divisor. |
|
Q | Array | Quotient array. |
|
Qi | Number | Left of quotient. |
|
Qj | Number | Right of quotient. |
|
R | Array | Remainder array. |
|
Ri | Number | Left of remainder. |
|
Rj | Number | Right of remainder. |
private _euclidean_algorithm_loop(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number): Array source
import _euclidean_algorithm_loop from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/gcd/_euclidean_algorithm_loop.js'
Euclidean algorithm. Computes the gcd of the two input numbers A and B, A >= B. Input arrays are modified in-place.
Input
- A >= B
- No leading zeros
Return:
Array | The array containing the gcd of A and B (one of A and B). Return as [ d , di , dj ], where d is the array and di and dj are its left and right bounds. |
private _extended_euclidean_algorithm(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number): * source
import _extended_euclidean_algorithm from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/gcd/_extended_euclidean_algorithm.js'
Precondition:
- A >= B
- No leading zeroes.
Return:
* |
private _extended_euclidean_algorithm_allocate(m: *, n: *): undefined[] source
import _extended_euclidean_algorithm_allocate from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/gcd/_extended_euclidean_algorithm_allocate.js'
M >= n >= 0 m >= 1
Params:
Name | Type | Attribute | Description |
m | * | ||
n | * |
private _extended_euclidean_algorithm_loop(r: *, R0: *, R1: *, S0: *, T0: *, S1: *, T1: *, Q: *, X: *): undefined[] source
import _extended_euclidean_algorithm_loop from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/gcd/_extended_euclidean_algorithm_loop.js'
Extended Euclidean algorithm.
Params:
Name | Type | Attribute | Description |
r | * | ||
R0 | * | ||
R1 | * | ||
S0 | * | ||
T0 | * | ||
S1 | * | ||
T1 | * | ||
Q | * | ||
X | * |
private _fill(a: number[], ai: number, aj: number, v: number) source
import _fill from '@arithmetic-operations-for/naturals-big-endian/src/core/array/_fill.js'
Fill the input limb array with a fixed value.
private _from_string(string: string): number[] source
import _from_string from '@arithmetic-operations-for/naturals-big-endian/src/core/convert/_from_string.js'
Converts a string representation to a limb array representation without radix conversion.
Params:
Name | Type | Attribute | Description |
string | string | input string |
private _iadd(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number) source
import _iadd from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/add/_iadd.js'
Adds a big endian array to another. Wraps on overflow. |A| >= |B|.
private _iadd_limb(r: Number, x: Number, a: Array, ai: Number, aj: Number) source
import _iadd_limb from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/add/_iadd_limb.js'
Adds single limb to a big endian array. Wraps on overflow.
Input:
- |A| >= 1.
private _idivmod(r: Number, D: Array, Di: Number, Dj: Number, d: Array, di: Number, dj: Number, Q: Array, Qi: Number, Qj: Number): * source
import _idivmod from '@arithmetic-operations-for/naturals-big-endian/src/api/arithmetic/div/_idivmod.js'
Computes the quotient and remainder of two numbers. Uses the most appropriate algorithm depending on the size of the operands. The remainder is written to the dividend array. There are a few assumptions made on the input.
Input
- |d| >= 1
- |D| = |Q| >= 1
- No leading zeros in D or d.
- Q is zero initialized.
Params:
Name | Type | Attribute | Description |
r | Number | The base to work with. |
|
D | Array | Dividend / Remainder array (remainder computed in-place). |
|
Di | Number | Left of dividend. |
|
Dj | Number | Right of dividend. |
|
d | Array | Divisor array. |
|
di | Number | Left of divisor. |
|
dj | Number | Right of divisor. |
|
Q | Array | Quotient array (zero initialized). |
|
Qi | Number | Left of quotient. |
|
Qj | Number | Right of quotient. |
Return:
* |
private _idivmod_dc(X: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number, c: Array, ci: Number, cj: Number) source
import _idivmod_dc from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/div/_idivmod_dc.js'
Input
- No leading zeros
- |A| = |C|
- C must be zero-initialized.
References
private _idivmod_dc_21(r: *, a: *, ai: *, aj: *, b: *, bi: *, bj: *, c: *, ci: *, cj: *): * source
import _idivmod_dc_21 from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/div/_idivmod_dc_21.js'
Algorithm 3.3 Divide-and-conquer division (2 by 1)
Input
Two nonnegative integers A and B, such that A < β^n B and β^n / 2 ≤ B < β^n. n must be even if n >= THRESHOLD_DIV_DC.
----------- -----
| : | : | | : |
----------- -----
Output
The quotient floor( A/B ) and the remainder A mod B.
Complexity
T(n) = 2T'(n/2) + K
Params:
Name | Type | Attribute | Description |
r | * | ||
a | * | ||
ai | * | ||
aj | * | ||
b | * | ||
bi | * | ||
bj | * | ||
c | * | ||
ci | * | ||
cj | * |
Return:
* |
private _idivmod_dc_32(r: *, a: *, ai: *, aj: *, b: *, bi: *, bj: *, c: *, ci: *, cj: *) source
import _idivmod_dc_32 from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/div/_idivmod_dc_32.js'
Algorithm 3.4 Divide-and-conquer division (3 by 2)
Input
Two nonnegative integers A and B, such that A < β^n B and β^{2n} / 2 ≤ B < β^{2n}. n must be even.
-------- -----
| | | | | | |
-------- -----
Output
The quotient floor( A/B ) and the remainder A mod B.
Complexity
T'(n) ≤ T(n) + M(n) + Ln
Params:
Name | Type | Attribute | Description |
r | * | ||
a | * | ||
ai | * | ||
aj | * | ||
b | * | ||
bi | * | ||
bj | * | ||
c | * | ||
ci | * | ||
cj | * |
private _idivmod_limb(r: Number, d: Number, D: Array, Di: Number, Dj: Number, Q: Array, Qi: Number): * source
import _idivmod_limb from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/div/_idivmod_limb.js'
Divides a big endian number by a single limb number. Can only work with limbs of size at most sqrt( 2^53 ).
Return:
* |
private _idivmod_limb_with_prefix(r: Number, tmp: Number, d: Number, D: Array, Di: Number, Dj: Number, Q: Array, Qi: Number) source
import _idivmod_limb_with_prefix from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/div/_idivmod_limb_with_prefix.js'
Divides a big endian number by a single limb number. Can only work with limbs of size at most sqrt( 2^53 ). Allows to prefix the dividend with an intermediate remainder.
Input
- |Q| = |D| >= 1.
- NO NEED to reset Q. The loop will set every member of Q.
private _idivmod_schoolbook(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number, q: Array, qi: Number) source
import _idivmod_schoolbook from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/div/_idivmod_schoolbook.js'
Computes q <- a / b and a <- a % b. No leading zeros allowed. q has length at least aj - ai
private _idivmod_schoolbook_large_divisor(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number, q: Array, qi: Number): * source
import _idivmod_schoolbook_large_divisor from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/div/_idivmod_schoolbook_large_divisor.js'
Input
- Two integers A and B such that r^(m-1) <= A < r^m and (r^n)/2 <= B < r^(n).
- No leading zeros (ONLY IN B?)
- Q is initialized with some limbs.
Output
The quotient floor( A/B ) and the remainder A mod B.
Return:
* |
private _idivmod_schoolbook_subroutine(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number, q: Array, qi: Number) source
import _idivmod_schoolbook_subroutine from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/div/_idivmod_schoolbook_subroutine.js'
Input
- Two integers A and B such that 0 <= A < β^(n+1) and (β^n)/2 <= B < β^n.
- |A| = |B| + 1
- |Q| = |A|
Output
The quotient floor( A/B ) and the remainder A mod B.
private _idivmod_schoolbook_subroutine_do(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number, q: Array, qi: Number) source
import _idivmod_schoolbook_subroutine_do from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/div/_idivmod_schoolbook_subroutine_do.js'
Input
- Two integers A and B such that 0 <= A < B * β and (β^n)/2 <= B < β^n. (Hence B >= 1).
- |A| = |B| + 1
- |Q| = |A|
Output
The quotient floor( A/B ) and the remainder A mod B.
private _idivmod_slow(x: Number, r: array, ri: Number, rj: Number, b: array, bi: Number, bj: Number, q: array, qi: Number) source
import _idivmod_slow from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/div/_idivmod_slow.js'
Computes quotient and remainder of two big endian arrays.
Computes quotient and remainder of two big endian arrays using long division algorithm (the one teached in european primary schools).
/!\ This algorithm modifies its first operand.
HYP : q is at least as large as r b is not zero
private _imod(r: Number, D: Array, Di: Number, Dj: Number, d: Array, di: Number, dj: Number, _: Array, _i: Number, _j: Number): * source
import _imod from '@arithmetic-operations-for/naturals-big-endian/src/api/arithmetic/div/_imod.js'
Computes the remainder of two numbers. Uses the most appropriate algorithm depending on the size of the operands. The remainder is written to the dividend array. There are a few assumptions made on the input.
Input
- |d| >= 1
- |D| = |_| >= 1
- No leading zeros in D or d.
Params:
Name | Type | Attribute | Description |
r | Number | The base to work with. |
|
D | Array | Dividend / Remainder array (remainder computed in-place). |
|
Di | Number | Left of dividend. |
|
Dj | Number | Right of dividend. |
|
d | Array | Divisor array. |
|
di | Number | Left of divisor. |
|
dj | Number | Right of divisor. |
|
_ | Array | Additional memory array. |
|
_i | Number | Left of memory. |
|
_j | Number | Right of memory. |
Return:
* |
private _imod_limb(r: Number, d: Number, D: Array, Di: Number, Dj: Number) source
import _imod_limb from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/div/_imod_limb.js'
Divides a big endian number by a single limb number and writes the remainder to the dividend array.
Computes a <- a % b. Only works with limbs of size at most sqrt( 2^53 ).
private _imod_schoolbook(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number) source
import _imod_schoolbook from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/div/_imod_schoolbook.js'
Divides a big endian number by another big endian number and writes the remainder to the dividend array.
Computes a <- a % b. No leading zeros allowed.
private _imod_schoolbook_large_divisor(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number): * source
import _imod_schoolbook_large_divisor from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/div/_imod_schoolbook_large_divisor.js'
Input
- Two integers A and B such that r^(m-1) <= A < r^m and (r^n)/2 <= B < r^(n).
- No leading zeros (ONLY IN B?)
Output
The remainder A mod B.
Return:
* |
private _imod_schoolbook_subroutine(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number) source
import _imod_schoolbook_subroutine from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/div/_imod_schoolbook_subroutine.js'
Input
- Two integers A and B such that 0 <= A < β^(n+1) and (β^n)/2 <= B < β^n.
- |A| = |B| + 1
Output
The remainder A mod B.
private _imod_schoolbook_subroutine_do(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number) source
import _imod_schoolbook_subroutine_do from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/div/_imod_schoolbook_subroutine_do.js'
Input
- Two integers A and B such that 0 <= A < B * β and (β^n)/2 <= B < β^n. (Hence B >= 1).
- |A| = |B| + 1
Output
The remainder A mod B.
private _int(x: string): number source
import _int from '@arithmetic-operations-for/naturals-big-endian/src/core/convert/_int.js'
Converts an input character representation to a limb.
Params:
Name | Type | Attribute | Description |
x | string | input character |
private _isub(r: Number, a: array, ai: Number, aj: Number, b: array, bi: Number, bj: Number) source
import _isub from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/sub/_isub.js'
Subtracts B from A, |A| >= |B|. Wraps.
private _karatsuba(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number, c: Array, ci: Number, cj: Number): * source
import _karatsuba from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/mul/_karatsuba.js'
Multiply two big endian arrays using karatsuba algorithm, |A| >= |B| >= 1, |C| >= |A| + |B|, |A| >= 2.
/!\ BLOCK MULTIPLICATION RESULT MUST HOLD IN THE JAVASCRIPT NUMBER TYPE (DOUBLE i.e. 53 bits)
EXPLANATION
###########
We consider the numbers a and b, both of size N = 2n.
We divide a and b into their lower and upper parts.
a = a1 r^{n} + a0 (1) b = b1 r^{n} + b0 (2)
We express the product of a and b using their lower and upper parts.
a b = (a1 r^{n} + a0) (b1 r^{n} + b0) (3) = a1 b1 r^{2n} + (a1 b0 + a0 b1) r^{n} + a0 b0 (4)
This gives us 4 multiplications with operands of size n. Using a simple trick, we can reduce this computation to 3 multiplications.
We give the 3 terms of (4) the names z0, z1 and z2.
z2 = a1 b1 z1 = a1 b0 + a0 b1 z0 = a0 b0
a b = z2 r^{2n} + z1 r^{n} + z0
We then express z1 using z0, z2 and one additional multiplication.
(a1 + a0)(b1 + b0) = a1 b1 + a0 b0 + (a1 b0 + a0 b1) = z2 + z0 + z1
z1 = (a1 + a0)(b1 + b0) - z2 - z0
AN ANOTHER WAY AROUND (not used here)
(a1 - a0)(b1 - b0) = (a1 b1 + a0 b0) - (a1 b0 + a0 b1) (a0 - a1)(b1 - b0) = (a1 b0 + a0 b1) - (a1 b1 + a0 b0) a b = (r^{2n} + r^{n})a1 b1 + r^{n}(a0 - a1)(b1 - b0) + (r^{n} + 1)a0 b0
This algorithm is a specific case of the Toom-Cook algorithm, when m = n = 2.
For further reference, see
Return:
* |
private _karatsuba_right_op_is_small(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number, c: Array, ci: Number, cj: Number) source
import _karatsuba_right_op_is_small from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/mul/_karatsuba_right_op_is_small.js'
Multiply two big endian arrays using karatsuba algorithm, WHEN THE SECOND OPERAND IS SMALL. |A| >= |B| >= 1, |C| >= |A| + |B|, |A| >= 2, Math.ceil(|A|/2) >= |B|.
/!\ BLOCK MULTIPLICATION RESULT MUST HOLD IN THE JAVASCRIPT NUMBER TYPE (DOUBLE i.e. 53 bits)
EXPLANATION
###########
We consider the numbers a and b0. a has size N = 2n, and b0 has size n.
We divide a into its lower and upper parts.
a = a1 r^{n} + a0 (1)
We express the product of a and b0 using these.
a b0 = (a1 r^{n} + a0) b0 (3) = a1 b0 r^{n} + a0 b0 (4)
This gives us 2 multiplications with operands of size n.
private _log(x: *, y: *): undefined[] source
import _log from '@arithmetic-operations-for/naturals-big-endian/src/core/convert/_log.js'
Params:
Name | Type | Attribute | Description |
x | * | ||
y | * |
private _mod_limb(r: Number, d: Number, D: Array, Di: Number, Dj: Number): Number source
import _mod_limb from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/div/_mod_limb.js'
Divides a big endian number by a single limb number and returns only the remainder.
Only works with limbs of size at most sqrt( 2^53 ).
private _mul(r: Number, a: Array, ai: Number, aj: Number, b: Array, bi: Number, bj: Number, c: Array, ci: Number, cj: Number): * source
Computes C = A+B.
Constraints:
- C is zero initialized,
- |A| >= |B| >= 0,
- |C| >= |A| + |B|.
TODO:
- Use schoolbook mul if n = O(log m).
Params:
Name | Type | Attribute | Description |
r | Number | base (radix) |
|
a | Array | first operand |
|
ai | Number | a left |
|
aj | Number | a right |
|
b | Array | second operand, cannot have more limbs than A |
|
bi | Number | b left |
|
bj | Number | b right |
|
c | Array | result, must be 0 initialized and be able to contain A+B |
|
ci | Number | c left |
|
cj | Number | c right |
Return:
* |
private _mul_limb(r: *, x: *, b: *, bi: *, bj: *, c: *, ci: *, cj: *) source
import _mul_limb from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/mul/_mul_limb.js'
Compute x * b where x is a single limb. 0 <= x <= r-1 No restriction on operand sizes.
Params:
Name | Type | Attribute | Description |
r | * | ||
x | * | ||
b | * | ||
bi | * | ||
bj | * | ||
c | * | ||
ci | * | ||
cj | * |
private _pow_double(r: Number, x: Number, a: Array, ai: Number, aj: Number, c: Array, ci: Number, cj: Number) source
import _pow_double from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/pow/_pow_double.js'
Computes pow(a,x) = a^x
using exponentiation by squaring.
Writes result to output array.
/!\ |A| >= 1, |C| >= 1, |C| >= |A| * x, |C| = 000...0
private _pow_double_recursive(r: Number, x: Number, a: Array, ai: Number, aj: Number, c: Array, ci: Number, cj: Number) source
import _pow_double_recursive from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/pow/_pow_double_recursive.js'
Computes pow(a,x) = a^x
using exponentiation by squaring.
Writes result to output array.
/!\ |A| >= 1, |C| >= 1, |C| >= |A| * x, |C| = 000...0
private _reset(a: number[], ai: number, aj: number) source
import _reset from '@arithmetic-operations-for/naturals-big-endian/src/core/array/_reset.js'
Fill the input limb array with zeros.
private _schoolbook_mul(r: *, a: *, ai: *, aj: *, b: *, bi: *, bj: *, c: *, ci: *, cj: *) source
import _schoolbook_mul from '@arithmetic-operations-for/naturals-big-endian/src/core/arithmetic/mul/_schoolbook_mul.js'
Computes the product of two big endian arrays using schoolbook multiplication. |C| >= |A|+|B|.
TODO Can this be optimized if we know that |A| >= |B|? Probably better to do many small passes rather than few large passes ?! This is what this implementation achieves, although it returns correct results even when |A| < |B|.
Params:
Name | Type | Attribute | Description |
r | * | ||
a | * | ||
ai | * | ||
aj | * | ||
b | * | ||
bi | * | ||
bj | * | ||
c | * | ||
ci | * | ||
cj | * |
private _sub(r: Number, a: array, ai: Number, aj: Number, b: array, bi: Number, bj: Number, c: array, ci: Number, cj: Number) source
Subtracts two big endian arrays, |C| >= |A| >= |B|. Wraps.
private _to_string(b: number[]): string source
import _to_string from '@arithmetic-operations-for/naturals-big-endian/src/core/convert/_to_string.js'
Convert an entire limb array to a string representation (without changing the radix).
Params:
Name | Type | Attribute | Description |
b | number[] | The inpurt limb array. |
private _trim_positive(a: number[], ai: number, aj: number): number source
import _trim_positive from '@arithmetic-operations-for/naturals-big-endian/src/core/convert/_trim_positive.js'
Compute the new inclusive left bound of a limb array by skipping all leading zeros.
private _validate(base: *, a: *, ai: *, aj: *): boolean source
import _validate from '@arithmetic-operations-for/naturals-big-endian/src/core/array/_validate.js'
Params:
Name | Type | Attribute | Description |
base | * | ||
a | * | ||
ai | * | ||
aj | * |
private _zeros(n: number): number[] source
import _zeros from '@arithmetic-operations-for/naturals-big-endian/src/core/array/_zeros.js'
Allocate a new limb array filled with zeros.
Params:
Name | Type | Attribute | Description |
n | number | The size of the allocated array. |