cdiv Subroutine

private pure subroutine cdiv(ar, ai, br, bi, cr, ci)

Compute the complex quotient of two complex numbers.

Complex division, (CR,CI) = (AR,AI)/(BR,BI)

REVISION HISTORY (YYMMDD)

  • 811101 DATE WRITTEN
  • 891214 Prologue converted to Version 4.0 format. (BAB)
  • 900402 Added TYPE section. (WRB)
  • Jacob Williams, 9/14/2022 : modernized this code

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: ar
real(kind=wp), intent(in) :: ai
real(kind=wp), intent(in) :: br
real(kind=wp), intent(in) :: bi
real(kind=wp), intent(out) :: cr
real(kind=wp), intent(out) :: ci

Called by

proc~~cdiv~~CalledByGraph proc~cdiv polyroots_module::cdiv proc~comqr polyroots_module::comqr proc~comqr->proc~cdiv proc~cpqr79 polyroots_module::cpqr79 proc~cpqr79->proc~comqr

Source Code

pure subroutine cdiv(ar, ai, br, bi, cr, ci)
    implicit none

    real(wp), intent(in) :: ar, ai, br, bi
    real(wp), intent(out) :: cr, ci

    real(wp) :: s, ars, ais, brs, bis

    s = abs(br) + abs(bi)
    ars = ar/s
    ais = ai/s
    brs = br/s
    bis = bi/s
    s = brs**2 + bis**2
    cr = (ars*brs + ais*bis)/s
    ci = (ais*brs - ars*bis)/s

end subroutine cdiv