Missing complex number function Arg(X) #625

Closed
coatless opened this Issue Jan 7, 2017 · 0 comments

Projects

None yet

1 participant

@coatless
Contributor
coatless commented Jan 7, 2017 edited

Complex sugar ops have support for the following R equivalents:

  • Re
  • Im
  • Mod
  • Conj

but no support for the Arg function that determines the angle between the real and complex plane (counter-clockwise).

Given the availability of the cpp port of the fortran atan2 inverse function, the base R imp of Arg is easy to mirror. Two-liner addition to the complex header:

inline double complex__Arg( Rcomplex x ){ return ::atan2(x.i, x.r); }
RCPP_SUGAR_COMPLEX( Arg, double )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment