projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
BSD 4_4 release
[unix-history]
/
usr
/
src
/
usr.bin
/
f77
/
libF77
/
pow_ci.c
diff --git
a/usr/src/usr.bin/f77/libF77/pow_ci.c
b/usr/src/usr.bin/f77/libF77/pow_ci.c
index
c4ccfd5
..
dad213e
100644
(file)
--- a/
usr/src/usr.bin/f77/libF77/pow_ci.c
+++ b/
usr/src/usr.bin/f77/libF77/pow_ci.c
@@
-1,24
+1,71
@@
-/*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+/*-
+ * Copyright (c) 1980 The Regents of the University of California.
+ * All rights reserved.
*
*
- * @(#)pow_ci.c 5.1 %G%
+ * This module is believed to contain source code proprietary to AT&T.
+ * Use and redistribution is subject to the Berkeley Software License
+ * Agreement and your Software Agreement with AT&T (Western Electric).
*/
*/
+#ifndef lint
+static char sccsid[] = "@(#)pow_ci.c 5.4 (Berkeley) 4/12/91";
+#endif /* not lint */
+
#include "complex"
#include "complex"
+#ifdef tahoe
+
+#define C_MULEQ(A,B) \
+ t = (A).real * (B).real - (A).imag * (B).imag,\
+ (A).imag = (A).real * (B).imag + (A).imag * (B).real,\
+ (A).real = t /* A *= B */
+
+void
pow_ci(p, a, b) /* p = a**b */
pow_ci(p, a, b) /* p = a**b */
-complex *p, *a;
-
long int
*b;
+
complex *p, *a;
+
long
*b;
{
{
-dcomplex p1, a1;
+ register long n = *b;
+ register float t;
+ complex x;
-a1.dreal = a->real;
-a1.dimag = a->imag;
+ x = *a;
+ p->real = (float)1, p->imag = (float)0;
+ if (!n)
+ return;
+ if (n < 0) {
+ c_div(&x, p, a);
+ n = -n;
+ }
+ while (!(n&1)) {
+ C_MULEQ(x, x);
+ n >>= 1;
+ }
+ for (*p = x; --n > 0; C_MULEQ(*p, x))
+ while (!(n&1)) {
+ C_MULEQ(x, x);
+ n >>= 1;
+ }
+}
+
+#else /* !tahoe */
-
pow_zi(&p1, &a1, b
);
+
extern void pow_zi(
);
-p->real = p1.dreal;
-p->imag = p1.dimag;
+void
+pow_ci(p, a, b) /* p = a**b */
+ complex *p, *a;
+ long *b;
+{
+ dcomplex p1, a1;
+
+ a1.dreal = a->real;
+ a1.dimag = a->imag;
+
+ pow_zi(&p1, &a1, b);
+
+ p->real = p1.dreal;
+ p->imag = p1.dimag;
}
}
+
+#endif /* tahoe */