Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include <math.h>
00039 #include "cmplx.h"
00040 #include "cmplrs/host.h"
00041 #include "moremath.h"
00042
00043
00044
00045
00046
00047
00048 static void my_sincos(double x, double *sinx, double *cosx)
00049 {
00050 *sinx = sin(x);
00051 *cosx = cos(x);
00052 }
00053
00054 dcomplex __powzz(double_t adreal, double_t adimag, double_t bdreal, double_t bdimag)
00055 {
00056 double_t logr, logi, x, y;
00057 double sinx, cosx;
00058 dcomplex r;
00059
00060 logr = log(hypot(adreal,adimag));
00061 logi = atan2(adimag,adreal);
00062
00063 x = exp(logr*bdreal-logi*bdimag);
00064 y = logr*bdimag+logi*bdreal;
00065
00066 my_sincos(y, &sinx, &cosx);
00067 r.dreal = x*cosx;
00068 r.dimag = x*sinx;
00069
00070 return r;
00071
00072
00073 }
00074
00075 void pow_zz(dcomplex *r, dcomplex *a, dcomplex *b)
00076 {
00077 *r = __powzz(a->dreal, a->dimag, b->dreal, b->dimag);
00078 }
00079
00080 void pow_zz_(dcomplex *r, dcomplex *a, dcomplex *b)
00081 {
00082 *r = __powzz(a->dreal, a->dimag, b->dreal, b->dimag);
00083 }
00084
00085 void pow_zz__(dcomplex *r, dcomplex *a, dcomplex *b)
00086 {
00087 *r = __powzz(a->dreal, a->dimag, b->dreal, b->dimag);
00088 }