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 00064 #if !defined(_TIFA_APPROX_H_) 00065 #define _TIFA_APPROX_H_ 00066 00067 #include <stdint.h> 00068 #include <stdbool.h> 00069 00070 #include "exit_codes.h" 00071 #include "array.h" 00072 00073 #ifdef __cplusplus 00074 extern "C" { 00075 #endif 00076 00081 #define MAX_NPRIMES_IN_TUPLE 3 00082 00090 struct struct_uint32_tuple_t { 00094 uint32_t tuple[MAX_NPRIMES_IN_TUPLE]; 00098 float tlog; 00099 }; 00100 00105 typedef struct struct_uint32_tuple_t uint32_tuple_t; 00106 00116 struct struct_approximer_t { 00120 mpz_t target; 00124 float targetlog; 00129 float dlog_tolerance; 00133 uint32_array_t* facpool; 00137 uint32_t nfactors; 00141 int32_t imin; 00145 int32_t imax; 00149 uint32_t keven; 00153 uint32_t neven; 00157 uint32_t kodd; 00161 uint32_t nodd; 00167 uint32_t nsubsets_odd; 00171 uint32_t* subset_odd; 00176 uint32_t rank; 00181 uint32_tuple_t* tuples; 00185 uint32_t ntuples; 00186 }; 00187 00192 typedef struct struct_approximer_t approximer_t; 00193 00203 approximer_t* alloc_approximer( 00204 mpz_t target, 00205 uint32_array_t* const facpool, 00206 uint32_t nfactors 00207 ); 00208 00220 void free_approximer(approximer_t* aximer); 00221 00230 void random_approximation( 00231 approximer_t* const aximer, 00232 mpz_t approxed, 00233 uint32_t* indexes 00234 ); 00235 00236 #ifdef __cplusplus 00237 } 00238 #endif 00239 00240 #endif