LatMRG Guide  1.0
A software package to test and search for new linear congruential random number generators
LatMRG::IntFactorization< Int > Class Template Reference

The class IntFactorization implements the decomposition of integers in factors, preferably prime (see class IntFactor). More...

#include <latmrg/IntFactorization.h>

Classes

class  CompFactor
 Nested class used to sort the prime factors of a number in increasing order. More...
 

Public Member Functions

 IntFactorization (const Int &x)
 Integer \(x\) is the number whose "prime" factors decomposition is kept in this object. More...
 
 IntFactorization (const char *fname=0)
 Integer number and its prime factors will be read from file fname by calling method read below. More...
 
 IntFactorization (const IntFactorization &f)
 Copy constructor. More...
 
 ~IntFactorization ()
 Destructor. More...
 
void addFactor (const Int &p, int mult=1, LatticeTester::PrimeType st=LatticeTester::UNKNOWN)
 Adds factor \(p\) with multiplicity mult and prime status st to this object. More...
 
void calcInvFactors ()
 Given the list of prime factors \(p\) of number, fills the list of inverse factors with the values number/ \(p\). More...
 
bool checkProduct () const
 Checks that the number is equal to the product of its factors. More...
 
void clear ()
 Empties the lists of primes factors and set this number to 0. More...
 
void factorize ()
 Tries to find all the prime factors of this number. More...
 
const std::list< LatticeTester::IntFactor< Int > > & getFactorList () const
 Returns a non-mutable list of the factors. More...
 
const std::vector< Int > & getInvFactorList () const
 Returns a non-mutable list of the inverse factors. More...
 
Int getNumber () const
 Returns the value of this number. More...
 
LatticeTester::PrimeType getStatus () const
 Returns the status of this number. More...
 
IntFactorizationoperator= (const IntFactorization &f)
 Assignment operator. More...
 
void read (const char *f)
 Reads the list of (possibly) prime factors of a number from file f. More...
 
void setNumber (const Int &x)
 Sets the value of this number to \(x\). More...
 
void setStatus (LatticeTester::PrimeType s)
 Sets the status of this number to \(s\). More...
 
std::string toString () const
 Returns the list of (possibly) prime factors of this object in the same format as described in method read above. More...
 
void unique ()
 Replaces repeated equal factors in factorList by one factor with its multiplicity. More...
 

Private Member Functions

void sort ()
 Sorts the list of factors in increasing order, the smallest factor first. More...
 

Private Attributes

std::list< LatticeTester::IntFactor< Int > > m_factorList
 The list of the "prime" factors in the decomposition of number. More...
 
std::vector< Int > m_invFactorList
 Given the list of prime factors \(p\) of number, invFactorList contains all the sorted values number/ \(p\) (indexing starts at 0). More...
 
Int m_number
 The number whose "prime" factor decomposition is kept in this object. More...
 
LatticeTester::PrimeType m_status
 The status of this number, i.e. More...
 

Detailed Description

template<typename Int>
class LatMRG::IntFactorization< Int >

The class IntFactorization implements the decomposition of integers in factors, preferably prime (see class IntFactor).

It contains functions to factorize an integer in prime factors, to sort and print the list of its factors. IntFactorization Integers are factorized by calling the MIRACL software [iSCO03a], which uses many different methods in succession to effect the factorization.

Given any natural integer \(n\), there is a unique decomposition in prime factors of the form

\[ n = p_1^{\nu_1}p_2^{\nu_2}\cdots p_s^{\nu_s} \]

where \(p_i\) is a prime integer with \(\nu_i\) its multiplicity, and where the factors are sorted in increasing order. In the case of very large integers, it may not be possible to find all the prime factors within a reasonable amount of time. In that case, a similar decomposition to the above may be used with some of the factors composite.

Constructor & Destructor Documentation

◆ IntFactorization() [1/3]

template<typename Int>
LatMRG::IntFactorization< Int >::IntFactorization ( const Int &  x)
explicit

Integer \(x\) is the number whose "prime" factors decomposition is kept in this object.

◆ IntFactorization() [2/3]

template<typename Int>
LatMRG::IntFactorization< Int >::IntFactorization ( const char *  fname = 0)
explicit

Integer number and its prime factors will be read from file fname by calling method read below.

If no argument is given, number is initialized to 0.

◆ ~IntFactorization()

template<typename Int >
LatMRG::IntFactorization< Int >::~IntFactorization ( )

Destructor.

◆ IntFactorization() [3/3]

template<typename Int>
LatMRG::IntFactorization< Int >::IntFactorization ( const IntFactorization< Int > &  f)

