|
|
Power 6/32 Unix version 1.21
/*
* "@(#)z_sqrt.c 1.1"
*/
#include "complex"
/* THIS IS BASED ON THE TAHOE FP REPRESENTATION */
#include <FP.h>
z_sqrt(r, z)
dcomplex *r, *z;
{
double mag, sqrt(), zabs();
if( (mag = zabs(z->dreal, z->dimag)) == 0.)
r->dreal = r->dimag = 0.;
else if(z->dreal > 0)
{
r->dreal = sqrt(0.5 * (mag + z->dreal) );
r->dimag = z->dimag / r->dreal / 2;
}
else
{
r->dimag = sqrt(0.5 * (mag - z->dreal) );
if(z->dimag < 0)
*((long int *)&r->dimag) ^= SIGN_BIT;
r->dreal = z->dimag / r->dimag / 2;
}
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.