18e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner/*- 28e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner * Copyright (c) 2008 David Schultz <das@FreeBSD.ORG> 38e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner * All rights reserved. 48e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner * 58e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner * Redistribution and use in source and binary forms, with or without 68e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner * modification, are permitted provided that the following conditions 78e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner * are met: 88e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner * 1. Redistributions of source code must retain the above copyright 98e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner * notice, this list of conditions and the following disclaimer. 108e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner * 2. Redistributions in binary form must reproduce the above copyright 118e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner * notice, this list of conditions and the following disclaimer in the 128e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner * documentation and/or other materials provided with the distribution. 138e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner * 148e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 158e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 168e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 178e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 188e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 198e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 208e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 218e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 228e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 238e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 248e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner * SUCH DAMAGE. 258e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner */ 268e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner 278e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner#include <sys/cdefs.h> 288cff2f95d8673b4b9002292d50ce8caa6efb98b6Elliott Hughes__FBSDID("$FreeBSD: head/lib/msun/src/s_cprojf.c 275819 2014-12-16 09:21:56Z ed $"); 298e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner 30a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes#include <complex.h> 318e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner#include <math.h> 328e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner 33a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes#include "math_private.h" 34a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes 35a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughesfloat complex 36a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughescprojf(float complex z) 378e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner{ 388e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner 39a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes if (!isinf(crealf(z)) && !isinf(cimagf(z))) 40a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes return (z); 41a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes else 428cff2f95d8673b4b9002292d50ce8caa6efb98b6Elliott Hughes return (CMPLXF(INFINITY, copysignf(0.0, cimagf(z)))); 438e2ff164cc327aad8666333a1d75f86291858da0David 'Digit' Turner} 44