00001 // Copyright (C) 2011 CNRS - Ecole Polytechnique - INRIA. 00002 // 00003 // This file is part of TIFA. 00004 // 00005 // TIFA is free software; you can redistribute it and/or modify it under the 00006 // terms of the GNU Lesser General Public License as published by the Free 00007 // Software Foundation; either version 2.1 of the License, or (at your option) 00008 // any later version. 00009 // 00010 // TIFA is distributed in the hope that it will be useful, but WITHOUT ANY 00011 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00012 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 00013 // more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with this library; if not, write to the Free Software Foundation, 00017 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00018 00090 #if !defined(_TIFA_SMOOTH_FILTER_H_) 00091 00095 #define _TIFA_SMOOTH_FILTER_H_ 00096 00097 #include <inttypes.h> 00098 #include <array.h> 00099 #include <hashtable.h> 00100 #include <gmp.h> 00101 00102 #ifdef __cplusplus 00103 extern "C" { 00104 #endif 00105 00110 #define MAX_NSTEPS 4 00111 00117 enum smooth_filter_method_enum { 00121 TDIV = 0, 00125 TDIV_EARLY_ABORT, 00130 DJB_BATCH, 00131 }; 00132 00137 typedef struct struct_smooth_filter_t smooth_filter_t; 00138 00143 static const char* const filter_method_to_str[3] = { 00144 "trial division", 00145 "trial division + early abort", 00146 "batch", 00147 }; 00148 00153 typedef enum smooth_filter_method_enum smooth_filter_method_t; 00154 00171 struct struct_smooth_filter_t { 00175 mpz_ptr n; 00179 mpz_ptr kn; 00183 smooth_filter_method_t method; 00190 unsigned short int nsteps; 00194 unsigned long int batch_size; 00198 unsigned long int base_size; 00202 uint32_array_t* complete_base; 00207 uint32_array_t* factor_base[MAX_NSTEPS]; 00216 mpz_array_t* candidate_xi; 00225 mpz_array_t* candidate_yi; 00234 mpz_array_t* candidate_ai; 00244 mpz_array_t* accepted_xi; 00254 mpz_array_t* accepted_yi; 00264 mpz_array_t* accepted_ai; 00278 mpz_array_t* filtered_xi[MAX_NSTEPS]; 00283 mpz_array_t* filtered_yi[MAX_NSTEPS]; 00288 mpz_array_t* filtered_ai[MAX_NSTEPS]; 00293 mpz_array_t* cofactors [MAX_NSTEPS]; 00299 mpz_t bounds[MAX_NSTEPS]; 00304 mpz_t prod_pj[MAX_NSTEPS + 1]; 00309 hashtable_t* htable; 00313 bool use_large_primes; 00318 bool use_siqs_variant; 00319 }; 00320 00357 void complete_filter_init( 00358 smooth_filter_t* const filter, 00359 uint32_array_t* const base 00360 ); 00361 00373 void clear_smooth_filter(smooth_filter_t* const filter); 00374 00387 void filter_new_relations(smooth_filter_t* const filter); 00388 00400 void print_filter_status(smooth_filter_t* const filter); 00401 00402 #ifdef __cplusplus 00403 } 00404 #endif 00405 00406 #endif