Lattice Tester Online Documentation 0.1.0-861
Software Package For Testing The Uniformity Of Integral Lattices In The Real Space
Loading...
Searching...
No Matches
LatticeTester::ParamReader< Int, Real > Class Template Reference

Utility class that can be used to read different kind of data from a file. More...

#include <latticetester/ParamReader.h>

Public Member Functions

 ParamReader ()
 Empty constructor.
 
 ParamReader (std::string fileName)
 Constructor.
 
 ~ParamReader ()
 Destructor.
 
void getLines ()
 Reads all the lines from the file and stores them into this object’s buffer.
 
void readString (std::string &field, uint64_t ln, uint64_t pos)
 Reads a string from the pos-th token of the ln-th line into field.
 
void readBool (bool &field, uint64_t ln, uint64_t pos)
 Reads a boolean from the pos-th token of the ln-th line into field.
 
void readChar (char &field, uint64_t ln, uint64_t pos)
 Reads a character from the pos-th token of the ln-th line into field.
 
void readInt (int64_t &field, uint64_t ln, uint64_t pos)
 Reads an integer from the pos-th token of the ln-th line into field.
 
void readLong (std::int64_t &field, uint64_t ln, uint64_t pos)
 Reads a std::int64_t from the pos-th token of the ln-th line into field.
 
void readZZ (NTL::ZZ &field, uint64_t ln, int64_t pos)
 Reads a large integer from the pos-th token of the ln-th line into field.
 
void readDouble (double &field, uint64_t ln, uint64_t pos)
 Reads a double from the pos-th token of the ln-th line into field.
 
void readNumber3 (Int &r, std::int64_t &b, std::int64_t &e, std::int64_t &c, uint64_t ln, uint64_t pos)
 Reads \(b\), \(e\) and \(c\), starting at the pos-th token of the ln-th line and uses them to define \(r\).
 
void readBScal (Int &field, uint64_t ln, int64_t pos)
 Reads a BScal from the pos-th token of the ln-th line into field.
 
void readBMat (IntMat &fields, uint64_t &ln, uint64_t pos, uint64_t numPos, uint64_t numCols)
 Reads a square BMat of size numPos*numPos from the pos-th token of the ln-th line into field.
 
void readBMat (IntMat &fields, uint64_t &ln, uint64_t pos, uint64_t numPos)
 Reads a square BMat of size numPos*numPos from the pos-th token of the ln-th line into field.
 
void readMScal (Int &field, uint64_t ln, uint64_t pos)
 Reads a Int from the pos-th token of the ln-th line into field.
 
void readReal (Real &field, uint64_t ln, uint64_t pos)
 Reads a Real from the pos-th token of the ln-th line into field.
 
void readMVect (IntVec &field, uint64_t &ln, uint64_t pos, uint64_t num, int64_t j)
 Reads num tokens (from the pos-th token of the ln-th line) into field, starting at index \(j\) of field.
 
void readIntVect (int64_t *field, uint64_t ln, uint64_t pos, uint64_t num, int64_t j)
 Reads num tokens (from the pos-th token of the ln-th line) into field, starting at index \(j\) of field.
 
void readDoubleVect (double *field, uint64_t ln, uint64_t pos, uint64_t num, int64_t j)
 Reads num tokens (from the pos-th token of the ln-th line) into field, starting at index \(j\) of field.
 
void readNormType (NormType &field, uint64_t ln, uint64_t pos)
 Reads 2k MScal tokens into vectors B and C, starting at the ln-th line.
 
void readProblemType (ProblemType &field, uint64_t ln, uint64_t pos)
 Reads a problem type from the pos-th token of the ln-th line into field.
 
void readCriterionType (CriterionType &field, uint64_t ln, uint64_t pos)
 Reads a test type from the pos-th token of the ln-th line into field.
 
void readNormaType (NormaType &field, uint64_t ln, uint64_t pos)
 Reads a type of normalization from the pos-th token of the ln-th line into field.
 
void readPrecisionType (PrecisionType &field, uint64_t ln, uint64_t pos)
 Reads a type of precision from the pos-th token of the ln-th line into field.
 
void readReduct (ReductionType &field, uint64_t ln, uint64_t pos)
 Reads a type of ReductionType from the pos-the token of the ln-th line into field.
 
void readOutputType (OutputType &field, uint64_t ln, uint64_t pos)
 Reads an output form from the pos-th token of the ln-th line into field.
 
void read (Config< Int, IntMat > &config)
 Reads the configuration file into config.
 

Static Public Attributes

static const int64_t MAX_WORD_SIZE = 64
 

Protected Member Functions

void getToken (std::string &field, uint64_t ln, uint64_t pos)
 Puts into field the pos-th string token from line ln.
 
void readBasisConfig (Config< Int, IntMat > &config, uint64_t &ln)
 This can be called to read a basis construction configuration from the file starting from ln (without the BASIS line).
 
