util library

Classes

Primes
Prime number generator.

Extensions

ComplexArray on Float64x2List
Extension methods for Float64x2List, representing a list of complex numbers.

Properties

primes Primes
Static Primes object used to cache prime numbers between all the functions that need prime numbers.
final

Functions

expMod(int g, int k, int n) int
Returns g^k mod n.
highestBit(int x) int
Returns the highest set bit of x, where x is a power of 2.
isPowerOf2(int x) bool
Returns whether x is a power of two: 1, 2, 4, 8, ...
isPrime(int n) bool
Returns whether n is a prime number.
largestPrimeFactor(int n) int
Returns the largest prime factor of n.
largestPrimeFactorIsAbove(int n, int k) bool
Returns whether largestPrimeFactor(n) > k.
mergeTwosIntoFours(List<int> p) List<int>
Merges all the twos in a prime decomposition into fours.
multiplicativeInverseOfPrime(int x, int n) int
Returns the multiplicative inverse of x mod n, where n is a prime.
nextPowerOf2(int x) int
Returns the smallest power of two equal or greater than x.
primeDecomp(int n) List<int>
Returns the prime decomposition of n.
primeFactors(int n) List<int>
Returns the unique prime factors of n.
primePaddingHeuristic(int n) bool
Returns whether padding the PrimeFFT to a power of two size is likely to be faster than not padding it.
primitiveRootOfPrime(int n) int
Returns the primitive root of n, where n is a prime > 2.
twiddleFactors(int n) Float64x2List
Returns the twiddle factors for an FFT of size n. Aka the complex n-th roots of 1.