Print this page
5261 libm should stop using synonyms.h
5298 fabs is 0-sized, confuses dis(1) and others
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Approved by: Gordon Ross <gwr@nexenta.com>


   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  23  */
  24 /*
  25  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  26  * Use is subject to license terms.
  27  */
  28 
  29 #pragma weak logf = __logf
  30 
  31 /*
  32  * Algorithm:
  33  *
  34  * Let y = x rounded to six significant bits.  Then for any choice
  35  * of e and z such that y = 2^e z, we have
  36  *
  37  * log(x) = e log(2) + log(z) + log(1+(x-y)/y)
  38  *
  39  * Note that (x-y)/y = (x'-y')/y' for any scaled x' = sx, y' = sy;
  40  * in particular, we can take s to be the power of two that makes
  41  * ulp(x') = 1.
  42  *
  43  * From a table, obtain l = log(z) and r = 1/y'.  For |s| <= 2^-6,
  44  * approximate log(1+s) by a polynomial p(s) where p(s) := s+s*s*
  45  * (K1+s*(K2+s*K3)).  Then we compute the expression above as
  46  * e*ln2 + l + p(r*(x'-y')) all evaluated in double precision.
  47  *
  48  * When x is subnormal, we first scale it to the normal range,
  49  * adjusting e accordingly.




   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  23  */
  24 /*
  25  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  26  * Use is subject to license terms.
  27  */
  28 
  29 #pragma weak __logf = logf
  30 
  31 /*
  32  * Algorithm:
  33  *
  34  * Let y = x rounded to six significant bits.  Then for any choice
  35  * of e and z such that y = 2^e z, we have
  36  *
  37  * log(x) = e log(2) + log(z) + log(1+(x-y)/y)
  38  *
  39  * Note that (x-y)/y = (x'-y')/y' for any scaled x' = sx, y' = sy;
  40  * in particular, we can take s to be the power of two that makes
  41  * ulp(x') = 1.
  42  *
  43  * From a table, obtain l = log(z) and r = 1/y'.  For |s| <= 2^-6,
  44  * approximate log(1+s) by a polynomial p(s) where p(s) := s+s*s*
  45  * (K1+s*(K2+s*K3)).  Then we compute the expression above as
  46  * e*ln2 + l + p(r*(x'-y')) all evaluated in double precision.
  47  *
  48  * When x is subnormal, we first scale it to the normal range,
  49  * adjusting e accordingly.