ctanhf.c revision 25c28e83beb90e7c80452a7c818c5e6f73a07dc8
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * CDDL HEADER START
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * The contents of this file are subject to the terms of the
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Common Development and Distribution License (the "License").
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * You may not use this file except in compliance with the License.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * or http://www.opensolaris.org/os/licensing.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * See the License for the specific language governing permissions
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * and limitations under the License.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * When distributing Covered Code, include this CDDL HEADER in each
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * If applicable, add the following below this CDDL HEADER, with the
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * fields enclosed by brackets "[]" replaced with your own identifying
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * information: Portions Copyright [yyyy] [name of copyright owner]
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * CDDL HEADER END
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Use is subject to license terms.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis#include "libm.h" /* expf/expm1f/fabsf/sincosf/sinf/tanhf */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis/* INDENT OFF */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtisstatic const float four = 4.0F, two = 2.0F, one = 1.0F, zero = 0.0F;
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis/* INDENT ON */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis float r, u, v, t, x, y, S, C;
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis if (iy == 0) { /* ctanh(x,0) = (x,0) for x = 0 or NaN */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis } else if (iy >= 0x7f800000) { /* y is inf or NaN */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis if (ix < 0x7f800000) /* catanh(finite x,inf/nan) is nan */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis else if (ix == 0x7f800000) { /* x is inf */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * |x| > 14 = prec/2 (14,28,34,60)
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * ctanh z ~ 1 + i (sin2y)/(exp(2x))
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis (void) sincosf(y, &S, &C);
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis S = (S + S) * C;
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis if (ix >= 0x7f800000) { /* |x| is inf or NaN */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis /* 2 sin 2y / exp(2x) */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis /* INDENT OFF */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * ctanh z = ---------------------------
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * t*t+[4(t+1)(cos y)](cos y)
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * [4(t+1)(cos y)]*(sin y)
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * i --------------------------
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * t*t+[4(t+1)(cos y)](cos y)
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis /* INDENT ON */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis (void) sincosf(y, &S, &C);
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis v = one / (u + r * C);