
\begin{lidia_man}
\markright{\BF{lattice\_basis}}

\NAME
\BF{lattice\_basis}  \DOTFILL    lattice basis reduction

\ABSTRACT
\BF{lattice\_basis} is the interface class for the classes \BF{bigint\_lattice\_basis}
and \BF{bigfloat\_lattice\_basis}. The class is supported only to
guarantee the compatibility to previous versions of \LiDIA\ and might not be available in future
versions. We recommend to use the classes \BF{bigfloat\_lattice\_basis}
and \BF{bigint\_lattice\_basis} instead. The class \BF{lattice\_basis} is derived from 
\BF{lattice\_gensys} and therefore inherits all their functions. Let
\latex{
\[A=(a_0, \LDOTS, a_{k-1})=(a_{ij})_{0\LE i< n, 0\LE j< k}\IN M^{n \TIMES k} \mbox{ }(n,k \IN \N)\]
}
\html{
\MATH{A=(a_0, \LDOTS, a_{k-1})=(a_{ij})_{0\LE i< n, 0\LE j< k}\IN M^{n \TIMES k} \mbox{ }(n,k \IN \N)}
}
be a basis of the lattice \MATH{L = \Z a_0 \XOR \dots \XOR \Z a_{k-1}} where \MATH{M} 
consists of elements of type \BF{bigfloat} or \BF{bigint}.
The class can be used to solve the problem of computing an LLL reduced basis \cite{LAK}
of \MATH{L}. 

\DESCRIPTION
In the present version of \LiDIA\ the Schnorr-Euchner variation \cite{SEN}
of the original LLL algorithm \cite{LAK} is implemented.

\CONS

For the following constructors the variable \MATH{A} is assumed to represent a lattice.
If in the following constructors \MATH{n\LT 1}, \MATH{k\LT 1}, \MATH{n < k}, \MATH{A=NULL} or the dimension of \MATH{A}
does not correspond to the input parameters which declare the dimension,
the \TT{lidia\_error\_handler} will be invoked. (In order to compute a reduced
basis for a lattice with \MATH{n < k} you will have to use the class 
\BF{lattice\_gensys}.)


\fcode{ct}{lattice\_basis}{lidia\_size\_t n\k lidia\_size\_t k}
{
constructs a \BF{lattice\_basis} of rank \MATH{k} embedded in an
\MATH{n}-dimensional vectorspace initialized with zero.}

\fcode{ct}{lattice\_basis}{const lattice\_basis \& A}
{
constructs a copy of \MATH{A}.}

\fcode{ct}{lattice\_basis}{lidia\_size\_t n\k lidia\_size\_t k\k bigint** \& A}
{
constructs an \MATH{n\TIMES k}-\BF{lattice\_basis} initialized with the
values of the 2-dimensional array \MATH{A} where *\MATH{A} is a row vector.}

\fcode{ct}{lattice\_basis}{lidia\_size\_t n\k lidia\_size\_t k\k bigfloat** \& A}
{
constructs an \MATH{n\TIMES k}-\BF{lattice\_basis} initialized with the
values of the 2-dimensional array \MATH{A} where *\MATH{A} is a row vector.}

\fcode{ct}{lattice\_basis}{const math\_matrix< bigint >\& A}
{
constructs a \BF{lattice\_basis} initialized with the values of \MATH{A}.}

\fcode{ct}{lattice\_basis}{const math\_matrix< bigfloat >\& A}
{
constructs a \BF{lattice\_basis} initialized with the values of \MATH{A}.}

\fcode{dt}{\SIM lattice\_basis}{}{}


\BASIC

Let \MATH{A} be of type \BF{lattice\_basis}.

\fcode{void}{A.extract\_basis}{const lattice\_gensys \& B\k lidia\_size\_t \& r}
{
before this function can be used for extracting a basis it is necessary to first apply the function
\TT{B.compute\_basis(C,T)} supported by the class \BF{lattice\_gensys} for computing a basis 
of the lattice. \MATH{r} is the rank of the basis.}

\fcode{long}{A.gram\_schmidt\_orth}{lattice\_basis \& M\k lattice\_basis \& B}
{
computes the Gram-Schmidt basis \MATH{B} corresponding to \MATH{A} and the coefficient matrix
\MATH{M} as described in \cite{LAK}.}

\fcode{void}{A.lll}{}{}

\fcode{lattice\_basis}{lll}{const lattice\_basis \& A}
{
reduces the lattice \MATH{A} by using the Schnorr-Euchner variation \cite{SEN} of the LLL algorithm.}


\fcode{void}{A.lll}{const lattice\_basis \& B}
{
assigns \MATH{B} to \MATH{A} and performs \TT{A.lll()}.}


\fcode{void}{lll}{math\_matrix< bigint > \& A\k const math\_matrix< bigint > \& B}
{
The input \MATH{B} is converted to a temporary \BF{lattice\_basis}
\MATH{C}. Then \TT{C.lll()} is computed and the result is assigned to \MATH{A}.}


