```/* <![CDATA[ */
function get_sym_list(){return [["Function","xf",[["_D_cplx_div_ix",77],["testinf",64]]]];} /* ]]> */1/*
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License").  You may not use this file except in compliance
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
19 *
21 */
22/*
24 * Use is subject to license terms.
25 */
26
27#pragma ident	"%Z%%M%	%I%	%E% SMI"
28
29/*
30 * _D_cplx_div_ix(b, w) returns (I * b) / w with infinities handled
31 * according to C99.
32 *
33 * If b and w are both finite and w is nonzero, _D_cplx_div_ix(b, w)
34 * delivers the complex quotient q according to the usual formula:
35 * let c = Re(w), and d = Im(w); then q = x + I * y where x = (b * d)
36 * / r and y = (b * c) / r with r = c * c + d * d.  This implementa-
37 * tion computes intermediate results in extended precision to avoid
38 * premature underflow or overflow.
39 *
40 * If b is neither NaN nor zero and w is zero, or if b is infinite
41 * and w is finite and nonzero, _D_cplx_div_ix delivers an infinite
42 * result.  If b is finite and w is infinite, _D_cplx_div_ix delivers
43 * a zero result.
44 *
45 * If b and w are both zero or both infinite, or if either b or w is
46 * NaN, _D_cplx_div_ix delivers NaN + I * NaN.  C99 doesn't specify
47 * these cases.
48 *
49 * This implementation can raise spurious invalid operation, inexact,
50 * and division-by-zero exceptions.  C99 allows this.
51 *
52 * Warning: Do not attempt to "optimize" this code by removing multi-
53 * plications by zero.
54 */
55
56#if !defined(i386) && !defined(__i386) && !defined(__amd64)
57#error This code is for x86 only
58#endif
59
60/*
61 * Return +1 if x is +Inf, -1 if x is -Inf, and 0 otherwise
62 */
63static int
64testinf(double x)
65{
66	union {
67		int	i;
68		double	d;
69	} xx;
70
71	xx.d = x;
72	return (((((xx.i << 1) - 0xffe00000) | xx.i) == 0)?
73		(1 | (xx.i >> 31)) : 0);
74}
75
76double _Complex
77_D_cplx_div_ix(double b, double _Complex w)
78{
79	double _Complex	v;
80	union {
81		int	i;
82		double	d;
83	} cc, dd;
84	double		c, d;
85	long double	r, x, y;
86	int		i, j;
87
88	/*
89	 * The following is equivalent to
90	 *
91	 *  c = creal(w); d = cimag(w);
92	 */
93	/* LINTED alignment */
94	c = ((double *)&w);
95	/* LINTED alignment */
96	d = ((double *)&w);
97
98	r = (long double)c * c + (long double)d * d;
99
100	if (r == 0.0f) {
101		/* w is zero; multiply b by 1/Re(w) - I * Im(w) */
102		c = 1.0f / c;
103		j = testinf(b);
104		if (j) { /* b is infinite */
105			b = j;
106		}
107		/* LINTED alignment */
108		((double *)&v) = (b == 0.0f)? b * c : b * d;
109		/* LINTED alignment */
110		((double *)&v) = b * c;
111		return (v);
112	}
113
114	r = (long double)b / r;
115	x = (long double)d * r;
116	y = (long double)c * r;
117
118	if (x != x || y != y) {
119		/*
120		 * x or y is NaN, so b and w can't both be finite and
121		 * nonzero.  Since we handled the case w = 0 above, the
122		 * only case to check here is when w is infinite.
123		 */
124		i = testinf(c);
125		j = testinf(d);
126		if (i | j) { /* w is infinite */
127			cc.d = c;
128			dd.d = d;
129			c = (cc.i < 0)? -0.0f : 0.0f;
130			d = (dd.i < 0)? -0.0f : 0.0f;
131			x = (long double)d * b;
132			y = (long double)c * b;
133		}
134	}
135
136	/*
137	 * The following is equivalent to
138	 *
139	 *  return x + I * y;
140	 */
141	/* LINTED alignment */
142	((double *)&v) = (double)x;
143	/* LINTED alignment */
144	((double *)&v) = (double)y;
145	return (v);
146}
147```
{"ft_lang_label":"__label__en","ft_lang_prob":0.6399153,"math_prob":0.9614675,"size":4090,"snap":"2020-34-2020-40","text_gpt3_token_len":1421,"char_repetition_ratio":0.10744004,"word_repetition_ratio":0.018518519,"special_character_ratio":0.44987774,"punctuation_ratio":0.13851352,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9890803,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-09-25T23:00:33Z\",\"WARC-Record-ID\":\"<urn:uuid:33ed0f6d-e4dc-49dc-8f00-17ab4b594c77>\",\"Content-Length\":\"17432\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:948c5958-479e-4068-86af-74eb7af31c60>\",\"WARC-Concurrent-To\":\"<urn:uuid:1ae8c502-4cdf-46c7-857c-fdbea200492e>\",\"WARC-IP-Address\":\"165.225.151.82\",\"WARC-Target-URI\":\"http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libc/i386/fp/_D_cplx_div_ix.c\",\"WARC-Payload-Digest\":\"sha1:ABQKFKEQULGCGBBW3NKV5V7JPMQNBACD\",\"WARC-Block-Digest\":\"sha1:G6Z7X7AA5SPYFTIG3G3N7I7M22FHQAM2\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-40/CC-MAIN-2020-40_segments_1600400228998.45_warc_CC-MAIN-20200925213517-20200926003517-00176.warc.gz\"}"}