MCPcopy Create free account
hub / github.com/Open-GD/OpenGD / long_mul

Function long_mul

Source/external/fast_float.h:2152–2177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2150// grade-school multiplication algorithm
2151template <uint16_t size>
2152FASTFLOAT_CONSTEXPR20
2153bool long_mul(stackvec<size>& x, limb_span y) noexcept {
2154 limb_span xs = limb_span(x.data, x.len());
2155 stackvec<size> z(xs);
2156 limb_span zs = limb_span(z.data, z.len());
2157
2158 if (y.len() != 0) {
2159 limb y0 = y[0];
2160 FASTFLOAT_TRY(small_mul(x, y0));
2161 for (size_t index = 1; index < y.len(); index++) {
2162 limb yi = y[index];
2163 stackvec<size> zi;
2164 if (yi != 0) {
2165 // re-use the same buffer throughout
2166 zi.set_len(0);
2167 FASTFLOAT_TRY(zi.try_extend(zs));
2168 FASTFLOAT_TRY(small_mul(zi, yi));
2169 limb_span zis = limb_span(zi.data, zi.len());
2170 FASTFLOAT_TRY(large_add_from(x, zis, index));
2171 }
2172 }
2173 }
2174
2175 x.normalize();
2176 return true;
2177}
2178
2179// grade-school multiplication algorithm
2180template <uint16_t size>

Callers 1

large_mulFunction · 0.85

Calls 6

small_mulFunction · 0.85
large_add_fromFunction · 0.85
set_lenMethod · 0.80
try_extendMethod · 0.80
lenMethod · 0.45
normalizeMethod · 0.45

Tested by

no test coverage detected