lattice_gensys class for computing relations (and bases)
The class lattice_gensys
can be used to solve the following problems:
Let
be a generating system
of a lattice L, where M consists of elements of type double, bigfloat
or bigint .
Find a relation, i.e.,
such that
and find a basis of the lattice L.
For details see [9].
Let A be of class lattice_gensys . To solve the problem of finding relations
and/or a basis of the lattice L which is represented by A the method of [9] is used.
This method computes the rank r
of L
and a matrix
such that
where B is a basis of L. The first k-r
columns of
T
are relations of the above mentioned type.
Constructors/Destructor
For the following constructors the variable A is assumed to represent a lattice.
If in the following constructors ,
, A=NULL or the dimension of A
does not correspond
to the input parameters which declare the dimension, the error_handler
will be
invoked.
lattice_gensys(long n, long k)
constructs a lattice_gensys
of k vectors embedded in an
n-dimensional vectorspace initialized with zero.
lattice_gensys(lattice_gensys & A)
constructs a copy of A.
lattice_gensys(bigint_matrix & A)
constructs a lattice_gensys
initialized with the values of
the bigint_matrix
A.
lattice_gensys(long n, long k, double** & A)
constructs an - lattice_gensys
initialized with the
values of the 2-dimensional array A where *A is a row vector.
lattice_gensys(long n, long k, bigint** & A)
constructs an - lattice_gensys
initialized with the
values of the 2-dimensional array A where *A is a row vector.
lattic_gensys(long n, long k, bigfloat** & A)
constructs an - lattice_gensys
initialized with the
values of the 2-dimensional array A where *A is a row vector.
lattice_gensys()
Initialization
Let A be of type lattice_gensys . 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 significant 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_gensys . These functions test whether all entries of A are of the demanded type.
int A.check_double()
returns 1, if the entries are of type double, 0 otherwise.
int A.check_bigint()
returns 1, if the entries are of type bigint
, 0 otherwise.
Assignments
Let A be of type lattice_gensys .
The operator = is overloaded. For efficiency reasons the following functions are also implemented:
void A.assign(lattice_gensys & B)
A = B.
void A.assign(lattice_basis & B)
A = B.
void A.assign(bigint_matrix & B)
A = B.
Access Functions
Let A be of type lattice_gensys
. 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 columns of the matrix representing lattice_gensys
A.
Each column corresponds to a vector of the generating system of the lattice.
long A.get_no_of_rows()
returns the dimension of the vectors generating lattice_gensys
A.
This corresponds to the number of rows of the matrix representing lattice_gensys
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 lattice
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 lattice
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_no_of_columns() and stores the lattice
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_gensys .
void A.compute_basis(const lattice_gensys & B, const lattice_gensys & T)
uses the Buchmann-Kessler variation [9] of the LLL Algorithm and
computes a transformation matrix T such that
.
The error_handler
will be invoked, if A, B and T do not have appropriate dimension.
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 the paper [9] used in connection
with A.lin_gen_system(T,r)
in order to obtain A.compute_basis(B,T).
long A.get_computing_time()
returns the amount of time used for the reduction by means of 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
as described in A.set_reduction_parameter(y).
void A.get_reduction_parameter(long & p, long & q)
returns
as described in A.set_reduction_parameter(p,q).
void A.lin_gen_system(lattice_gensys & T, long & r)
The error_handler
will be invoked, if A and T do not have appropriate dimension.
void lin_gen_system(bigint_matrix & T, const bigint_matrix & A, long & r)
converts A to a lattice_gensys
C, computes C.lll_gen_sys(S,r) and converts S to T
where r is the rank of the computed basis.
The error_handler
will be invoked, if A and T do not have appropriate dimension.
The last function results of the present inconsistency of the classes bigint_matrix and lattice_gensys .
Input/Output
The istream
operator >>
and the ostream
operator <<
are
overloaded.
Let n, k
be the number of rows and columns of a lattice_gensys
Input and output are of the following format:
lattice_basis
At the moment this class is inconsistent with the class bigint_matrix .
#include <LiDIA/lattice_gensys.h> // using class lattice_gensys long main() { long rows, cols, mode, prec, r; 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_gensys A(rows,cols), T(cols, 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):" << "actual mode is " << A.get_computing_mode(); cout << "\n enter number:"; cin >> mode; A.set_computing_mode(mode); cout << "\n do you want to change the computing precision?"; cout << "\n 0 for default precision (see manual):" << A.get_computing_precision(); cout << "\n enter number:"; cin >> prec; A.set_computing_precision(prec); A.lin_gen_system(T, r); A.compute_basis(A, T); 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