sqrt algorithm

Marco Bodrato bodrato at mail.dm.unipi.it
Thu Aug 13 19:42:56 UTC 2015


Ciao,

On Thu, August 13, 2015 2:52 pm, Torbjörn Granlund wrote:
> This is my alternative mullo_basecase:

Great code!

May I suggest to save a variable?

void
mpn_mullo_basecase (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n)
{
  mp_limb_t h;

  ASSERT (n > 0);
  h = up[0] * vp[--n];

  if (n != 0)
    {
      mp_limb_t v0;

      v0 = *vp++;
      h += mpn_mul_1 (rp, up, n, v0);
      h += up[n] * v0;
      rp++;

      while (--n != 0)
        {
          v0 = *vp++;
          h += mpn_addmul_1 (rp, up, n, v0);
          h += up[n] * v0;
          rp++;
        }
    }

  rp[0] = h;
}

Regards,
m

-- 
http://bodrato.it/papers/



More information about the gmp-devel mailing list