#include <stdint.h>
#include <stdbool.h>
#include "exit_codes.h"
#include "array.h"
Go to the source code of this file.
Data Structures | |
struct | struct_uint32_tuple_t |
Defines a tuple of integers together with a sorting key. More... | |
struct | struct_approximer_t |
Structure used to find number approximation. More... | |
Defines | |
#define | _TIFA_APPROX_H_ |
#define | MAX_NPRIMES_IN_TUPLE 3 |
Typedefs | |
typedef struct struct_uint32_tuple_t | uint32_tuple_t |
Equivalent to struct_uint32_tuple_t . | |
Functions | |
approximer_t * | alloc_approximer (mpz_t target, uint32_array_t *const facpool, uint32_t nfactors) |
Allocates and returns a new approximer_t . | |
void | free_approximer (approximer_t *aximer) |
Frees a previously allocated approximer_t . | |
void | random_approximation (approximer_t *const aximer, mpz_t approxed, uint32_t *indexes) |
Generates a "random" approximation. |
approximer_t
and associated functions that can be used to approximate a target value by multiplying a given number of factors from a given base. Each factor is allowed to appear only once in the decomposition of the approximation on the given base.This is used in TIFA's SIQS implementation where we need to find a polynomial coefficient of a given order from the product of some prime numbers.
The strategy used to reach a good approximation is adapted from the Carrier-Wagstaff method.
Definition in file approx.h.
#define MAX_NPRIMES_IN_TUPLE 3 |
approximer_t* alloc_approximer | ( | mpz_t | target, | |
uint32_array_t *const | facpool, | |||
uint32_t | nfactors | |||
) |
Allocates and returns a new approximer_t
.
target | the target number to approximate. | |
facpool | the pool of available factors. | |
nfactors | the number of factors from facpool to use. |
approximer_t
. void free_approximer | ( | approximer_t * | aximer | ) |
Frees a previously allocated approximer_t
.
Frees all memory used by the pointed approximer_t
and then frees the aximer
pointer.
free(aximer)
in client code after a call to free_approximer(aximer)
: it would result in an error.aximer | the approximer_t to free. |
void random_approximation | ( | approximer_t *const | aximer, | |
mpz_t | approxed, | |||
uint32_t * | indexes | |||
) |
Generates a "random" approximation.
[in] | aximer | the approximer_t to use. |
[out] | approxed | the approximation obtained. |
[out] | indexes | the (sorted) indexes of the factors making up the approximation. |