void readDualConfig (Config< Int, IntMat > &config, uint64_t &ln)
 This can be called to read a dual computation configuration from the file starting from ln (without the DUAL line).
 
void readReductionConfig (Config< Int, IntMat > &config, uint64_t &ln)
 This can be called to read a reduction problem configuration from the file starting from ln (without the REDUCT line).
 
void readShortestConfig (Config< Int, IntMat > &config, uint64_t &ln)
 This can be called to read a shortest vector problem configuration from the file starting from ln (without the SHORTEST line).
 
void readMeritConfig (Config< Int, IntMat > &config, uint64_t &ln)
 This can be called to read a figure of merit computation configuration from the file starting from ln (without the MERIT line).
 

Detailed Description

template<typename Int, typename Real>
class LatticeTester::ParamReader< Int, Real >

Utility class that can be used to read different kind of data from a file.

This class has to be initialized with a fileName to be used. After the object is initialized, it is then necessary to read the entire file with getLines. This will make a vector containing all the lines of the file, removing those with a # at the start. There then are many methods allowing the conversion of string tokens to various data types by specifying a line and a token number. In every line, a token is a string delimited by any of these caracters: (blank), ?, !, ,, \t, and \n. For example, ReadString(string, 2, 3) will put the 4th token (numerotation starts at 0) of the 3rd line in string. The user of this class has to be aware of the format of the file that will be read.

Remarks
This class should have proper error management in the GetToken method because the program curently simply crashes without explanation if this class is misued.

Constructor & Destructor Documentation

◆ ParamReader() [1/2]

template<typename Int , typename Real >
LatticeTester::ParamReader< Int, Real >::ParamReader ( )

Empty constructor.

Allocates space for a word.

◆ ParamReader() [2/2]

template<typename Int , typename Real >
LatticeTester::ParamReader< Int, Real >::ParamReader ( std::string fileName)

Constructor.

Opens the file fileName.

◆ ~ParamReader()

template<typename Int , typename Real >
LatticeTester::ParamReader< Int, Real >::~ParamReader ( )

Destructor.

Member Function Documentation

◆ getLines()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::getLines ( )

Reads all the lines from the file and stores them into this object’s buffer.

Lines whose first non-blank character is a # are considered as comments and discarded. Empty lines are also discarded.

◆ getToken()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::getToken ( std::string & field,
uint64_t ln,
uint64_t pos )
protected

Puts into field the pos-th string token from line ln.

This is intended to be used by other methods the get a specific string token that can then be converted. This method uses tokenize to split the line it has to operate on.

◆ read()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::read ( Config< Int, IntMat > & config)

Reads the configuration file into config.

This reads the file, looking for information in a specific order, to populate config with enough information to exectute a LatticeAnalysis test. The standard format is described in usage_program.

◆ readBasisConfig()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readBasisConfig ( Config< Int, IntMat > & config,
uint64_t & ln )
protected

This can be called to read a basis construction configuration from the file starting from ln (without the BASIS line).

◆ readBMat() [1/2]

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readBMat ( IntMat & fields,
uint64_t & ln,
uint64_t pos,
uint64_t numPos )

Reads a square BMat of size numPos*numPos from the pos-th token of the ln-th line into field.

The lines in the matrix will be read from the subsequent lines in the file, starting from token at the position pos. fields has to be initialized to the right size.

◆ readBMat() [2/2]

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readBMat ( IntMat & fields,
uint64_t & ln,
uint64_t pos,
uint64_t numPos,
uint64_t numCols )

Reads a square BMat of size numPos*numPos from the pos-th token of the ln-th line into field.

The lines in the matrix will be read from the subsequent lines in the file, starting from token at the position pos. fields has to be initialized to the right size.

◆ readBool()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readBool ( bool & field,
uint64_t ln,
uint64_t pos )

Reads a boolean from the pos-th token of the ln-th line into field.

◆ readBScal()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readBScal ( Int & field,
uint64_t ln,
int64_t pos )

Reads a BScal from the pos-th token of the ln-th line into field.

◆ readChar()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readChar ( char & field,
uint64_t ln,
uint64_t pos )

Reads a character from the pos-th token of the ln-th line into field.

◆ readCriterionType()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readCriterionType ( CriterionType & field,
uint64_t ln,
uint64_t pos )

Reads a test type from the pos-th token of the ln-th line into field.

◆ readDouble()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readDouble ( double & field,
uint64_t ln,
uint64_t pos )

Reads a double from the pos-th token of the ln-th line into field.

◆ readDoubleVect()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readDoubleVect ( double * field,
uint64_t ln,
uint64_t pos,
uint64_t num,
int64_t j )

Reads num tokens (from the pos-th token of the ln-th line) into field, starting at index \(j\) of field.

