next up previous contents
Next: bigint_matrix Up: Description of the Previous: lattice_gensys

lattice_basis


lattice_basis class for reducing lattice bases


lattice_basis is the class providing several variations of the original LLL algorithm [28].
Let

be a basis of the lattice where M

consists of elements of type double, bigfloat or bigint . The class can be used to solve the problem of computing an LLL reduced basis of L .


Let A be of class lattice_basis . In the present version of LiDIA the following variations of the LLL algorithm are implemented:

  1. The Schnorr-Euchner variation [37]. A significant speed up is achieved due to computing with a reduced accuracy of the crucial data.

  2. A modification of the original LLL algorithm [28] which neither computes the Gram-Schmidt matrix in advance nor updates the matrix after each reduction step (similarities with the Schorr-Euchner variation [37]).

The decision which method is actually used in order to compute an LLL reduced basis is accomplished by using A.set_computing_mode() as described in the following table. The choice of the mode influences the functions A.lll(), A.lll(B) and A.lll_trans(T).

Constructors/Destructor

For the following constructors the variable A is assumed to represent a lattice. If in the following constructors , , n < k, A=NULL or the dimension of A does not correspond to the input parameters which declare the dimension, the error_handler will be invoked. (In order to compute a reduced basis for a lattice with n < k you will have to use the class lattice_gensys .)

lattice_basis(long n, long k)

constructs a lattice_basis of rank k embedded in an n-dimensional vectorspace initialized with zero.

lattice_basis(const lattice_basis & A)

constructs a copy of A.

lattice_basis(const bigint_matrix & A)

constructs a lattice_basis initialized with the values of the bigint_matrix A.

lattice_basis(long n, long k, double** & A)

constructs an - lattice_basis initialized with the values of the 2-dimensional array A where *A is a row vector.

lattice_basis(long n, long k, bigint** & A)

constructs an - lattice_basis initialized with the values of the 2-dimensional array A where *A is a row vector.

lattic_basis(long n, long k, bigfloat** & A)

constructs an - lattice_basis initialized with the values of the 2-dimensional array A where *A is a row vector.

lattice_basis()

Initialization

Let A be of type lattice_basis . The order of application of the various initializations does not matter but has to be done before other functions can be applied.

void A.set_reduction_parameter(double y)

sets the reduction parameter . If y is not in the range ] ], y is set to the default y=1.
Warning: It is not guaranteed that the LLL algorithm terminates for y=1 .

void A.set_reduction_parameter(long p, long q)

sets the reduction parameter . The default is taken as in A.set_reduction_parameter(double y).

void A.set_computing_precision(long n)

sets the number of decimal digits used in bigfloat_mode. In the other modes this function has no effect. If default precision of bigfloat , n is set to the default precision of bigfloat .

void A.set_computing_mode(long n)

all consequent operations on the matrix A will be done according to mode n:
double_mode (0x00000001) uses the double datatype
bigint_mode (0x00000010) uses the class bigint
bigfloat_mode (0x00000100) uses the class bigfloat
If no mode is set, all computations will be done in the default mode namely bigfloat_mode. The error_handler will be invoked, if a not documented mode is used.
Warning: Precision loss may occur due to truncation.

void A.set_io_mode(long n)

sets the format of the input and output operations to mode n, where n can be one of the following modes:
own_io_mode (0x00000001) see section Input/Output
pari_io_mode (0x00000010) see pari manual
maple_io_mode (0x00000100) see maple manual
mathematica_io_mode (0x00001000) see mathematica manual

The last three modes are intended to provide an interface to other existing computer algebra systems. If no mode is set, own_io_mode will be chosen. The error_handler will be invoked, if a not documented mode is used.

Type Checking

Let A be of type lattice_basis . These functions test whether all entries of A are of the demanded type.

int A.check_double()

returns 1 , if the entries of A are of type double, 0 \ otherwise.

int A.check_bigint()

returns 1 , if the entries of A are of type bigint , 0 \ otherwise.

Assignments

Let A be of type lattice_basis .

The operator = is overloaded. For efficiency reasons, the following functions are also implemented:

void A.assign(lattice_basis & B) A = B.

void A.assign(bigint_matrix & B) A = B.

Access Functions

Let A be of type lattice_basis . If i,j < 0, or in one of the following functions, the error_handler will be invoked.

long A.get_no_of_columns()

returns the number of basis vectors of lattice_basis A. This corresponds to the number of columns of the matrix representing lattice_basis A.

long A.get_no_of_rows()

returns the dimension of the basis vectors. This corresponds to the number of rows of the matrix representing lattice_basis A.

void A.member(long i, long j, double & b) .

