factory-0.0.0.2: Rational arithmetic in an irrational world.

Factory.Math.PrimeFactorisation

Contents

Description

AUTHOR
Dr. Alistair Ward
DESCRIPTION
  • http://en.wikipedia.org/wiki/Integer_factorization.
  • Exports a common interface to permit decomposition of positive integers, into the unique combination of prime-factors known to exist according to the Fundamental Theorem of Arithmetic; http://en.wikipedia.org/wiki/Fundamental_theorem_of_arithmetic.
  • Leveraging this abstract capability, it derives the smoothness, power-smoothness, and omega-numbers.
  • Filters the list of regular-numbers from the list of smoothness.
  • CAVEAT: to avoid wasting time, it may be advantageous to check Factory.Math.Primality.isPrime first.

Synopsis

Type-classes

class Algorithm algorithm whereSource

Defines the methods expected of a factorisation-algorithm.

Methods

primeFactorsSource

Arguments

:: (NFData base, Integral base) 
=> algorithm 
-> base

The operand

-> Factors base Int 

Instances

Functions

maxBoundPrimeFactor :: Integral i => i -> iSource

  • The upper limit for a prime to be considered as a candidate factor of the specified number.
  • One might naively think that this limit is (x div 2) for an even number, but though a prime-factor greater than the square-root of the number can exist, its smaller cofactor decomposes to a prime which must be less than the square-root.
  • NB: rather using (primeFactor <= sqrt numerator) to filter the candidate prime-factors of a given numerator, one can alternatively use (numerator >= primeFactor ^ 2) to filter what can potentially be factored by a given prime-factor.

smoothness :: (Algorithm algorithm, NFData base, Integral base) => algorithm -> [base]Source

powerSmoothness :: (Algorithm algorithm, NFData base, Integral base) => algorithm -> [base]Source

regularNumbers :: (Algorithm algorithm, NFData base, Integral base) => algorithm -> [base]Source

primePowerTotient :: (Integral base, Integral exponent) => Exponential base exponent -> baseSource

  • Euler's Totient for a power of a prime-number.
  • By Olofsson; (phi(n^k) = n^(k - 1) * phi(n)) and since (phi(prime) = prime - 1)
  • CAVEAT: checks neither the primality nor the bounds of the specified value; therefore for internal use only.

eulersTotient :: (Algorithm algorithm, NFData i, Integral i) => algorithm -> i -> iSource

omega :: (Algorithm algorithm, NFData i, Integral i) => algorithm -> [i]Source