bd_mul_pow Subroutine

private pure subroutine bd_mul_pow(limb, n_limb, base, power)

Multiply the big integer in place by base**power.

The exponent is consumed in the largest chunks whose power still fits below LIMB_BASE, which is 29 for base two and 12 for base five.

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(inout) :: limb(:)
integer(kind=default_int), intent(inout) :: n_limb
integer(kind=int64), intent(in) :: base
integer(kind=default_int), intent(in) :: power

Calls

proc~~bd_mul_pow~~CallsGraph proc~bd_mul_pow bd_mul_pow proc~bd_mul_small bd_mul_small proc~bd_mul_pow->proc~bd_mul_small

Called by

proc~~bd_mul_pow~~CalledByGraph proc~bd_mul_pow bd_mul_pow proc~expand_exact expand_exact proc~expand_exact->proc~bd_mul_pow proc~to_string_fixed_dp to_string_fixed_dp proc~to_string_fixed_dp->proc~expand_exact proc~to_string_sci_dp to_string_sci_dp proc~to_string_sci_dp->proc~expand_exact interface~to_string_fixed to_string_fixed interface~to_string_fixed->proc~to_string_fixed_dp proc~to_string_fixed_sp to_string_fixed_sp interface~to_string_fixed->proc~to_string_fixed_sp interface~to_string_sci to_string_sci interface~to_string_sci->proc~to_string_sci_dp proc~to_string_sci_sp to_string_sci_sp interface~to_string_sci->proc~to_string_sci_sp proc~to_string_fixed_sp->proc~to_string_fixed_dp proc~to_string_sci_sp->proc~to_string_sci_dp

Variables

Type Visibility Attributes Name Initial
integer(kind=default_int), private :: chunk
integer(kind=int64), private :: factor
integer(kind=default_int), private :: remaining
integer(kind=int64), private :: step

Source Code

   pure subroutine bd_mul_pow(limb, n_limb, base, power)
      !! Multiply the big integer in place by `base**power`.
      !!
      !! The exponent is consumed in the largest chunks whose power still fits
      !! below `LIMB_BASE`, which is 29 for base two and 12 for base five.
      integer(int64), intent(inout) :: limb(:)
      integer(default_int), intent(inout) :: n_limb
      integer(int64), intent(in) :: base
      integer(default_int), intent(in) :: power
      integer(default_int) :: chunk, remaining
      integer(int64) :: step, factor

      chunk = 0_default_int
      step = 1_int64
      do while (step*base < LIMB_BASE)
         step = step*base
         chunk = chunk + 1_default_int
      end do

      remaining = power
      do while (remaining > 0_default_int)
         if (remaining >= chunk) then
            factor = step
            remaining = remaining - chunk
         else
            factor = base**remaining
            remaining = 0_default_int
         end if
         call bd_mul_small(limb, n_limb, factor)
      end do

   end subroutine bd_mul_pow