LatMRG Online Documentation unknown
Tools to analyze the lattice structure of linear generators
Loading...
Searching...
No Matches
LatMRG::IntFactorization< Int > Class Template Reference

Represents the factorization of an arbitrary positive integer, usually into prime factors, but not always. More...

Public Member Functions

 IntFactorization (const Int &x)
 Constructs a factorization for the integer \(x\).
 IntFactorization (const char *fname=0)
 Constructs a factorization object by reading the factorization from file fname using the read function defined below.
 ~IntFactorization ()
 Destructor.
 IntFactorization (const IntFactorization &f)
 Copy constructor.
IntFactorizationoperator= (const IntFactorization &f)
 Assignment operator.
void clear ()
 Empties the list of primes factors and set this number to 0.
void read (const char *f)
 Reads a factorization by reading the list of (possibly prime) factors of an integer from file f whose name is given as a character string, in the following format.
void decompToFactorsInv (DecompType decomp, const char *file)
 Makes a decomposition of the current integer according to the selected value of decomp.
void addFactor (const Int &p, int64_t mult=1, PrimeType status=UNKNOWN)
 Adds the factor p with multiplicity mult and prime status status to this object.
void makeUnique ()
 Replaces repeated equal factors in the factor list of this object by one factor with its multiplicity, and sorts the factors in increasing order.
void factorize ()
 Tries to find all the prime factors of this integer and stores all the factors in increasing order in a private list.
void calcInvFactors ()
 Given the list of prime factors \(p\) of the integer \(x\) in this object, this function computes the internal list of the inverse factors \(x/p\), sorted in increasing order.
void factorizePlus ()
 Same as calling factorize and calcInvFactors in a single function call.
bool checkProduct () const
 Checks that the integer in this object is equal to the product of its factors.
Int getNumber () const
 Returns the main integer in this object.
const std::list< IntFactor< Int > > & getFactorList () const
 Returns the list of factors.
const std::vector< Int > & getInvFactorList () const
 Returns the list of the inverse factors, assuming that they have been computed.
void setNumber (const Int &x)
 Sets to \(x\) the value of the integer to be factored.
PrimeType getStatus () const
 Returns the status of this number.
void setStatus (PrimeType status)
 Sets the status of this number to status.
std::string toString () const
 Returns the list of (possibly prime) factors of this object as a string in the same format as described in method read above.

Detailed Description

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

Represents the factorization of an arbitrary positive integer, usually into prime factors, but not always.

The factors are IntFactor objects. There are also functions to sort and print the list of factors. The factorization is performed by the yafu executable program, which must be installed in a directory that belongs to the PATH for the function to work. This program is in latmrg/data/yafu in the git distribution.

Recall that for 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 factor with multiplicity \(\nu_i\) and the factors are sorted in increasing order. For 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

Constructs a factorization for the integer \(x\).

◆ IntFactorization() [2/3]

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

Constructs a factorization object by reading the factorization from file fname using the read function defined below.

If no file name is given, the integer 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

◆ operator=()

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

Assignment operator.

◆ clear()

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

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

◆ read()

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

Reads a factorization by reading the list of (possibly prime) factors of an integer from file f whose name is given as a character string, in the following format.

The first line contains the integer 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, for the number \(x = 120 = 2^3*3*5\), the file should contain

120
2 1 P
3 2 P
5 1 P

◆ decompToFactorsInv()

template<typename Int>
void LatMRG::IntFactorization< Int >::decompToFactorsInv ( DecompType decomp,
const char * file )

Makes a decomposition of the current integer according to the selected value of decomp.

The type DecompType is defined in EnumTypes.. Unless this value is NO_DECOMP, the prime factors as well as the inverse factors are put in the fact object. The string filename is the name of the file where the factors are read or written when decomp is DECOMP_WRITE or DECOMP_READ. This file must be accessible by the program.

◆ addFactor()

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

Adds the factor p with multiplicity mult and prime status status to this object.

◆ makeUnique()

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

Replaces repeated equal factors in the factor list of this object by one factor with its multiplicity, and sorts the factors in increasing order.

◆ factorize()

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

Tries to find all the prime factors of this integer and stores all the factors in increasing order in a private list.

Then calls makeUnique. If the number is prime, there is a single factor in the list. This function works only if Yafu is installed.

◆ calcInvFactors()

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

Given the list of prime factors \(p\) of the integer \(x\) in this object, this function computes the internal list of the inverse factors \(x/p\), sorted in increasing order.

For example, if \(x = 24\), the prime factorization is \(24 = 2^3 \cdot 3\) and the list on inverse factors is \([24/3, 24/2] = [8, 12]\).

◆ factorizePlus()

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

Same as calling factorize and calcInvFactors in a single function call.

◆ checkProduct()

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

Checks that the integer in this object is equal to the product of its factors.

Returns true if it is, otherwise false.

◆ getNumber()

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

Returns the main integer in this object.

◆ getFactorList()

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

Returns the list of factors.

◆ getInvFactorList()

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

Returns the list of the inverse factors, assuming that they have been computed.

◆ setNumber()

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

Sets to \(x\) the value of the integer to be factored.

◆ getStatus()

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

Returns the status of this number.

◆ setStatus()

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

Sets the status of this number to status.

◆ toString()

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

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


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