NAG FL Interface
a02acf (divide)

1 Purpose

a02acf divides one complex number, x=xr,xi, by a second complex number, y=yr,yi, returning the result in z=zr,zi.

2 Specification

Fortran Interface
Subroutine a02acf ( xr, xi, yr, yi, zr, zi)
Real (Kind=nag_wp), Intent (In) :: xr, xi, yr, yi
Real (Kind=nag_wp), Intent (Out) :: zr, zi
C Header Interface
#include <nag.h>
void  a02acf_ (const double *xr, const double *xi, const double *yr, const double *yi, double *zr, double *zi)
The routine may be called by the names a02acf or nagf_complex_divide.

3 Description

The result z is calculated using Smith's algorithm with scaling, from Li et al. (2002), which ensures that no unnecessary overflow or underflow occurs at intermediate stages of the computation.

4 References

Li X S, Demmel J W, Bailey D H, Henry G, Hida Y, Iskandar J, Kahan W, Kapur A, Martin M C, Tung T and Yoo D J (2002) Design, implementation and testing of extended and mixed precision BLAS ACM Trans. Math. Soft. 28(2) 152–205

5 Arguments

1: xr Real (Kind=nag_wp) Input
2: xi Real (Kind=nag_wp) Input
On entry: xr and xi, the real and imaginary parts of x, respectively.
3: yr Real (Kind=nag_wp) Input
4: yi Real (Kind=nag_wp) Input
On entry: yr and yi, the real and imaginary parts of y, respectively.
5: zr Real (Kind=nag_wp) Output
6: zi Real (Kind=nag_wp) Output
On exit: zr and zi, the real and imaginary parts of z, respectively.

6 Error Indicators and Warnings

None.

7 Accuracy

The result should be correct to machine precision.

8 Parallelism and Performance

a02acf is not threaded in any implementation.

9 Further Comments

The time taken by a02acf is negligible.
This routine must not be called with yr=0.0 and yi=0.0.

10 Example

This example finds the value of -1.7+2.6i/-3.1-0.9i.

10.1 Program Text

Program Text (a02acfe.f90)

10.2 Program Data

Program Data (a02acfe.d)

10.3 Program Results

Program Results (a02acfe.r)