Pope and Stein division algorithm subroutines More...
#include "c4e_elements.h"
Go to the source code of this file.
Functions | |
C4eArchUint | c4e_pstdiv_start (C4eElement *C4E_RESTRICT a, C4eElement *C4E_RESTRICT b) |
Start of Pope and Stein division algorithm. | |
C4eArchDigit | c4e_pstdiv_step (C4eArchIdx step, C4E_CONST C4eElement *C4E_RESTRICT a, C4E_CONST C4eElement *C4E_RESTRICT b) |
One step of Pope and Stein division algorithm, determining a (next) quotient digit in . | |
void | c4e_pstdiv_stop (C4eArchUint shift, C4eElement *C4E_RESTRICT a, C4eElement *C4E_RESTRICT b) |
End of Pope and Stein division algorithm. |
Pope and Stein division algorithm subroutines
Definition in file c4e_pstdiv.h.
C4eArchUint c4e_pstdiv_start | ( | C4eElement *C4E_RESTRICT | a, | |
C4eElement *C4E_RESTRICT | b | |||
) |
Start of Pope and Stein division algorithm.
b
is temporary modified in this function, but restored to it's original value in c4e_pstdiv_stop().a
and b
must be normalized. a
must be greater/equal than the size of b
(else a
itself is the remainder). [in,out] | a | Dividend. There must be enough memory space in a->digits to hold a->size + 1 digits. |
[in,out] | b | Divisor. |
C4eArchDigit c4e_pstdiv_step | ( | C4eArchIdx | step, | |
C4E_CONST C4eElement *C4E_RESTRICT | a, | |||
C4E_CONST C4eElement *C4E_RESTRICT | b | |||
) |
One step of Pope and Stein division algorithm, determining a (next) quotient digit in .
a
can be declared as C4E_CONST because the structure it points to isn't modified. Instead only the digits in a->digits
[] will change (and the double indirection prevents any const inheritance, at least when using "C").[in] | step | Iteration step, from a->size - b->size (as size values were before the call to c4e_pstdiv_start()) down to 0. step corresponds to an offset in a->digits from which is subtracted. |
[in,out] | a | Dividend digits as input, next remainder as output. |
[in] | b | Divisor. |
a
vanishes. For an typical division application it is the next digit, to be stored at position step
of digit vector q
[].void c4e_pstdiv_stop | ( | C4eArchUint | shift, | |
C4eElement *C4E_RESTRICT | a, | |||
C4eElement *C4E_RESTRICT | b | |||
) |
End of Pope and Stein division algorithm.
[in] | shift | Algorithm specific number, returned from c4e_pstdiv_start() |
[in,out] | a | Dividend |
[in,out] | b | Divisor |