|
noexcept |
Performs fused multiplication of two arbitrary-precision integers and a subtraction of the product from another arbitrary-precision integer in place. All integers are specified with vectors of bytes in the Little-Endian order.
[in,out] | pResult | A pointer to a buffer which contains an integer whose value is decreased by the product of the values pointed to by pX and pY . |
cbResult | A byte size of the subtrahend and of the result. Fused multiplication and subtraction is performed by the function modulo bcbResult , where b = 2CHAR_BIT is a number of values that one byte can represent. | |
[in] | pX | A pointer to the first integral multiplicand. |
cbX | A byte size of the multiplicand pointed to by pX . | |
[in] | pY | A pointer to the second integer multiplicand. |
cbY | A byte size of the multiplicand pointed to by cbY . |
The function considers the vectors pointed to by pResult
, pX
and pY
to hold bytes of the integers in the Little-Endian byte order. That is, assuming that nx = cbX - 1
, ny = cbY - 1
and nR = cbResult - 1
, the respective vectors are \(V_R = \{r_0,\dots,r_{n_R}\}\), \(V_X = \{x_0,\dots, x_{n_x}\}\) and \(V_Y = \{y_0,\dots, y_{n_y}\}\), where the bytes \(r_0\), \(x_0\) and \(y_0\) are the first elements within the respective vectors, the function produces the result \(R \gets (R - X \cdot Y)\bmod b^{n_R + 1}\), where on input \(R = \sum_{i=0}^{n_R} r_i\cdot b^i\), \(X = \sum_{i=0}^{n_x} x_i\cdot b^i\), and \(Y = \sum_{i=0}^{n_y} y_i\cdot b^i\) with respect to the Little-Endian order. The result is then written to the buffer pointed to by pResult
.
That is, the multiplicands pointed to by pX
and pY
are firstly zero-extended or contracted in order to produce the \(n_R\)-byte integers \(X' = \sum_{i=0}^{n_R}x'_i\cdot b^i\), where \(x'_i = x_i\), if \(0\le i \le n_x\), and \(x'_i = 0\) otherwise, and \(Y' = \sum_{i=0}^{n_R}y'_i\cdot b^i\), where \(y'_i = y_i\), if \(0\le i\le n_y\), and \(y'_i = 0\) otherwise. Secondly, the integers \(X'\) and \(Y'\) are multiplied modulo \(n_R\). Lastly, the product is subtracted from the integer pointed to by pResult
in place of the latter, again modulo \(n_R\).
The buffers pointed to by pResult
, pX
and pY
must not overlap.
The memfmsub_BE function performs the operation over Big-Endian integers.