compute_step_real64 Subroutine

private elemental subroutine compute_step_real64(prev_a, prev_g, next_a, next_g)

Compute arithmetic and geometric mean using the given prev_a and prev_g.

Warning

  • This subroutine assumes both inputs are positive.
  • No validation is performed on inputs.

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: prev_a

previous arithmetic mean

real(kind=real64), intent(in) :: prev_g

previous geometric mean

real(kind=real64), intent(out) :: next_a

next arithmetic mean

real(kind=real64), intent(out) :: next_g

next geometric mean


Source Code

    elemental subroutine compute_step_real64(prev_a, prev_g, next_a, next_g)
        !! Compute arithmetic and geometric mean using the given `prev_a` and `prev_g`.  
        !!
        !! @warning
        !! - This subroutine assumes both inputs are positive.
        !! - No validation is performed on inputs.
        !! @endwarning


        real(real64), intent(in) :: prev_a
        !! previous arithmetic mean

        real(real64), intent(in) :: prev_g
        !! previous geometric mean

        real(real64), intent(out) :: next_a
        !! next arithmetic mean

        real(real64), intent(out) :: next_g
        !! next geometric mean



        next_a =     (prev_a + prev_g) * 0.5_real64
        next_g = sqrt(prev_a * prev_g)

    end subroutine compute_step_real64