Lattice Builder Manual
Software Package for Constructing Rank-1 Lattices
LatMRG Namespace Reference

This module describes various useful functions as well as functions interfacing with NTL. More...

Functions

NTL compatibility utilities
long IsOdd (const long &x)
 Returns 1 if \(x\) is odd, and 0 otherwise.
 
Mathematical functions
long power (long p, long i)
 Returns \(p^i\).
 
void power2 (long &z, long i)
 Sets \(z = 2^i\).
 
double mysqrt (double x)
 Returns \(\sqrt{x}\) for \(x\ge 0\), and \(-1\) for \(x < 0\).
 
double SqrRoot (double x)
 Returns \(\sqrt{x}\). More...
 
template<typename T >
double Log2 (const T &x)
 Logarithm of \(x\) in base 2.
 
double Log2 (long x)
 Logarithm of \(x\) in base 2.
 
template<typename T >
long sign (const T &x)
 Returns 1, 0 or \(-1\) depending on whether \(x> 0\), \(x= 0\) or \(x< 0\) respectively. More...
 
Division and remainder

For negative operands, the / and % operators do not give the same results for NTL large integers ZZ and for primitive types int and long.

The negative quotient differs by 1 and the remainder also differs. Thus the following small inline functions for division and remainder.

Note
Richard: Pour certaines fonctions, les résultats sont mis dans les premiers arguments de la fonction pour être compatible avec NTL; pour d'autres, ils sont mis dans les derniers arguments pour être compatible avec notre ancienne version de LatMRG en Modula-2. Plutôt détestable. Je crois qu'il faudra un jour réarranger les arguments des fonctions pour qu'elles suivent toutes la même convention que NTL.
void div (long &a, const long &b, const long &d)
 Integer division: \(a = b/d\).
 
Vectors
template<typename Real >
void CreateVect (Real *&A, int d)
 Allocates memory for the vector \(A\) of dimensions \(d+1\) and initializes its elements to 0.
 
template<typename Real >
void DeleteVect (Real *&A)
 Frees the memory used by the vector \(A\).
 
template<typename Vect >
void CreateVect (Vect &A, int d)
 Creates the vector \(A\) of dimensions \(d+1\) and initializes its elements to 0.
 
template<typename Vect >
void DeleteVect (Vect &A)
 Frees the memory used by the vector \(A\).
 
template<typename Real >
void SetZero (Real *A, int d)
 Sets components \([0..d]\) of \(A\) to 0.
 
template<typename Real >
void SetValue (Real *A, int d, const Real &x)
 Sets all components \([0..d]\) of \(A\) to the value \(x\).
 
void Invert (const MVect &A, MVect &B, int n)
 Transforms the polynomial \(A_0 + A_1x^1 + \cdots + A_nx^n\) into \(x^n - A_1x^{n-1} - \cdots - A_n\). More...
 
template<typename Vect >
void CopyVect (const Vect &A, Vect &B, int n)
 Copies vector \(A\) into vector \(B\) using components \([0..n]\).
 
template<typename Xcal , typename Scal >
void ModifVect (Xcal *A, const Xcal *B, Scal x, int n)
 Adds vector \(B\) multiplied by \(x\) to vector \(A\) using components \([1..n]\), and puts the result in \(A\).
 
Matrices
template<typename Real >
void CreateMatr (Real **&A, int d)
 Allocates memory for the square matrix \(A\) of dimensions \((d+1)\times(d+1)\). More...
 
template<typename Real >
void DeleteMatr (Real **&A, int d)
 Frees the memory used by the \((d+1)\times(d+1)\) matrix \(A\).
 
template<typename Real >
void CreateMatr (Real **&A, int line, int col)
 Allocates memory for the matrix \(A\) of dimensions (line + 1) \(\times\) (col + 1). More...
 
template<typename Real >
void DeleteMatr (Real **&A, int line, int col)
 Frees the memory used by the matrix \(A\).
 
void CreateMatr (MMat &A, int d)
 Creates the square matrix \(A\) of dimensions \((d+1)\times(d+1)\) and initializes its elements to 0.
 
void CreateMatr (MMatP &A, int d)
 As above.
 
void CreateMatr (MMat &A, int line, int col)
 Creates the matrix \(A\) of dimensions (line + 1) \(\times\) (col + 1). More...
 
void CreateMatr (MMatP &A, int line, int col)
 As above.
 
void DeleteMatr (MMat &A)
 Deletes the matrix \(A\).
 
void DeleteMatr (MMatP &A)
 As above.
 
template<typename Matr >
void CopyMatr (const Matr &A, Matr &B, int n)
 Copies matrix \(A\) into matrix \(B\).
 
template<typename Matr >
void CopyMatr (const Matr &A, Matr &B, int line, int col)
 As above.
 
template<typename MatT >
std::string toStr (const MatT &mat, int d1, int d2)
 Transforms mat into a string. More...
 

Variables

const double MAX_LONG_DOUBLE = 9007199254740992.0
 Maximum integer that can be represented exactly as a double: \(2^{53}\).
 

Detailed Description

This module describes various useful functions as well as functions interfacing with NTL.

Function Documentation

template<typename Real >
void LatMRG::CreateMatr ( Real **&  A,
int  d 
)
inline

Allocates memory for the square matrix \(A\) of dimensions \((d+1)\times(d+1)\).

Initializes its elements to 0.

template<typename Real >
void LatMRG::CreateMatr ( Real **&  A,
int  line,
int  col 
)
inline

Allocates memory for the matrix \(A\) of dimensions (line + 1) \(\times\) (col + 1).

Initializes its elements to 0.

void LatMRG::CreateMatr ( MMat &  A,
int  line,
int  col 
)
inline

Creates the matrix \(A\) of dimensions (line + 1) \(\times\) (col + 1).

Initializes its elements to 0.

void LatMRG::Invert ( const MVect &  A,
MVect &  B,
int  n 
)
inline

Transforms the polynomial \(A_0 + A_1x^1 + \cdots + A_nx^n\) into \(x^n - A_1x^{n-1} - \cdots - A_n\).

The result is put in \(B\).

template<typename T >
long LatMRG::sign ( const T &  x)
inline

Returns 1, 0 or \(-1\) depending on whether \(x> 0\), \(x= 0\) or \(x< 0\) respectively.

%

double LatMRG::SqrRoot ( double  x)
inline

Returns \(\sqrt{x}\).

Note
Richard: Cette fonction est-elle encore utilis\'ee?
template<typename MatT >
std::string LatMRG::toStr ( const MatT &  mat,
int  d1,
int  d2 
)

Transforms mat into a string.

Prints the first \(d1\) rows and \(d2\) columns. Indices start at 1. Elements with index 0 are not printed.