|
noexcept |
Computes fused multiply-add multiplying two arbitrary-precision integers and adding them to a third integer writing the result in place of the latter. All integers are specified by vectors of bytes in the Big-Endian order.
[in,out] | pResult | A pointer to a buffer which on input holds the addend to the product. On output the buffer receives the result of the fused multiply-add. |
cbResult | A byte size of the addend pointed to by pResult , and a byte size of the result of fused multiply-add. The operation is performed 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 Big-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_{n_R - i}\cdot b^i\), \(X = \sum_{i=0}^{n_x} x_{n_x - i}\cdot b^i\), and \(Y = \sum_{i=0}^{n_y} y_{n_y - i}\cdot b^i\) with respect to the Big-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_{n_x - i}\), if \(0\le i \le n_x\), and \(x'_i = 0\) otherwise, and \(Y' = \sum_{i=0}^{n_R}y'_{n_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 added to the integer pointed to by pResult
in place, again modulo \(n_R\).
The buffers pointed to by pResult
, pX
and pY
must not overlap.
The memfmadd_LE function performs the operation over Little-Endian integers.