1 // -*- C++ -*-
2 //==============================================================================================
3 //
4 //	This file is part of LiDIA --- a library for computational number theory
5 //
6 //	Copyright (c) 1994--2001 the LiDIA Group.  All rights reserved.
7 //
8 //	See http://www.informatik.tu-darmstadt.de/TI/LiDIA/
9 //
10 //----------------------------------------------------------------------------------------------
11 //
12 //	$Id$
13 //
14 //	Author	: Werner Backes (WB), Thorsten Lauer (TL)
15 //	Changes	: see CVS log
16 //
17 //==============================================================================================
18 
19 
20 #ifndef LIDIA_LATTICE_MODULES_H_GUARD_
21 #define LIDIA_LATTICE_MODULES_H_GUARD_
22 
23 
24 #ifndef LIDIA_LATTICE_DEFS_H_GUARD_
25 # include	"LiDIA/lattices/lattice_defs.h"
26 #endif
27 #ifndef LIDIA_P_VECTOR_H_GUARD_
28 # include	"LiDIA/lattices/p_vector.h"
29 #endif
30 
31 
32 
33 #ifdef LIDIA_NAMESPACE
34 namespace LiDIA {
35 # define IN_NAMESPACE_LIDIA
36 #endif
37 
38 
39 
40 const int Normal = 0;
41 const int VariationI = 1;
42 const int VariationII = 2;
43 
44 const sdigit Magic_Precision_Factor = 2;
45 
46 
47 
48 //
49 // class prec_modules < E, A >
50 // ~~~~~~~~~~~~~~~~~~~~~~~~
51 //
52 // a class  which cares about needed precision
53 // for both the template type E and the approximate type A
54 //
55 template< class E, class A >
56 class prec_modules
57 {
58 protected :
59 	sdigit tempsdt;
60 public :
prec_modules()61 	prec_modules() { };
~prec_modules()62 	~prec_modules() { };
63 
64 	void prec_startup(dense_alg< E > &);
65 	void prec_update(dense_alg< E > &);
66 	void prec_exact(const dense_alg< E > &);
67 	void prec_approx(const dense_alg< E > &);
68 	void prec_correct(const dense_alg< E > &);
69 	void prec_restore(const dense_alg< E > &);
70 };
71 
72 
73 
74 //
75 // class base_modules < E, A, int >
76 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
77 //
78 // a class  which implements parts of the lll -
79 // algorithm for both basis and gensys
80 //
81 template< class E, class A, const int V >
82 class base_modules : public prec_modules< E, A >
83 {
84 protected :
85 	sdigit   bi_bit_len;
86 	sdigit   bit_diff;
87 	bigint   mant;
88 	sdigit   expo;
89 	bigint   tempbin; // working on mantissa
90 	bigfloat tempbfl;
91 
92 public :
base_modules()93 	base_modules() : prec_modules< E, A > () { };
~base_modules()94 	~base_modules() { };
95 
96 	bool A_convert_value_E_bound(dense_alg< E > &, E&, const A&, const A&);
97 	void E_convert_value_A(dense_alg< E > &, A&, const E&);
98 };
99 
100 
101 
102 //
103 // class basis_modules < E, A, int >
104 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
105 //
106 // a class  which implements specialized modules of the lll -
107 // algorithm for basis lattices
108 //
109 template< class E, class A, const int V >
110 class basis_modules : public base_modules< E, A, V >
111 {
112 protected :
113 	bool is_zero;
114 	void *tempP; // swapping rows
115 
116 public :
basis_modules()117 	basis_modules() : base_modules< E, A, V > () { };
~basis_modules()118 	~basis_modules() { };
119 
120 	bool E_convert_vector_A(dense_alg< E > &, A**, const lidia_size_t);
121 	void E_convert_lattice_A(dense_alg< E > &, A**);
122 };
123 
124 
125 
126 //
127 // class gensys_modules < E, A, int >
128 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
129 //
130 // a class  which implements specialized modules of the lll -
131 // algorithm for gensys lattices
132 //
133 template< class E, class A, const int V >
134 class gensys_modules : public base_modules< E, A, V >
135 {
136 protected :
137 	bool is_zero;
138 	void *tempP; // swapping rows
139 
140 public :
gensys_modules()141 	gensys_modules() : base_modules< E, A, V > () { };
~gensys_modules()142 	~gensys_modules() { };
143 
144 	bool E_convert_vector_A(dense_alg< E > &, A**, const lidia_size_t);
145 	void E_convert_lattice_A(dense_alg< E > &, A**);
146 };
147 
148 
149 
150 #ifdef LIDIA_NAMESPACE
151 }	// end of namespace LiDIA
152 # undef IN_NAMESPACE_LIDIA
153 #endif
154 
155 
156 
157 #include	"LiDIA/lattices/lattice_modules.cc"
158 
159 
160 
161 #endif	// LIDIA_LATTICE_MODULES_H_GUARD_
162