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 00036 #if !defined(_TIFA_CFRAC_H_) 00037 00041 #define _TIFA_CFRAC_H_ 00042 00043 #ifdef __cplusplus 00044 extern "C" { 00045 #endif 00046 00047 #include <stdbool.h> 00048 #include <gmp.h> 00049 00050 #include "first_primes.h" 00051 #include "array.h" 00052 #include "lindep.h" 00053 #include "smooth_filter.h" 00054 #include "factoring_machine.h" 00055 #include "exit_codes.h" 00056 00062 #define CFRAC_DFLT_NPRIMES_IN_BASE (NFIRST_PRIMES/16) 00063 00068 #define CFRAC_DFLT_NPRIMES_TDIV (NFIRST_PRIMES/16) 00069 00074 #define CFRAC_DFLT_NRELATIONS 32 00075 00079 #define CFRAC_DFLT_LINALG_METHOD SMART_GAUSS_ELIM 00080 00084 #define CFRAC_DFLT_USE_LARGE_PRIMES true 00085 00093 struct struct_cfrac_params_t { 00098 uint32_t nprimes_in_base; 00105 uint32_t nprimes_tdiv; 00109 uint32_t nrelations; 00113 linalg_method_t linalg_method; 00118 bool use_large_primes; 00122 smooth_filter_method_t filter_method; 00131 unsigned short int nsteps_early_abort; 00132 }; 00133 00138 typedef struct struct_cfrac_params_t cfrac_params_t; 00139 00154 void set_cfrac_params_to_default(const mpz_t n, cfrac_params_t* const params); 00155 00188 ecode_t cfrac( 00189 mpz_array_t* const factors, 00190 uint32_array_t* const multis, 00191 const mpz_t n, 00192 const cfrac_params_t* const params, 00193 const factoring_mode_t mode 00194 ); 00195 00196 #ifdef __cplusplus 00197 } 00198 #endif 00199 00200 #endif