pow_zz.c 549 B

1234567891011121314151617181920212223242526272829
  1. #include "f2c.h"
  2. #ifdef KR_headers
  3. double log(), exp(), cos(), sin(), atan2(), f__cabs();
  4. VOID pow_zz(r,a,b) doublecomplex *r, *a, *b;
  5. #else
  6. #undef abs
  7. #include "math.h"
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. extern double f__cabs(double,double);
  12. void pow_zz(doublecomplex *r, doublecomplex *a, doublecomplex *b)
  13. #endif
  14. {
  15. double logr, logi, x, y;
  16. logr = log( f__cabs(a->r, a->i) );
  17. logi = atan2(a->i, a->r);
  18. x = exp( logr * b->r - logi * b->i );
  19. y = logr * b->i + logi * b->r;
  20. r->r = x * cos(y);
  21. r->i = x * sin(y);
  22. }
  23. #ifdef __cplusplus
  24. }
  25. #endif