Commit graph

200 commits

Author SHA1 Message Date
Mark Murray 737799dfd3 Now that D44168 has been merged to stable/14, update the manpage
to correctly reflect history.
2024-04-12 16:33:54 +01:00
Mark Murray e38f230827 lib/msun: Fix tgammal(3) on IEEE 128-bit platforms
Undo the 80-bit "stub" implementation of the 128-bit long double
tgammal(3) function. The latest (as of Feb 2024) version of the
src/contrib/arm-optimised-routines library includes a standalone,
full 128-bit replacement. This needs a small bit of wrapping to
fit it in, but is otherwise a drop-in replacement.

Testing this is hard, as most maths packages blow up as soon as
their 80-bit floating-point capability is exceeded. With 128-bit
tgammal(), this is easy to do, and this is the range that needs to
be checked the most carefully. Using my copy of Maple, I was able
to check that the output was within a few ULP of the correct answer,
right up to the point of 128-bit over- and underflow. Additionally,
the results are no worse, and indeed better than the 80-bit version.

Steve Kargl sent me his libm testing code, which I used to verify
that the excpetions for certain key values were correct. Tested in
this case were +-Inf, +-NaN, +-1 and +-0.

Differential Revision:	https://reviews.freebsd.org/D44168
Reviewed by:	theraven, andrew, imp
2024-03-18 09:48:43 +00:00
Warner Losh dc36d6f9bb lib: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by:		Netflix
2023-11-26 22:23:28 -07:00
Warner Losh b2c76c41be Remove $FreeBSD$: one-line nroff pattern
Remove /^\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:15 -06:00
Warner Losh fa9896e082 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:10 -06:00
Brad Smith 2c01176a28 msun: Correct FreeBSD version in sincos() man page
The sincos() man page notes the function was added to msun in FreeBSD
9.0 which must have been an oversight in the review as it was commited
to 12.0 and then backported to the 11 branch.

So I have provided a diff to correct this to the first FreeBSD version
it did ship with which was 11.2.

Reviewed by:	dim, imp
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D40308
2023-06-09 22:04:43 +02:00
Gordon Bergling a52f4499ae libm: Correct some typos in source code comments
- s/modfied/modified/
- s/minimun/minimum/

While here, fix some mandoc warnings:

- whitespace at end of input line
- unusual Xr punctuation
- missing comma before name

Obtained from:	NetBSD
MFC after:	5 days
2022-09-03 19:14:02 +02:00
Gordon Bergling 4b7f35db44 libc: Add HISTORY sections to the manual pages
There are some sections which could be improved
and work to do so is on going. The work will be
covered via 'X-MFC-WITH' commits.

Obtained from:	OpenBSD
MFC after:	1 month
Differential Revision: https://reviews.freebsd.org/D34759
2022-05-05 18:46:32 +02:00
Steve Kargl 046e2d5db1 Implementations of cexpl()
The change implements cexpl() for both ld80 and ld128 architectures.
Testing was done on x86_64 and aarch64 systems.

Along the way sincos[fl]() use an optimization that reduces the argument
to being done one rather than twice.  This optimization actually pointed
to a bug in the ld128 version of sincosl(), which is now fixed.  In
addition, the minmax polynomial coefficients for sincosl() have been
updated.

A concise log of the file-by-file changes follows.

* include/complex.h:
  . Add a prototype for cexpl().

* lib/msun/Makefile:
  . Add s_cexpl.c to the build.
  . Setup a link for cexpl.3 to cexp.3.

* lib/msun/Symbol.map:
  . Expose cexpl symbol in libm shared library.

* lib/msun/ld128/s_cexpl.c:
  * Implementation of cexpl() for 128-bit long double architectures.
    Tested on an aarch64 system.

* lib/msun/ld80/s_cexpl.c:
  * Implementation of cexpl() for Intel 80-bit long double.

* lib/msun/man/cexp.3:
  . Document cexpl().

* lib/msun/man/complex.3:
  . Add a BUGS section about cpow[fl].