void A.member(long i, long j, bigint & b) .

void A.member(long i, long j, bigfloat & b) .

void A.member(long & rows, long & columns, double** & B)

sets rows = A.get_no_of_rows(), columns = A.get_no_of_columns() and stores the entries of the lattice_basis A in the 2-dimensional array B. The amount of memory needed is allocated.

void A.member(long & rows, long & columns, bigint** & B)

sets rows = A.get_no_of_rows(), columns = A.get_no_of_columns() and stores the entries of the lattice_basis A in the 2-dimensional array B. The amount of memory needed is allocated.

void A.member(long & rows, long & columns, bigfloat** & B)

sets rows = A.get_no_of_rows(), columns = A.get_of_of_columns() and stores the entries of the lattice_basis A in the 2-dimensional array B. The amount of memory needed is allocated.

void A.sto(long i, long j, double & b) .

void A.sto(long i, long j, bigint & b) .

void A.sto(long i, long j, bigfloat & b) .

Basic Functions

Let A be of type lattice_basis .

long A.get_computing_mode()

returns current computing mode according to
A.set_computing_mode(mode).

long A.get_computing_precision()

returns the number of decimal digits according to a worst-case-bound derived in [9]. This bound is used in the functions A.lll() and A.lll_trans(T).

long A.get_computing_time()

returns the amount of time used for the reduction using the class timer .

long A.get_read_precision()

returns the maximum number of decimals of the entries in A provided using bigfloat_mode.

double A.get_reduction_parameter()

returns y according to A.set_reduction_parameter(y).

void A.get_reduction_parameter(long & p, long & q)

returns according to A.set_reduction_parameter(p,q).

long A.gram_schmidt_orth(lattice_basis & B)

computes the Gram-Schmidt basis B corresponding to A as described in [28]. The error_handler will be invoked, if A and B do not have appropriate dimension.

void A.lll()

reduces the matrix A using a variation of the LLL algorithm. The variation is chosen according to the above mentioned table.

void A.lll(const lattice_basis & B)

assigns B to A and performs A.lll(). The error_handler will be invoked, if A and B do not have appropriate dimension.

double A.lll_check()

if A is LLL reduced, this function will return the largest for which A is still LLL reduced, see [28]. If A is not LLL reduced, 0 will be returned.

int A.lll_check(double y)

returns 1 , if the basis is reduced for the reduction parameter y, 0 otherwise.

int A.lll_check(long p, long q)

returns 1 , if the basis is reduced for the reduction parameter , 0 otherwise.

void A.lll_trans(lattice_basis & T)

computes an unimodular matrix T such that A T is LLL reduced. A variation of the LLL algorithm is used. The variation is chosen according to the above mentioned table. The error_handler will be invoked, if A and T do not have appropriate dimension.

void A.make_basis(const lattice_gensys & G)

tests whether G is a basis. If so, the function only copies G to A, otherwise it first executes G.lin_gen_system(T, r), then G1.compute_basis(G, T), and finally assigns A the computed basis C as described in lattice_gensys::compute_basis(G, T).

void lll(bigint_matrix & B, const bigint_matrix & A)

The input A is converted to a temporary lattice_basis C. Then C.lll() is computed and the result is assigned to B. The error_handler will be invoked, if A and B do not have appropriate dimension.

void lll_trans(bigint_matrix & T, const bigint_matrix & A)

The input A is converted to a temporary lattice_basis C. Then C.lll_trans(S) is computed and S is assigned to T. The error_handler will be invoked, if A and T do not have appropriate dimension.

The last two functions result of the present inconsistency of the classes bigint_matrix and lattice_basis .

Input/Output

The istream operator >> and the ostream operator << are overloaded.
Let n, k be the number of rows and columns of a lattice_basis

Input and output are of the following format:


lattice_gensys


At the moment this class is inconsistent with the class bigint_matrix .


#include <LiDIA/lattice_basis.h>  // using class lattice_basis
long main()
{ 
  long rows, cols, mode, prec;
  cout << "\n please enter the number of rows for the matrix:";
  cin >> rows;
  cout << "\n please enter the number of columns for the matrix:";
  cin >> cols;
  lattice_basis A(rows,cols);
  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 1(double),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);
}

Werner Backes, Thorsten Lauer, Oliver van Sprang, Susanne Wetzel
(based on a program written by Jutta Bartholomes)

Copyright 1995 by the LiDIA -Group, Universität des Saarlandes



next up previous contents
Next: bigint_matrix Up: Description of the Previous: lattice_gensys



LiDIA Administrator
Thu Aug 10 16:41:08 MET DST 1995