#include <inttypes.h>
#include <gmp.h>
Go to the source code of this file.
Data Structures | |
| struct | struct_cont_frac_state_t |
| An ad-hoc structure for the computation of the continued fraction of a square root. More... | |
Defines | |
| #define | _TIFA_SQRT_CONT_FRAC_H_ |
Typedefs | |
|
typedef struct struct_cont_frac_state_t | cont_frac_state_t |
Equivalent to struct struct_cont_frac_state_t. | |
Functions | |
| void | init_cont_frac_state (cont_frac_state_t *const state, const mpz_t n) |
Initializes a cont_frac_state_t. | |
| void | clear_cont_frac_state (cont_frac_state_t *const state) |
Clears a cont_frac_state_t. | |
| static void | step_cont_frac_state (cont_frac_state_t *const state, uint32_t nsteps) |
| Computes another term of a continued fraction. | |
The expansion is computed via an iterative process, each step giving the value of a new numerator. All the variables needed to perform this computation is stored in an ad-hoc structure called struct_cont_frac_state_t.
Definition in file sqrt_cont_frac.h.
| #define _TIFA_SQRT_CONT_FRAC_H_ |
Standard include guard.
Definition at line 47 of file sqrt_cont_frac.h.
| void clear_cont_frac_state | ( | cont_frac_state_t *const | state | ) |
Clears a cont_frac_state_t.
Clears a cont_frac_state_t.
| [in] | state | A pointer to the cont_frac_state_t to clear. |
| void init_cont_frac_state | ( | cont_frac_state_t *const | state, | |
| const mpz_t | n | |||
| ) |
Initializes a cont_frac_state_t.
Initializes a cont_frac_state_t to begin the computation of a continued fraction. After invocation of this function, the fields of state corresponds to the calculation of the second term of the computed fraction, the first term beeing of course ceil(sqrt(n)).
| [in] | state | A pointer to the cont_frac_state_t to initialize. |
| [in] | n | The non perfect square integer whose square root will be approximated by the computation of a continued fraction. |
| static void step_cont_frac_state | ( | cont_frac_state_t *const | state, | |
| uint32_t | nsteps | |||
| ) | [inline, static] |
Computes another term of a continued fraction.
Computes another coefficient in the expansion of a continued fraction and updates the structure state. The parameter nsteps gives the number of iteration to perform. A new term is computed at each iteration.
state->step_function.| [in] | state | A pointer to the cont_frac_state_t. |
| [in] | nsteps | Number of steps to perfom. |
Definition at line 192 of file sqrt_cont_frac.h.
References struct_cont_frac_state_t::step_function.