* lib/msun/src/s_cexp.c:
  . Include float.h for weak references on 53-bit long double targets.
  . Use sincos() to reduce argument reduction cost.

* lib/msun/src/s_cexpf.c:
  . Use sincosf() to reduce argument reduction cost.

* lib/msun/src/k_sincosl.h:
  . Catch up with the new minmax polynomial coefficients for the kernel for
    the 128-bit cosl() implementation.
  . BUG FIX: *cs was used where *sn should have been.  This means that sinl()
    was no computed correctly when iy != 0.

* lib/msun/src/s_cosl.c:
  . Include fpmath.h to get access to IEEEl2bits.
  . Replace M_PI_4 with pio4,  a 64-bit or 113-bit approximation for pi / 4.

PR:	216862
MFC after:	1 week
2021-11-05 13:51:42 +02:00
Steve Kargl dce5f3abed [LIBM] implementations of sinpi[fl], cospi[fl], and tanpi[fl]
Both IEEE-754 2008 and ISO/IEC TS 18661-4 define the half-cycle
trignometric functions cospi, sinpi, and tanpi.  The attached
patch implements cospi[fl], sinpi[fl], and tanpi[fl].  Limited
testing on the cospi and sinpi reveal a max ULP less than 0.89;
while tanpi is more problematic with a max ULP less than 2.01
in the interval [0,0.5].  The algorithms used in these functions
are documented in {ks}_cospi.c, {ks}_sinpi.c, and s_tanpi.c.

Note.  I no longer have access to a system with ld128 and
adequate support to compile and test the ld128 implementations
of these functions.  Given the almost complete lack of input from
others on improvements to libm, I doubt that anyone cares.  If
someone does care, the ld128 files contain a number of FIXME comments,
and in particular, while the polynomial coefficients are given
I did not update the polynomial algorithms to properly use the
coefficients.

PR:	218514
MFC after:	2 weeks
2021-10-26 02:50:20 +03:00
Gordon Bergling c5cbef2f85 math(3): Use the .Fa macro for function arguments
.Fa is the suitable macro for functions in comparsion to the
.Ar macro, which should be used for commandline arguments.

While here, fix some mandoc warnings.

Reviewed by:	imp (earlier version)
Obtained from:	OpenBSD (in partial)
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D31090
2021-07-09 19:51:44 +02:00
Gordon Bergling 3d265fce43 Fix a few mandoc issues
- skipping paragraph macro: Pp after Sh
- sections out of conventional order: Sh EXAMPLES
- whitespace at end of input line
- normalizing date format
2020-10-09 19:12:44 +00:00
Sergio Carlavilla Delgado d2034aedc1 Fix typo 2020-04-04 07:43:47 +00:00
Warner Losh 5310132318 Note some functions that appeared in First Edition Unix
These functions first appeared in the First Edition of Unix (or earlier in the
pdp-7 version). Just claim 1st Edition for all this. The pdp-7 code is too
fragmented at this point to extend history that far back.
2020-04-01 22:50:41 +00:00
Sergio Carlavilla Delgado 8e76d7909d Add HISTORY sections to log(3) man page
PR:		240265
Submitted by:	gbergling@gmail.com
Approved by:	bcr@(mentor), imp@
MFC after:	1 day
Differential Revision:	https://reviews.freebsd.org/D24148
2020-03-26 11:24:43 +00:00
Sergio Carlavilla Delgado 8209febbb3 Add some HISTORY sections to manpages
environ(7) was in AT&T Version 7
ac(8): Add a HISTORY section
sa(8): Add a HISTORY section
sqrt(3): Add the actual sqrt function to the HISTORY section

Obtained from: OpenBSD

Submitted by:	gbergling@gmail.com
Approved by:	bcr@(mentor)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D23693
2020-02-19 12:49:49 +00:00
Edward Tomasz Napierala 5a38af1fb8 Introduce <sys/qmath.h>, a fixed-point math library from Netflix.
This makes it possible to perform mathematical operations
on
fractional values without using floating point. It operates on Q
numbers, which are integer-sized, opaque structures initialized
to hold a chosen number of integer and fractional
bits.


For a general description of the Q number system, see the "Fixed Point
Representation & Fractional Math" whitepaper[1]; for the actual
API see the qmath(3) man page.

This is one of dependencies for the upcoming stats(3) framework[2]
that will be applied to the TCP stack in a later commit.

1. https://www.superkits.net/whitepapers/Fixed%20Point%20Representation%20&%20Fractional%20Math.pdf
2. https://reviews.freebsd.org/D20477

Reviewed by:	bcr (man pages, earlier version), sef (earlier version)
Discussed with:	cem, dteske, imp, lstewart
Sponsored By:	Klara Inc, Netflix
Obtained from:	Netflix
Differential Revision:	https://reviews.freebsd.org/D20116
2019-08-27 11:46:22 +00:00
Mateusz Piotrowski 6d080f8660 csqrt(3): Fix some typos in the manual page
Submitted by:	Steve Kargl <sgk@troutmask.apl.washington.edu>
Reviewed by:	eadler
Approved by:    krion (mentor, implicit), mat (mentor, implicit)
Differential Revision:	https://reviews.freebsd.org/D17831
2018-11-04 14:11:38 +00:00
Dimitry Andric 5a4c3b831b Recommit r336497: Fix powl, cpow, cpowf, and cpowl imports from OpenBSD
This is a follow-up to r336299.

* lib/msun/Makefile:
  . Remove polevll.c

* lib/msun/ld80/e_powl.c:
  . Copy contents of polevll.c to here.  This is the only consumer of
    these functions.  Make functions 'static inline'.
  . Make reducl a 'static inline' function.

* lib/msun/man/exp.3:
  . Remove BUGS section that no longer applies.

* lib/msun/src/math_private.h:
  . Remove prototypes of __p1evll() and __polevll()

* lib/msun/src/s_cpow.c:
* lib/msun/src/s_cpowf.c:
* lib/msun/src/s_cpowl.c
  . Include math_private.h.
  . Use the CMPLX macro from either C99 or math_private.h (depends on
    compiler support) instead of the problematic use of complex I.

Submitted by:	Steve Kargl <sgk@troutmask.apl.washington.edu>
PR:		229876
MFC after:	1 week
2018-07-20 18:27:30 +00:00
Dimitry Andric c422fbac00 Revert r336497 for now, as it breaks on architectures using gcc, with:
cc1: warnings being treated as errors
/usr/src/lib/msun/src/s_cpow.c: In function 'cpow':
/usr/src/lib/msun/src/s_cpow.c:63: warning: implicit declaration of function 'CMPLX'
2018-07-19 19:07:25 +00:00
Dimitry Andric 2ae9055f49 Fix powl, cpow, cpowf, and cpowl imports from OpenBSD
This is a follow-up to r336299.

* lib/msun/Makefile:
  . Remove polevll.c

* lib/msun/ld80/e_powl.c:
  . Copy contents of polevll.c to here.  This is the only consumer of
    these functions.  Make functions 'static inline'.
  . Make reducl a 'static inline' function.

* lib/msun/man/exp.3:
  . Remove BUGS section that no longer applies.

* lib/msun/src/math_private.h:
  . Remove prototypes of __p1evll() and __polevll()

* lib/msun/src/s_cpow.c:
* lib/msun/src/s_cpowf.c:
* lib/msun/src/s_cpowl.c
  . Use the CMPLX macro from either C99 or math_private.h (depends of
    compiler support) instead of the problematic use of complex I.

Submitted by:	Steve Kargl <sgk@troutmask.apl.washington.edu>
PR:		229876
MFC after:	1 week
2018-07-19 18:44:10 +00:00
Matt Macy 6813d08ff5 msun: add ld80/ld128 powl, cpow, cpowf, cpowl from openbsd
This corresponds to the latest status (hasn't changed in 9+
years) from openbsd of ld80/ld128 powl, and source cpowf, cpow,
cpowl (the complex power functions for float complex, double
complex, and long double complex) which are required for C99
compliance and were missing from FreeBSD. Also required for
some numerical codes using complex numbered Hamiltonians.

Thanks to jhb for tracking down the issue with making
weak_reference compile on powerpc.

When asked to review, bde said "I don't like it" - but
provided no actionable feedback or superior implementations.

Discussed with: jhb
Submitted by: jmd
Differential Revision: https://reviews.freebsd.org/D15919
2018-07-15 00:23:10 +00:00
Conrad Meyer bc5356c5a8 clog.3, complex.3: Fix typos and igor style issues
PR:		228783
Reported by:	Karsten <freebsd-bugzilla AT kkoenig.net>
2018-06-06 16:25:00 +00:00
Konstantin Belousov 0c0288a218 Add implementations for clog(3), clogf(3), and clog(3).
PR:	216863
Submitted by:	bde, Steven G. Kargl <sgk@troutmask.apl.washington.edu>
MFC after:	2 weeks
2018-05-13 09:54:34 +00:00
Eitan Adler d592c356d3 cacos(3): correct spelling of 'I'
In some cases we had 'i' instead of 'I'.

PR:		195517
Submitted by:	stephen
2017-12-31 00:55:00 +00:00
Dimitry Andric 45b8a101e7 Correct r326748, indicating that tgammal(3) is mapped to tgamma(3), not
to itself.

Noticed by:	jilles
MFC after:	3 days
2017-12-10 23:03:13 +00:00
Dimitry Andric 240076e595 Document the existence and precision of the remaining long double
functions for which an imprecise stub implementation was added in
r255294, namely powl(3) and tgammal(3).

Submitted by:	Steve Kargl
MFC after:	3 days
2017-12-10 16:42:59 +00:00
Dimitry Andric dfd6ede5f9 Remove the sentence in math(3) about some long double math functions not
being available.

Submitted by:	Steve Kargl
MFC after:	3 days
2017-12-07 20:38:37 +00:00
Michal Meloun e1b98d0774 Implement sincos, sincosf, and sincosl.
The primary benefit of these functions is that argument
reduction is done once instead of twice in independent
calls to sin() and cos().

* lib/msun/Makefile:
  . Add s_sincos[fl].c to the build.
  . Add sincos.3 documentation.
  . Add appropriate MLINKS.

* lib/msun/Symbol.map:
  . Expose sincos[fl] symbols in dynamic libm.so.

* lib/msun/man/sincos.3:
  . Documentation for sincos[fl].

* lib/msun/src/k_sincos.h:
  . Kernel for sincos() function.  This merges the individual kernels
    for sin() and cos().  The merger offered an opportunity to re-arrange
    the individual kernels for better performance.

* lib/msun/src/k_sincosf.h:
   . Kernel for sincosf() function.  This merges the individual kernels
     for sinf() and cosf(). The merger offered an opportunity to re-arrange
     the individual kernels for better performance.

* lib/msun/src/k_sincosl.h:
   . Kernel for sincosl() function.  This merges the individual kernels
     for sinl() and cosl(). The merger offered an opportunity to re-arrange
     the individual kernels for better performance.

* lib/msun/src/math.h:
  . Add prototytpes for sincos[fl]().

* lib/msun/src/math_private.h:
  . Add RETURNV macros.  This is needed to reset fpsetprec on I386
    hardware for a function with type void.

* lib/msun/src/s_sincos.c:
  . Implementation of sincos() where sin() and cos() were merged into
    one routine and possibly re-arranged for better performance.

* lib/msun/src/s_sincosf.c:
  . Implementation of sincosf() where sinf() and cosf() were merged into
    one routine and possibly re-arranged for better performance.

* lib/msun/src/s_sincosl.c:
  . Implementation of sincosl() where sinl() and cosl() were merged into
    one routine and possibly re-arranged for better performance.

PR:		215977, 218300
Submitted by:	Steven G. Kargl <sgk@troutmask.apl.washington.edu>
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D10765
2017-05-28 06:13:38 +00:00
Warner Losh fbbd9655e5 Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann <jschauma@stevens.edu>
Pull Request:	https://github.com/freebsd/freebsd/pull/96
2017-02-28 23:42:47 +00:00
Mahdi Mokhtari 1fdfb24aa7 Add documentations related to new APIs of r313761
PR:		216850 216851 216852 216856 216857 216858
Submitted by:	sgk@troutmask.apl.washington.edu
Reported by:	sgk@troutmask.apl.washington.edu
Reviewed by:	bde emaste hselasky
Approved by:	bde emaste hselasky
Differential Revision:	https://reviews.freebsd.org/D9491
2017-02-17 08:25:48 +00:00
Enji Cooper fdb319ca66 Bump .Dd 2015-11-09 10:41:27 +00:00
Enji Cooper 6922f80018 Document powl(3)
PR: 191751
Sponsored by: EMC / Isilon Storage Division
2015-11-09 10:40:16 +00:00
Baptiste Daroussin 59a046067a .ie is not supposed to be used in manpages
Submitted by:	carsten.kunze@arcor.de
2015-07-14 15:21:00 +00:00
Baptiste Daroussin 0af928e203 mdoc: fix function declaration 2015-04-26 11:35:36 +00:00
Baptiste Daroussin fbe7ee53da mdoc: remove empty line 2015-04-26 11:35:07 +00:00
Baptiste Daroussin 84413e5425 Remove end of line whitespace 2015-04-26 11:30:27 +00:00
Steve Kargl 186f620727 According to POSIX.1-2008, the Bessel functions of second kind
should raise a divide-by-zero floating point exception for x = +-0
and an invalid floating point exception for x < 0 including x = -Inf.
Update the code to raise the exception and update the documentation
with hopefully better description of the behavior.

Reviewed by:	bde (code only)
2015-03-10 17:10:54 +00:00
Joel Dahl f7e00d4bbd mdoc: remove EOL whitespace. 2014-12-29 13:50:59 +00:00
Joel Dahl c09eb46601 mdoc: improvements to SEE ALSO. 2014-12-27 08:22:58 +00:00
Joel Dahl 7161cdb37b Minor Xr fix. 2014-12-26 09:18:33 +00:00
Steve Kargl f7efd14df1 * Makefile:
. Hook e_lgammal[_r].c to the build.
  . Create man page links for lgammal[-r].3.

* Symbol.map:
  . Sort lgammal to its rightful place.
  . Add FBSD_1.4 section for the new lgamal_r symbol.

* ld128/e_lgammal_r.c:
  . 128-bit implementataion of lgammal_r().

* ld80/e_lgammal_r.c:
  . Intel 80-bit format implementation of lgammal_r().

* src/e_lgamma.c:
  . Expose lgammal as a weak reference to lgamma for platforms
    where long double is mapped to double.

* src/e_lgamma_r.c:
  . Use integer literal constants instead of real literal constants.
    Let compiler(s) do the job of conversion to the appropriate type.
  . Expose lgammal_r as a weak reference to lgamma_r for platforms
    where long double is mapped to double.

* src/e_lgammaf_r.c:
  . Fixed the Cygnus Support conversion of e_lgamma_r.c to float.
    This includes the generation of new polynomial and rational
    approximations with fewer terms.  For each approximation, include
    a comment on an estimate of the accuracy over the relevant domain.
  . Use integer literal constants instead of real literal constants.
    Let compiler(s) do the job of conversion to the appropriate type.
    This allows the removal of several explicit casts of double values
    to float.

* src/e_lgammal.c:
  . Wrapper for lgammal() about lgammal_r().

* src/imprecise.c:
  . Remove the lgamma.

* src/math.h:
  . Add a prototype for lgammal_r().

* man/lgamma.3:
  . Document the new functions.