Copy constructor.

Member Function Documentation

◆ addFactor()

template<typename Int>
void LatMRG::IntFactorization< Int >::addFactor ( const Int &  p,
int  mult = 1,
LatticeTester::PrimeType  st = LatticeTester::UNKNOWN 
)

Adds factor \(p\) with multiplicity mult and prime status st to this object.

◆ calcInvFactors()

template<typename Int >
void LatMRG::IntFactorization< Int >::calcInvFactors ( )

Given the list of prime factors \(p\) of number, fills the list of inverse factors with the values number/ \(p\).

◆ checkProduct()

template<typename Int >
bool LatMRG::IntFactorization< Int >::checkProduct ( ) const

Checks that the number is equal to the product of its factors.

Returns true if it is, otherwise false.

◆ clear()

template<typename Int >
void LatMRG::IntFactorization< Int >::clear ( )

Empties the lists of primes factors and set this number to 0.

◆ factorize()

template<typename Int >
void LatMRG::IntFactorization< Int >::factorize ( )

Tries to find all the prime factors of this number.

◆ getFactorList()

template<typename Int>
const std::list<LatticeTester::IntFactor<Int> >& LatMRG::IntFactorization< Int >::getFactorList ( ) const
inline

Returns a non-mutable list of the factors.

◆ getInvFactorList()

template<typename Int>
const std::vector<Int>& LatMRG::IntFactorization< Int >::getInvFactorList ( ) const
inline

Returns a non-mutable list of the inverse factors.

◆ getNumber()

template<typename Int>
Int LatMRG::IntFactorization< Int >::getNumber ( ) const
inline

Returns the value of this number.

◆ getStatus()

template<typename Int>
LatticeTester::PrimeType LatMRG::IntFactorization< Int >::getStatus ( ) const
inline

Returns the status of this number.

◆ operator=()

template<typename Int >
IntFactorization< Int > & LatMRG::IntFactorization< Int >::operator= ( const IntFactorization< Int > &  f)

Assignment operator.

◆ read()

template<typename Int >
void LatMRG::IntFactorization< Int >::read ( const char *  f)

Reads the list of (possibly) prime factors of a number from file f.

The first line contains the number itself. The following lines contain one factor per line: the factor (first field) with its multiplicity (second field) and its status (third field). The status field is written as P if the factor is known to be prime, Q if the factor is probably prime, C if the factor is composite, and U if its status is unknown or unimportant. For example, given the number \(120= 2^3*3*5\), then the file must be

120
2\ P
3 P
5 P

◆ setNumber()

template<typename Int>
void LatMRG::IntFactorization< Int >::setNumber ( const Int &  x)
inline

Sets the value of this number to \(x\).

◆ setStatus()

template<typename Int>
void LatMRG::IntFactorization< Int >::setStatus ( LatticeTester::PrimeType  s)
inline

Sets the status of this number to \(s\).

◆ sort()

template<typename Int>
void LatMRG::IntFactorization< Int >::sort ( )
inlineprivate

Sorts the list of factors in increasing order, the smallest factor first.

◆ toString()

template<typename Int >
std::string LatMRG::IntFactorization< Int >::toString ( ) const

Returns the list of (possibly) prime factors of this object in the same format as described in method read above.

◆ unique()

template<typename Int >
void LatMRG::IntFactorization< Int >::unique ( )

Replaces repeated equal factors in factorList by one factor with its multiplicity.

Also sorts the factors.

Member Data Documentation

◆ m_factorList

template<typename Int>
std::list<LatticeTester::IntFactor<Int> > LatMRG::IntFactorization< Int >::m_factorList
private

The list of the "prime" factors in the decomposition of number.

◆ m_invFactorList

template<typename Int>
std::vector<Int> LatMRG::IntFactorization< Int >::m_invFactorList
private

Given the list of prime factors \(p\) of number, invFactorList contains all the sorted values number/ \(p\) (indexing starts at 0).

However, one must have called the function calcInvFactors beforehand. For example, if number = 24, its prime factors decomposition is \(24 = 2^3\cdot3\), and invfactorList = \([8, 12]\).

◆ m_number

template<typename Int>
Int LatMRG::IntFactorization< Int >::m_number
private

The number whose "prime" factor decomposition is kept in this object.

◆ m_status

template<typename Int>
LatticeTester::PrimeType LatMRG::IntFactorization< Int >::m_status
private

The status of this number, i.e.

whether it is prime, composite, ...


The documentation for this class was generated from the following file: