Sync usage with man page.
[netbsd-mini2440.git] / external / bsd / pcc / dist / pcc-libs / libF77 / pow_zi.c
blob396df91befe5b202b91a42f7a89f5db0f11caa14
1 /* $Id: pow_zi.c,v 1.1.1.1 2008/08/24 05:34:46 gmcgarry Exp $ */
2 /*
3 * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
9 * Redistributions of source code and documentation must retain the above
10 * copyright notice, this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditionsand the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed or owned by Caldera
17 * International, Inc.
18 * Neither the name of Caldera International, Inc. nor the names of other
19 * contributors may be used to endorse or promote products derived from
20 * this software without specific prior written permission.
22 * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
23 * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE
27 * FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OFLIABILITY, WHETHER IN CONTRACT,
31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
35 #include "f77lib.h"
37 void
38 pow_zi(dcomplex *p, dcomplex *a, long int *b) /* p = a**b */
40 long int n;
41 double t;
42 dcomplex x;
44 n = *b;
45 p->dreal = 1;
46 p->dimag = 0;
48 if(n == 0)
49 return;
50 if(n < 0) {
51 n = -n;
52 z_div(&x, p, a);
53 } else {
54 x.dreal = a->dreal;
55 x.dimag = a->dimag;
58 for( ; ; ) {
59 if(n & 01) {
60 t = p->dreal * x.dreal - p->dimag * x.dimag;
61 p->dimag = p->dreal * x.dimag + p->dimag * x.dreal;
62 p->dreal = t;
64 if(n >>= 1) {
65 t = x.dreal * x.dreal - x.dimag * x.dimag;
66 x.dimag = 2 * x.dreal * x.dimag;
67 x.dreal = t;
68 } else
69 break;