MCPcopy Create free account
hub / github.com/numpy/numpy / BigInt_Multiply2

Function BigInt_Multiply2

numpy/core/src/multiarray/dragon4.c:476–500  ·  view source on GitHub ↗

result = in * 2 */

Source from the content-addressed store, hash-verified

474
475/* result = in * 2 */
476static void
477BigInt_Multiply2(BigInt *result, const BigInt *in)
478{
479 /* shift all the blocks by one */
480 npy_uint32 carry = 0;
481
482 npy_uint32 *resultCur = result->blocks;
483 const npy_uint32 *pLhsCur = in->blocks;
484 const npy_uint32 *pLhsEnd = in->blocks + in->length;
485 for ( ; pLhsCur != pLhsEnd; ++pLhsCur, ++resultCur) {
486 npy_uint32 cur = *pLhsCur;
487 *resultCur = (cur << 1) | carry;
488 carry = cur >> 31;
489 }
490
491 if (carry != 0) {
492 /* grow the array */
493 DEBUG_ASSERT(in->length + 1 <= c_BigInt_MaxBlocks);
494 *resultCur = carry;
495 result->length = in->length + 1;
496 }
497 else {
498 result->length = in->length;
499 }
500}
501
502/* result = result * 2 */
503static void

Callers 1

Dragon4Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected