1 //==============================================================================================
2 //
3 //	This file is part of LiDIA --- a library for computational number theory
4 //
5 //	Copyright (c) 1994--2001 the LiDIA Group.  All rights reserved.
6 //
7 //	See http://www.informatik.tu-darmstadt.de/TI/LiDIA/
8 //
9 //----------------------------------------------------------------------------------------------
10 //
11 //	$Id$
12 //
13 //	Author	: Werner Backes (WB), Thorsten Lauer (TL)
14 //	Changes	: See CVS log
15 //
16 //==============================================================================================
17 
18 
19 #ifndef HEADBANGER
20 #ifdef HAVE_CONFIG_H
21 # include	"config.h"
22 #endif
23 #include	"LiDIA/lattice_gensys.h"
24 #include	"LiDIA/lattice_basis.h"
25 #endif
26 
27 
28 
29 #ifdef LIDIA_NAMESPACE
30 namespace LiDIA {
31 #endif
32 
33 
34 
35 // MM, The include of gensys is a hack, because the cpp of CC
36 //     on SunOs4.1.4 has a maximum include nesting depth of 12.
37 
38 //
39 // Algorithms
40 //
41 
lll()42 void lattice_basis::lll()
43 {
44 	debug_handler("lattice_basis", "lll()");
45 	CT.start_timer();
46 	if (comp_mode == bigfloat_mode)
47 		lbf->lll_var();
48 	else
49 		lbi->lll();
50 	CT.stop_timer();
51 }
52 
lll(const lattice_basis & B)53 void lattice_basis::lll(const lattice_basis& B)
54 {
55 	debug_handler("lattice_basis", "lll(B)");
56 	assign(B);
57 	CT.start_timer();
58 	if (comp_mode == bigfloat_mode)
59 		lbf->lll_var();
60 	else
61 		lbi->lll();
62 	CT.stop_timer();
63 }
64 
lll_trans(lattice_basis & Tr)65 void lattice_basis::lll_trans(lattice_basis& Tr)
66 {
67 	debug_handler("lattice_basis", "lll_trans(Tr)");
68 	Tr.set_computing_mode(comp_mode);
69 	CT.start_timer();
70 	if (comp_mode == bigfloat_mode)
71 		lbf->lll_trans_var(*Tr.lbf);
72 	else
73 		lbi->lll_trans(*Tr.lbi);
74 	CT.stop_timer();
75 }
76 
77 //
78 // Conversion
79 //
80 
extract_basis(const lattice_gensys & L,lidia_size_t & rank)81 void lattice_basis::extract_basis(const lattice_gensys& L, lidia_size_t& rank)
82 {
83 	debug_handler("lattice_basis", "extract_basis(L, rank)");
84 	set_computing_mode(L.comp_mode);
85 	if (comp_mode == bigint_mode)
86 		lbi->extract_basis(*L.lbi, rank);
87 	else
88 		lbf->extract_basis(*L.lbf, rank);
89 }
90 
make_basis(const lattice_gensys & L,lidia_size_t & rank)91 bool lattice_basis::make_basis(const lattice_gensys& L, lidia_size_t& rank)
92 {
93 	debug_handler("lattice_basis", "make_basis(L, rank)");
94 	set_computing_mode(L.comp_mode);
95 	if (comp_mode == bigint_mode)
96 		return(lbi->make_basis(*L.lbi, rank));
97 	else
98 		return(lbf->make_basis(*L.lbf, rank));
99 }
100 
101 //
102 // lll - checking
103 //
lll_check(double y)104 bool lattice_basis::lll_check(double y)
105 {
106 	debug_handler("lattice_basis", "lll_check(y)");
107 	if (comp_mode == bigint_mode)
108 		return(lbi->lll_check(y));
109 	else
110 		return(lbf->lll_check(y));
111 }
112 
lll_check(sdigit a,sdigit b)113 bool lattice_basis::lll_check(sdigit a, sdigit b)
114 {
115 	debug_handler("lattice_basis", "lll_check(a, b)");
116 	if (comp_mode == bigint_mode)
117 		return(lbi->lll_check(a, b));
118 	else
119 		return(lbf->lll_check(a, b));
120 }
121 
lll_check_search()122 double lattice_basis::lll_check_search()
123 {
124 	debug_handler("lattice_basis", "lll_check_search()");
125 	if (comp_mode == bigint_mode)
126 		return(lbi->lll_check_search());
127 	else
128 		return(lbf->lll_check_search());
129 }
130 
lll_check_search(sdigit & a,sdigit & b)131 void lattice_basis::lll_check_search(sdigit& a, sdigit& b)
132 {
133 	debug_handler("lattice_basis", "lll_check_search(a, b)");
134 	if (comp_mode == bigint_mode)
135 		lbi->lll_check_search(a, b);
136 	else
137 		lbf->lll_check_search(a, b);
138 }
139 
gram_schmidt_orth(lattice_basis & Mue,lattice_basis & Gso)140 void lattice_basis::gram_schmidt_orth(lattice_basis& Mue, lattice_basis& Gso)
141 {
142 	debug_handler("lattice_basis", "gram_schmidt_orth(Mue, Gso)");
143 	Mue.set_computing_mode(bigfloat_mode);
144 	Gso.set_computing_mode(bigfloat_mode);
145 	if (comp_mode == bigint_mode)
146 		lbi->gram_schmidt_orth(*Mue.lbf, *Gso.lbf);
147 	else
148 		lbf->gram_schmidt_orth(*Mue.lbf, *Gso.lbf);
149 }
150 
lll(math_matrix<bigint> & A,const math_matrix<bigint> & B)151 void lll(math_matrix< bigint > & A, const math_matrix< bigint > & B)
152 {
153 	debug_handler("lattice_basis", "friend lll(A, B)");
154 	bigint_lattice_basis temp(B);
155 	temp.lll();
156 	A.assign(temp);
157 }
158 
lll_trans(math_matrix<bigint> & T,math_matrix<bigint> & A)159 void lll_trans(math_matrix< bigint > & T, math_matrix< bigint > & A)
160 {
161 	debug_handler("lattice_basis", "friend lll_trans(T, A)");
162 	bigint_lattice_basis temp(A);
163 	temp.lll_trans(T);
164 	A.assign(temp);
165 }
166 
lll(math_matrix<bigfloat> & A,const math_matrix<bigfloat> & B)167 void lll(math_matrix< bigfloat > & A, const math_matrix< bigfloat > & B)
168 {
169 	debug_handler("lattice_basis", "friend lll(A, B)");
170 	bigfloat_lattice_basis temp(B);
171 	temp.lll_var();
172 	A.assign(temp);
173 }
174 
lll_trans(math_matrix<bigint> & T,math_matrix<bigfloat> & A)175 void lll_trans(math_matrix< bigint > & T, math_matrix< bigfloat > & A)
176 {
177 	debug_handler("lattice_basis", "friend lll_trans(T, A)");
178 	bigfloat_lattice_basis temp(A);
179 	temp.lll_trans_var(T);
180 	A.assign(temp);
181 }
182 
lll_trans(math_matrix<bigfloat> & T,math_matrix<bigfloat> & A)183 void lll_trans(math_matrix< bigfloat > & T, math_matrix< bigfloat > & A)
184 {
185 	debug_handler("lattice_basis", "friend lll_trans(T, A)");
186 	bigfloat_lattice_basis temp(A);
187 	temp.lll_trans_var(T);
188 	A.assign(temp);
189 }
190 
191 
192 
193 #ifdef LIDIA_NAMESPACE
194 }	// end of namespace LiDIA
195 #endif
196