Skip to main content

add

Function add 

Source
pub(crate) fn add<U: Limbs>(
    a1: U,
    b1: (Choice, U),
    a2: U,
    b2: (Choice, U),
    c2: U::Wide,
) -> (U::Wide, (Choice, U::Wide))
Expand description

Compose two positive definite binary quadratic forms.

This requires boths form be well-defined, primitive, and with the same negative discriminant. Neither form is explicitly bound to be reduced however.

This function assumes:

  • floor(log_2(a1)) + 1 < AsRef::<[Limb]>::as_ref(&a1).len() * Limb::BITS
  • floor(log_2(a2)) + 1 < AsRef::<[Limb]>::as_ref(&a2).len() * Limb::BITS
  • AsRef::<[Limb]>::as_ref(&a1).len() == AsRef::<[Limb]>::as_ref(&a2).len()
  • AsRef::<[Limb]>::as_ref(&a1).len() == AsRef::<[Limb]>::as_ref(&b2.1).len()
  • AsRef::<[Limb]>::as_ref(&b1.1).len() == AsRef::<[Limb]>::as_ref(&b2.1).len()

This returns the unreduced a', b' coefficients of the resulting form, with the following bounds:

  • $a’ < 2^(floor(log_2(a1 * a2)) + 1)$
  • $b’ < 2^(1 + max(floor(log_2(|b2|)), floor(log_2(2 * a1 * a2))) + 1)$