R-beta: (0+0i)^2

U-E59264-Osman F Buyukisik absd00t@c1186.ae.ge.com
Thu, 17 Sep 1998 09:55:31 -0400 (EDT)


I am not a "c" programmer but this is very simple and seems to be
working (just a check for 0): in src/main/complex.c 
...
static void complex_pow(complex *r, complex *a, complex *b)
{
    double logr, logi, x, y, mag;
    if ((mag = hypot(a->r, a->i)) == 0.0) {
        r->r = r->i = 0.0;
    }
    else {
    logr = log(mag );
    logi = atan2(a->i, a->r);
    x = exp( logr * b->r - logi * b->i );
    y = logr * b->i + logi * b->r;
    r->r = x * cos(y);
    r->i = x * sin(y);
    }
}
....
Osman
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._