Compute the complex quotient of two complex numbers.
Complex division, (CR,CI) = (AR,AI)/(BR,BI)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp) | :: | Ar | ||||
real(kind=wp) | :: | Ai | ||||
real(kind=wp) | :: | Br | ||||
real(kind=wp) | :: | Bi | ||||
real(kind=wp) | :: | Cr | ||||
real(kind=wp) | :: | Ci |
subroutine cdiv(Ar, Ai, Br, Bi, Cr, Ci) implicit none real(wp) :: Ar, Ai, Br, Bi, 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