@rwk/physics-math
Version:
Math for physics homework problems
49 lines • 1.89 kB
TypeScript
/**
* Algebraic manipulations.
* @packageDocumentation
* @module Algebra
* @preferred
*/
/**
* The Miller Rabin algorithm.
*
* For the moment, due to lack of universal BigInt support and unlikeliness of need,
* we accept that it will be inaccurate on platforms w/o BigInt (e.g. Safari) above
* 94906265 (Math.floor(Math.sqrt(Number.MAX_SAFE_INTEGER)).
* @arg n the number to be tested for primality.
* @return true if n is prime, else returns false
*/
export declare const isPrime: (n: number) => boolean;
/**
* The Miller Rabin algorithm. The opposite of [isPrime].
*
* For the moment, due to lack of universal BigInt support and unlikeliness of need,
* we accept that it will be inaccurate on platforms w/o BigInt (e.g. Safari) above
* 94906265 (Math.floor(Math.sqrt(Number.MAX_SAFE_INTEGER)).
* @arg n the number to be tested for primality.
* @return true if n is prime, else returns false
*/
export declare const isComposite: (n: number) => boolean;
/**
* GCD, for either two numbers or two BigInts.
* @param a
* @param b
*/
export declare function gcd(a: number, b: number): number;
export declare function gcd(a: bigint, b: bigint): bigint;
/**
* Extended GCD
* @param a
* @param b
* @return [gcd, factor_a, factor_b] such that gcd*factor_a = a, gcd*factor_b = b.
*/
export declare function xgcd(a: number, b: number): [number, number, number];
export declare function xgcd(a: bigint, b: bigint): [bigint, bigint, bigint];
export declare function sieve(lim: number): Generator<number, void, unknown>;
/**
* Returns a generator with a number's factors. Uses a pre-computed sieve up to 16K, then Brent's algorithm,
* which has a small chance of failing
* @param n The number to be factored.
*/
export declare function factor(n: number): Generator<number, void, unknown>;
//# sourceMappingURL=algebra.d.ts.map