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_DEFS_H_GUARD_ 21 #define LIDIA_LATTICE_DEFS_H_GUARD_ 22 23 24 #ifndef LIDIA_XDOUBLE_H_GUARD_ 25 # include "LiDIA/xdouble.h" 26 #endif 27 #ifndef LIDIA_BIGINT_H_GUARD_ 28 # include "LiDIA/bigint.h" 29 #endif 30 #ifndef LIDIA_BIGFLOAT_H_GUARD_ 31 # include "LiDIA/bigfloat.h" 32 #endif 33 #ifndef LIDIA_P_VECTOR_H_GUARD_ 34 # include "LiDIA/lattices/p_vector.h" 35 #endif 36 #ifndef LIDIA_BIGINT_MATRIX_H_GUARD_ 37 # include "LiDIA/bigint_matrix.h" 38 #endif 39 #ifndef LIDIA_RANDOM_GENERATOR_H_GUARD_ 40 # include "LiDIA/random_generator.h" 41 #endif 42 43 44 45 #ifdef LIDIA_NAMESPACE 46 namespace LiDIA { 47 # define IN_NAMESPACE_LIDIA 48 #endif 49 50 51 52 class bigint_lattice; 53 class bigfloat_lattice; 54 55 56 57 // 58 // typedef for sortfunction 59 // 60 61 typedef sdigit (*bin_cmp_func)(const bigint*, const bigint*, lidia_size_t); 62 typedef sdigit (*bfl_cmp_func)(const bigfloat*, const bigfloat*, lidia_size_t); 63 64 65 66 // 67 // typedef for scalarproduct 68 // the bigfloat - version is not allowed to change precision 69 // (if it's changed then restore after computation) 70 // 71 typedef void (*scal_dbl)(double&, double*, double*, lidia_size_t); 72 typedef void (*scal_xdbl)(xdouble&, xdouble*, xdouble*, lidia_size_t); 73 typedef void (*scal_bin)(bigint&, bigint*, bigint*, lidia_size_t); 74 typedef void (*scal_bfl)(bigfloat&, bigfloat*, bigfloat*, lidia_size_t); 75 76 typedef struct { 77 scal_dbl dbl; 78 scal_xdbl xdbl; 79 scal_bin bin; 80 scal_bfl bfl; 81 } user_SP; 82 83 // 84 // Information about the algorithms 85 // 86 typedef union { 87 struct { 88 lidia_size_t rank; 89 double y; 90 sdigit y_nom; 91 sdigit y_denom; 92 sdigit reduction_steps; 93 sdigit correction_steps; 94 sdigit swaps; 95 } lll; 96 } lattice_info; 97 98 // 99 // structure definition for internal class use 100 // to simplify parameters for algorithms 101 // 102 typedef struct { 103 double y; 104 sdigit y_nom; 105 sdigit y_denom; 106 bool transpose; 107 bool alg_trans; 108 lidia_size_t rows; 109 lidia_size_t columns; 110 lidia_size_t rank; 111 lidia_size_t real_columns; 112 } base_alg; 113 114 115 typedef struct { 116 sdigit bit_prec; 117 sdigit cut_bit_prec; 118 sdigit bit_factor; 119 sdigit approx_prec; 120 sdigit exact_prec; 121 sdigit old_prec; 122 sdigit read_prec; 123 } info_dgts; 124 125 template< class T > 126 struct dense_struc 127 { 128 T **value; 129 T *delvalue; 130 math_matrix< T > *TMatrix; 131 }; 132 133 // 134 // Parameters for dense lattice algorithms 135 // 136 template< class T > 137 struct dense_alg 138 { 139 dense_struc< T > s; 140 info_dgts d; 141 base_alg b; 142 }; 143 144 // 145 // Parameters for sparse lattice algorithms 146 // 147 struct sparse_alg 148 { 149 base_alg b; 150 }; 151 152 153 // 154 // Vector operations for the needed types using 155 // the new class p_vector. These are put together to 156 // have one template argument instead of three 157 // 158 159 template< class E, class A > 160 struct vector_op 161 { 162 p_vector< A > approx; 163 p_vector< E > exact; 164 }; 165 166 // 167 // See above, using function pointer defined scalarproduct 168 // 169 template< class E, class A > 170 struct vector_op_SP 171 { 172 p_vector_SP< A > approx; 173 p_vector_SP< E > exact; 174 }; 175 176 const sdigit DOUBLE_MANTISSA_BITS = 52; 177 //const sdigit MANTISSA_CUT = bigint::bits_per_digit(); 178 //MM: Replaced this by a define for SunPro 179 #ifndef MANTISSA_CUT 180 #define MANTISSA_CUT bigint::bits_per_digit() 181 #endif 182 183 184 #define ALG_DEF_BASIS(E, Vect, Var) \ 185 struct LIDIA_CONCAT4(E, Vect, basis, Var) { \ 186 lll_kernel_op< E, double, Vect < E, double >, \ 187 basis_modules< E, double, Var > > dbl; \ 188 lll_kernel_op< E, xdouble, Vect < E, xdouble >, \ 189 basis_modules< E, xdouble, Var > > xdbl; \ 190 lll_kernel_fu< E, bigfloat, Vect < E, bigfloat >, \ 191 basis_modules< E, bigfloat, Var > > bfl; \ 192 } 193 194 #define ALG_DEF_GENSYS(E, Vect, Var) \ 195 struct LIDIA_CONCAT4(E, Vect, igensys, Var) { \ 196 lll_kernel_op< E, double, Vect < E, double >, \ 197 gensys_modules< E, double, Var > > dbl; \ 198 lll_kernel_op< E, xdouble, Vect < E, xdouble >, \ 199 gensys_modules< E, xdouble, Var > > xdbl; \ 200 lll_kernel_fu< E, bigfloat, Vect < E, bigfloat >, \ 201 gensys_modules< E, bigfloat, Var > > bfl; \ 202 } 203 204 #define ALG_POINTER(alg, SP, ex) \ 205 { \ 206 alg.dbl.vector_operations().approx.set_pointer(SP.dbl); \ 207 alg.dbl.vector_operations().exact.set_pointer(SP.ex); \ 208 alg.xdbl.vector_operations().approx.set_pointer(SP.xdbl); \ 209 alg.xdbl.vector_operations().exact.set_pointer(SP.ex); \ 210 alg.bfl.vector_operations().approx.set_pointer(SP.bfl); \ 211 alg.bfl.vector_operations().exact.set_pointer(SP.ex); \ 212 } 213 214 #define ALG_CALL(cl, alg, da, li, factor) \ 215 { \ 216 if (factor < 2) \ 217 cl.dbl.alg(da, li); \ 218 else \ 219 { \ 220 if (factor == 2) \ 221 cl.xdbl.alg(da, li); \ 222 else \ 223 cl.bfl.alg(da, li); \ 224 } \ 225 } 226 227 // 228 // Const for structure_info 229 // 230 const sdigit GRAM_MATRIX = 0x80000000; 231 232 // 233 // Const for lattice_info 234 // 235 const sdigit REDUCE_ROWS = 0x80000000; 236 237 // __dummy__ is never referenced and it is an illegal identifier anyway. (see C++ standard 17.4.3.1.2) 238 // static const bigfloat __dummy__ = 0.0; 239 240 241 242 #ifdef LIDIA_NAMESPACE 243 } // end of namespace LiDIA 244 # undef IN_NAMESPACE_LIDIA 245 #endif 246 247 248 249 #endif // LIDIA_LATTICE_DEFS_H_GUARD_ 250