Reviewed by:	bde
2014-09-15 23:21:57 +00:00
Steve Kargl 3b5e0d0f96 * Makefile:
. Add s_erfl.c to building libm.
  . Add MLINKS for erfl.3 and erfcl.3.

* Symbol.map:
  . Move erfl and erfcl to their proper location.

* ld128/s_erfl.c:
  . Implementations of erfl and erfcl in the IEEE 754 128-bit format.

* ld80/s_erfl.c:
  . Implementations of erfl and erfcl in the Intel 80-bit format.

* man/erf.3:
  . Document the new functions.
  . While here, remove an incomplete sentence.

* src/imprecise.c:
  . Remove the stupidity of mapping erfl and erfcl to erf and erfc.

* src/math.h:
  . Move the declarations of erfl and erfcl to their proper place.

* src/s_erf.c:
  . For architectures where double and long double are the same
    floating point format, use weak references to map erfl to
    erf and ercl to erfc.

Reviewed by:	bde (many earlier versions)
2014-07-13 17:05:03 +00:00
Steve Kargl 1531aa5f6a * msun/man/cosh.3:
* msun/man/sinh.3:
* msun/man/tanh.3:
  . Fix grammar.

* msun/src/e_coshl.c:
* msun/src/e_sinhl.c:
  . Fix comment.

* msun/src/s_tanhl.c:
  . Remove unused variables.
  . Fix location/indentation of comments.
  . Use comparison involving ints instead of long double.
  . Re-order polynomial evaluation on ld128 for |x| < 0.25.
    For now, retain the older order in an "#if 0 ... #else" block.
  . Use int comparison to short-circuit the |x| < 1.5 condition.

Requested by:	bde
2013-12-31 23:59:33 +00:00
Steve Kargl 36af656535 Fix a mismerge of my local doc changes to msun/man/sinh.3. 2013-12-30 17:11:36 +00:00
Steve Kargl a48e1f224c * Makefile:
. Hook coshl, sinhl, and tanhl into libm.
  . Create symbolic links for corresponding manpages.
  . While here remove a nearby extraneous space.

* Symbol.map:
* src/math.h:
  . Move coshl, sinhl, and tanhl to their proper locations.

* man/cosh.3:
* man/sinh.3:
* man/tanh.3:
  . Update the manpages.

* src/e_cosh.c:
* src/e_sinh.c:
* src/s_tanh.c:
  . Add weak reference for LBDL_MANT_DIG==53 targets.

* src/imprecise.c:
  . Remove the coshl, sinhl, and tanhl kludge.

* src/e_coshl.c:
  . ld80 and ld128 implementation of coshl().

* src/e_sinhl.c:
  . ld80 and ld128 implementation of sinhl().

* src/s_tanhl.c:
  . ld80 and ld128 implementation of tanhl().

Obtained from:	bde (mostly), das and kargl
2013-12-30 01:06:21 +00:00
David Schultz 998b640bcb Add implementations of acoshl(), asinhl(), and atanhl(). This is a
merge of the work done by bde and myself.
2013-06-10 06:04:58 +00:00
Steve Kargl 3ffff4bad5 ld80 and ld128 implementations of expm1l(). This code started life
as a fairly faithful implementation of the algorithm found in

PTP Tang, "Table-driven implementation of the Expm1 function
in IEEE floating-point arithmetic," ACM Trans. Math. Soft., 18,
211-222 (1992).

Over the last 18-24 months, the code has under gone significant
optimization and testing.

Reviewed by:	bde
Obtained from:	bde (most of the optimizations)
2013-06-03 19:51:32 +00:00
David Schultz 25a4d6bfda Add logl, log2l, log10l, and log1pl.
Submitted by:	bde
2013-06-03 09:14:31 +00:00
David Schultz e4afa19c33 I'm happy to finally commit stephen@'s implementations of cacos,
cacosh, casin, casinh, catan, and catanh. Thanks to stephen@ and bde@
for working on these.

Submitted by:	stephen@
Reviewed by:	bde
2013-05-30 04:49:26 +00:00