◆ readDualConfig()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readDualConfig ( Config< Int, IntMat > & config,
uint64_t & ln )
protected

This can be called to read a dual computation configuration from the file starting from ln (without the DUAL line).

◆ readInt()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readInt ( int64_t & field,
uint64_t ln,
uint64_t pos )

Reads an integer from the pos-th token of the ln-th line into field.

◆ readIntVect()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readIntVect ( int64_t * field,
uint64_t ln,
uint64_t pos,
uint64_t num,
int64_t j )

Reads num tokens (from the pos-th token of the ln-th line) into field, starting at index \(j\) of field.

◆ readLong()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readLong ( std::int64_t & field,
uint64_t ln,
uint64_t pos )

Reads a std::int64_t from the pos-th token of the ln-th line into field.

◆ readMeritConfig()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readMeritConfig ( Config< Int, IntMat > & config,
uint64_t & ln )
protected

This can be called to read a figure of merit computation configuration from the file starting from ln (without the MERIT line).

◆ readMScal()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readMScal ( Int & field,
uint64_t ln,
uint64_t pos )

Reads a Int from the pos-th token of the ln-th line into field.

◆ readMVect()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readMVect ( IntVec & field,
uint64_t & ln,
uint64_t pos,
uint64_t num,
int64_t j )

Reads num tokens (from the pos-th token of the ln-th line) into field, starting at index \(j\) of field.

◆ readNormaType()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readNormaType ( NormaType & field,
uint64_t ln,
uint64_t pos )

Reads a type of normalization from the pos-th token of the ln-th line into field.

◆ readNormType()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readNormType ( NormType & field,
uint64_t ln,
uint64_t pos )

Reads 2k MScal tokens into vectors B and C, starting at the ln-th line.

These represent a box \([B_i, C_i]\), \(i = 1, 2, …, k\). The \(B_i, C_i\) must be given in the order \(B_1, C_1, B_2, C_2, …, B_k, C_k\), each on a line of its own. Each coefficient may be given in the form described in readNumber3 above. Reads a norm from the pos-th token of the ln-th line into field.

◆ readNumber3()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readNumber3 ( Int & r,
std::int64_t & b,
std::int64_t & e,
std::int64_t & c,
uint64_t ln,
uint64_t pos )

Reads \(b\), \(e\) and \(c\), starting at the pos-th token of the ln-th line and uses them to define \(r\).

The numbers in the data file may be given in one of the two following formats:

\(\bullet\) A single integer giving the value of \(r=b\) directly on a line. In that case, one sets \(e=c=0\).
\(\bullet\) Three integers \(b\), \(e\), \(c\) on the same line, separated by at least one blank. The \(r\) value will be set as \(r=b^e+c\) if \(b>0\), and \(r= -(|b|^e+c)\) if \(b<0\). One must have \(e\ge0\). For example, \((b, e, c) = (2, 5, -1)\) will give \(r=31\), while \((b, e, c) = (-2, 5, -1)\) will give \(r=-31\).

◆ readOutputType()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readOutputType ( OutputType & field,
uint64_t ln,
uint64_t pos )

Reads an output form from the pos-th token of the ln-th line into field.

◆ readPrecisionType()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readPrecisionType ( PrecisionType & field,
uint64_t ln,
uint64_t pos )

Reads a type of precision from the pos-th token of the ln-th line into field.

◆ readProblemType()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readProblemType ( ProblemType & field,
uint64_t ln,
uint64_t pos )

Reads a problem type from the pos-th token of the ln-th line into field.

◆ readReal()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readReal ( Real & field,
uint64_t ln,
uint64_t pos )

Reads a Real from the pos-th token of the ln-th line into field.

◆ readReduct()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readReduct ( ReductionType & field,
uint64_t ln,
uint64_t pos )

Reads a type of ReductionType from the pos-the token of the ln-th line into field.

◆ readReductionConfig()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readReductionConfig ( Config< Int, IntMat > & config,
uint64_t & ln )
protected

This can be called to read a reduction problem configuration from the file starting from ln (without the REDUCT line).

◆ readShortestConfig()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readShortestConfig ( Config< Int, IntMat > & config,
uint64_t & ln )
protected

This can be called to read a shortest vector problem configuration from the file starting from ln (without the SHORTEST line).

◆ readString()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readString ( std::string & field,
uint64_t ln,
uint64_t pos )

Reads a string from the pos-th token of the ln-th line into field.

◆ readZZ()

template<typename Int , typename Real >
void LatticeTester::ParamReader< Int, Real >::readZZ ( NTL::ZZ & field,
uint64_t ln,
int64_t pos )

Reads a large integer from the pos-th token of the ln-th line into field.

Member Data Documentation

◆ MAX_WORD_SIZE

template<typename Int , typename Real >
const int64_t LatticeTester::ParamReader< Int, Real >::MAX_WORD_SIZE = 64
static

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