_X_cplx_lr_div_rx.c revision 2
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy/*
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * CDDL HEADER START
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy *
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * The contents of this file are subject to the terms of the
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * Common Development and Distribution License, Version 1.0 only
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * (the "License"). You may not use this file except in compliance
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * with the License.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy *
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * or http://www.opensolaris.org/os/licensing.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * See the License for the specific language governing permissions
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * and limitations under the License.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy *
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * When distributing Covered Code, include this CDDL HEADER in each
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * If applicable, add the following below this CDDL HEADER, with the
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * fields enclosed by brackets "[]" replaced with your own identifying
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * information: Portions Copyright [yyyy] [name of copyright owner]
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy *
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * CDDL HEADER END
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy */
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy/*
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * Use is subject to license terms.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy */
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy#pragma ident "%Z%%M% %I% %E% SMI"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy/*
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy * _X_cplx_lr_div_rx(a, w) returns a / w computed by the textbook
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy * formula without regard to exceptions or special cases.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy *
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * This code is intended to be used only when CX_LIMITED_RANGE is
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * ON; otherwise use _X_cplx_div_rx.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy */
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy#if !defined(i386) && !defined(__i386) && !defined(__amd64)
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy#error This code is for x86 only
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy#endif
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylong double _Complex
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy_X_cplx_lr_div_rx(long double a, long double _Complex w)
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy{
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy long double _Complex v;
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy long double c, d, r;
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy c = ((long double *)&w)[0];
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy d = ((long double *)&w)[1];
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy r = a / (c * c + d * d);
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy ((long double *)&v)[0] = r * c;
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy ((long double *)&v)[1] = r * -d;
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy return (v);
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy}
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy