File:  [Power 6/32 Unix Tahoe 4.2BSD] / cci / usr / src / usr.lib / libF77 / pow_ci.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Sun Jul 28 12:28:02 2019 UTC (7 years ago) by root
Branches: bsd, MAIN
CVS tags: v121, HEAD
Power 6/32 Unix version 1.21

#include "complex"

pow_ci(p, a, b) 	/* p = a**b  */
complex *p, *a;
long int *b;
{
register long int n;
register float t;
complex x;

n = *b;
p->real = 1;
p->imag = 0;

if(n == 0)
	return;
if(n < 0)
	{
	n = -n;
	c_div(&x,p,a);
	}
else
	{
	x.real = a->real;
	x.imag = a->imag;
	}

for( ; ; )
	{
	if(n & 01)
		{
		t = p->real * x.real - p->imag * x.imag;
		p->imag = p->real * x.imag + p->imag * x.real;
		p->real = t;
		}
	if(n >>= 1)
		{
		t = x.real * x.real - x.imag * x.imag;
		x.imag = 2 * x.real * x.imag;
		x.real = t;
		}
	else
		break;
	}
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.