Print this page
11210 libm should be cstyle(1ONBLD) clean
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/common/complex/csqrtf.c
+++ new/usr/src/lib/libm/common/complex/csqrtf.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 24 */
25 +
25 26 /*
26 27 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 28 * Use is subject to license terms.
28 29 */
29 30
30 31 #pragma weak __csqrtf = csqrtf
31 32
32 -#include "libm.h" /* sqrt/fabsf/sqrtf */
33 +#include "libm.h" /* sqrt/fabsf/sqrtf */
33 34 #include "complex_wrapper.h"
34 35
35 -/* INDENT OFF */
36 36 static const float zero = 0.0F;
37 -/* INDENT ON */
37 +
38 38
39 39 fcomplex
40 -csqrtf(fcomplex z) {
40 +csqrtf(fcomplex z)
41 +{
41 42 fcomplex ans;
42 43 double dt, dx, dy;
43 44 float x, y, t, ax, ay, w;
44 45 int ix, iy, hx, hy;
45 46
46 47 x = F_RE(z);
47 48 y = F_IM(z);
48 49 hx = THE_WORD(x);
49 50 hy = THE_WORD(y);
50 51 ix = hx & 0x7fffffff;
51 52 iy = hy & 0x7fffffff;
52 53 ay = fabsf(y);
53 54 ax = fabsf(x);
55 +
54 56 if (ix >= 0x7f800000 || iy >= 0x7f800000) {
55 57 /* x or y is Inf or NaN */
56 - if (iy == 0x7f800000)
58 + if (iy == 0x7f800000) {
57 59 F_IM(ans) = F_RE(ans) = ay;
58 - else if (ix == 0x7f800000) {
60 + } else if (ix == 0x7f800000) {
59 61 if (hx > 0) {
60 62 F_RE(ans) = ax;
61 63 F_IM(ans) = ay * zero;
62 64 } else {
63 65 F_RE(ans) = ay * zero;
64 66 F_IM(ans) = ax;
65 67 }
66 - } else
68 + } else {
67 69 F_IM(ans) = F_RE(ans) = ax + ay;
70 + }
68 71 } else if (iy == 0) {
69 72 if (hx >= 0) {
70 73 F_RE(ans) = sqrtf(ax);
71 74 F_IM(ans) = zero;
72 75 } else {
73 76 F_IM(ans) = sqrtf(ax);
74 77 F_RE(ans) = zero;
75 78 }
76 79 } else {
77 - dx = (double) ax;
78 - dy = (double) ay;
80 + dx = (double)ax;
81 + dy = (double)ay;
79 82 dt = sqrt(0.5 * (sqrt(dx * dx + dy * dy) + dx));
80 - t = (float) dt;
81 - w = (float) (dy / (dt + dt));
83 + t = (float)dt;
84 + w = (float)(dy / (dt + dt));
85 +
82 86 if (hx >= 0) {
83 87 F_RE(ans) = t;
84 88 F_IM(ans) = w;
85 89 } else {
86 90 F_IM(ans) = t;
87 91 F_RE(ans) = w;
88 92 }
89 93 }
94 +
90 95 if (hy < 0)
91 96 F_IM(ans) = -F_IM(ans);
97 +
92 98 return (ans);
93 99 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX