Function mul [src]

rma = a * b rma may alias with a or b. a and b may alias with each other. Asserts the result fits in rma. An upper bound on the number of limbs needed by rma is given by a.limbs.len + b.limbs.len. limbs_buffer is used for temporary storage. The amount required is given by calcMulLimbsBufferLen.

Prototype

pub fn mul(rma: *Mutable, a: Const, b: Const, limbs_buffer: []Limb, allocator: ?Allocator) void

Parameters

rma: *Mutablea: Constb: Constlimbs_buffer: []Limballocator: ?Allocator

Source

pub fn mul(rma: *Mutable, a: Const, b: Const, limbs_buffer: []Limb, allocator: ?Allocator) void { var buf_index: usize = 0; const a_copy = if (rma.limbs.ptr == a.limbs.ptr) blk: { const start = buf_index; @memcpy(limbs_buffer[buf_index..][0..a.limbs.len], a.limbs); buf_index += a.limbs.len; break :blk a.toMutable(limbs_buffer[start..buf_index]).toConst(); } else a; const b_copy = if (rma.limbs.ptr == b.limbs.ptr) blk: { const start = buf_index; @memcpy(limbs_buffer[buf_index..][0..b.limbs.len], b.limbs); buf_index += b.limbs.len; break :blk b.toMutable(limbs_buffer[start..buf_index]).toConst(); } else b; return rma.mulNoAlias(a_copy, b_copy, allocator); }