\fcode{void}{lll}{math\_matrix< bigfloat > \& A\k const math\_matrix< bigfloat > \& B}
{
The input \MATH{B} is converted to a temporary \BF{lattice\_basis}
\MATH{C}. Then \TT{C.lll()} is computed and the result is assigned to \MATH{A}.}


\fcode{double}{A.lll\_check\_search}{}
{
if \MATH{A} is LLL reduced, this function will return the largest
\MATH{y\IN ]\FRAC{1}{2},1]} for which \MATH{A} is still LLL reduced, see
\cite{LAK}. If \MATH{A} is not LLL reduced, 0 will be returned.}


\fcode{void}{A.lll\_check\_search}{sdigit \& p\k sdigit \& q}
{
if \MATH{A} is LLL reduced, this function will return the largest
\MATH{\FRAC{p}{q}\IN ]\FRAC{1}{2},1]} for which \MATH{A} is still LLL reduced, see
\cite{LAK}. If \MATH{A} is not LLL reduced, 0 will be returned.}


\fcode{bool}{A.lll\_check}{double y}
{
returns \TRUE , if the basis is reduced for the reduction parameter \MATH{y}, 
\FALSE\ otherwise.}


\fcode{bool}{A.lll\_check}{sdigit p\k sdigit q}
{
returns \TRUE , if the basis is reduced for the reduction parameter 
\MATH{\FRAC{p}{q}}, \FALSE\ otherwise.}


\fcode{void}{A.lll\_trans}{lattice\_basis \& T}{}

\fcode{lattice\_basis}{lll\_trans}{const lattice\_basis \& A, lattice\_basis \& T}
{
reduces the lattice and computes the corresponding unimodular matrix \MATH{T} 
by using the Schnorr-Euchner variation \cite{SEN} of the LLL algorithm.}


\fcode{void}{lll\_trans}{math\_matrix< bigint > \& T\k math\_matrix< bigint > \& A}
{
The input \MATH{A} is converted to a temporary \BF{lattice\_basis}
\MATH{C}. Then \TT{C.lll\_trans(S)} is computed and \MATH{S} is
assigned to \MATH{T} and the result \MATH{C} is assigned to \MATH{A}.}


\fcode{void}{lll\_trans}{math\_matrix< bigfloat > \& T\k math\_matrix< bigfloat > \& A}
{
The input \MATH{A} is converted to a temporary \BF{lattice\_basis}
\MATH{C}. Then \TT{C.lll\_trans(S)} is computed and \MATH{S} is
assigned to \MATH{T} and the result \MATH{C} is assigned to \MATH{A}.}


\fcode{void}{lll\_trans}{math\_matrix< bigint > \& T\k math\_matrix< bigfloat > \& A}
{
The input \MATH{A} is converted to a temporary \BF{lattice\_basis}
\MATH{C}. Then \TT{C.lll\_trans(S)} is computed and \MATH{S} is
assigned to \MATH{T} and the result \MATH{C} is assigned to \MATH{A}.}


\fcode{void}{A.make\_basis}{const lattice\_gensys \& G\k lidia\_size\_t r}
{
tests whether \MATH{G} is a basis. If so, the function only copies \MATH{G} 
to \MATH{A},
otherwise it first executes \TT{G.lin\_gen\_system(T, r)},
then \TT{G1.compute\_basis(G, T)}, and finally assigns \MATH{A}
the computed basis \MATH{C} as described in 
\TT{lattice\_gensys:\-:compute\_basis(G, T)}.}

\SEEALSO
\BF{lattice\_gensys}, \BF{bigint\_lattice\_basis}, \BF{bigfloat\_lattice\_basis},
\BF{bigint\_lattice\_gensys}, \BF{bigfloat\_lattice\_gensys}

\EXAMPLES
\vspace{-0.8cm}

  \begin{verbatim}
 #include <LiDIA/lattice_basis.h>  // using class lattice_basis
 int main()
 { 
   sdigit mode;
   lattice_basis A(1, 1);
   cout << "\n please enter the matrix:";  
   cout << "\n (format described in the manual) \n";
   cin >> A;
   cout << "\n do you want to change the computing mode?";
   cout << "\n 16(bigint) or 256(bigfloat) (see manual):" 
        << A.get_computing_mode();
   cout << "\n enter number:";
   cin >> mode;
   A.set_computing_mode(mode);
   A.lll();
   cout << "\n time needed for the reduction:" 
        << (A.get_computing_time()).user_time() << " ms \n"; 
   cout << "\n reduced matrix :  \n \n" << A << "\n";   
   return (0);
 }

  \end{verbatim}
\vspace{-0.8cm}
\AUTHOR
Werner Backes, Thorsten Lauer, Oliver van Sprang, Susanne Wetzel \\
(code fragments written by Jutta Bartholomes)
\end{lidia_man}
