mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 15:03:34 +00:00
parent
c42dbe0e9e
commit
839e2f4cfb
24 changed files with 807 additions and 0 deletions
26
libc/tinymath/acosh.c
Normal file
26
libc/tinymath/acosh.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
|
||||
/**
|
||||
* Returns inverse hyperbolic cosine of 𝑥.
|
||||
*/
|
||||
double acosh(double x) {
|
||||
return log(x + sqrt(x * x - 1));
|
||||
}
|
26
libc/tinymath/acoshf.c
Normal file
26
libc/tinymath/acoshf.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
|
||||
/**
|
||||
* Returns inverse hyperbolic cosine of 𝑥.
|
||||
*/
|
||||
float acoshf(float x) {
|
||||
return logf(x + sqrtf(x * x - 1));
|
||||
}
|
26
libc/tinymath/acoshl.c
Normal file
26
libc/tinymath/acoshl.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
|
||||
/**
|
||||
* Returns inverse hyperbolic cosine of 𝑥.
|
||||
*/
|
||||
long double acoshl(long double x) {
|
||||
return logl(x + sqrtl(x * x - 1));
|
||||
}
|
26
libc/tinymath/asinh.c
Normal file
26
libc/tinymath/asinh.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
|
||||
/**
|
||||
* Returns inverse hyperbolic sine of 𝑥.
|
||||
*/
|
||||
double asinh(double x) {
|
||||
return copysign(log(fabs(x) + sqrt(x * x + 1)), x);
|
||||
}
|
26
libc/tinymath/asinhf.c
Normal file
26
libc/tinymath/asinhf.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
|
||||
/**
|
||||
* Returns inverse hyperbolic sine of 𝑥.
|
||||
*/
|
||||
float asinhf(float x) {
|
||||
return copysignf(logf(fabsf(x) + sqrtf(x * x + 1)), x);
|
||||
}
|
26
libc/tinymath/asinhl.c
Normal file
26
libc/tinymath/asinhl.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
|
||||
/**
|
||||
* Returns inverse hyperbolic sine of 𝑥.
|
||||
*/
|
||||
long double asinhl(long double x) {
|
||||
return copysignl(logl(fabsl(x) + sqrtl(x * x + 1)), x);
|
||||
}
|
26
libc/tinymath/atanh.c
Normal file
26
libc/tinymath/atanh.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
|
||||
/**
|
||||
* Returns inverse hyperbolic tangent of 𝑥.
|
||||
*/
|
||||
double atanh(double x) {
|
||||
return log((1 + x) / (1 - x)) / 2;
|
||||
}
|
26
libc/tinymath/atanhf.c
Normal file
26
libc/tinymath/atanhf.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
|
||||
/**
|
||||
* Returns inverse hyperbolic tangent of 𝑥.
|
||||
*/
|
||||
float atanhf(float x) {
|
||||
return logf((1 + x) / (1 - x)) / 2;
|
||||
}
|
26
libc/tinymath/atanhl.c
Normal file
26
libc/tinymath/atanhl.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
|
||||
/**
|
||||
* Returns inverse hyperbolic tangent of 𝑥.
|
||||
*/
|
||||
long double atanhl(long double x) {
|
||||
return logl((1 + x) / (1 - x)) / 2;
|
||||
}
|
26
libc/tinymath/cosh.c
Normal file
26
libc/tinymath/cosh.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
|
||||
/**
|
||||
* Returns hyperbolic cosine of 𝑥.
|
||||
*/
|
||||
double cosh(double x) {
|
||||
return (exp(x) + exp(-x)) / 2;
|
||||
}
|
26
libc/tinymath/coshf.c
Normal file
26
libc/tinymath/coshf.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
|
||||
/**
|
||||
* Returns hyperbolic cosine of 𝑥.
|
||||
*/
|
||||
float coshf(float x) {
|
||||
return (expf(x) + expf(-x)) / 2;
|
||||
}
|
26
libc/tinymath/coshl.c
Normal file
26
libc/tinymath/coshl.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
|
||||
/**
|
||||
* Returns hyperbolic cosine of 𝑥.
|
||||
*/
|
||||
long double coshl(long double x) {
|
||||
return (expl(x) + expl(-x)) / 2;
|
||||
}
|
26
libc/tinymath/sinh.c
Normal file
26
libc/tinymath/sinh.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
|
||||
/**
|
||||
* Returns hyperbolic sine of 𝑥.
|
||||
*/
|
||||
double sinh(double x) {
|
||||
return (exp(x) - exp(-x)) / 2;
|
||||
}
|
26
libc/tinymath/sinhf.c
Normal file
26
libc/tinymath/sinhf.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
|
||||
/**
|
||||
* Returns hyperbolic sine of 𝑥.
|
||||
*/
|
||||
float sinhf(float x) {
|
||||
return (expf(x) - expf(-x)) / 2;
|
||||
}
|
26
libc/tinymath/sinhl.c
Normal file
26
libc/tinymath/sinhl.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
|
||||
/**
|
||||
* Returns hyperbolic sine of 𝑥.
|
||||
*/
|
||||
long double sinhl(long double x) {
|
||||
return (expl(x) - expl(-x)) / 2;
|
||||
}
|
27
libc/tinymath/tanh.c
Normal file
27
libc/tinymath/tanh.c
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
|
||||
/**
|
||||
* Returns hyperbolic tangent of 𝑥.
|
||||
*/
|
||||
double tanh(double x) {
|
||||
if (isinf(x)) return copysign(1, x);
|
||||
return sinh(x) / cosh(x);
|
||||
}
|
27
libc/tinymath/tanhf.c
Normal file
27
libc/tinymath/tanhf.c
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
|
||||
/**
|
||||
* Returns hyperbolic tangent of 𝑥.
|
||||
*/
|
||||
float tanhf(float x) {
|
||||
if (isinf(x)) return copysignf(1, x);
|
||||
return sinhf(x) / coshf(x);
|
||||
}
|
27
libc/tinymath/tanhl.c
Normal file
27
libc/tinymath/tanhl.c
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
|
||||
/**
|
||||
* Returns hyperbolic tangent of 𝑥.
|
||||
*/
|
||||
long double tanhl(long double x) {
|
||||
if (isinf(x)) return copysignl(1, x);
|
||||
return sinhl(x) / coshl(x);
|
||||
}
|
56
test/libc/tinymath/acosh_test.c
Normal file
56
test/libc/tinymath/acosh_test.c
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
#include "libc/runtime/gc.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
#include "libc/x/x.h"
|
||||
|
||||
#define acoshl(x) acoshl(VEIL("t", (long double)(x)))
|
||||
#define acosh(x) acosh(VEIL("x", (double)(x)))
|
||||
#define acoshf(x) acoshf(VEIL("x", (float)(x)))
|
||||
|
||||
TEST(acosh, test) {
|
||||
EXPECT_STREQ(".962423650119207", gc(xdtoa(acosh(1.5))));
|
||||
EXPECT_STREQ("0", gc(xdtoa(acosh(1))));
|
||||
EXPECT_TRUE(isnan(acosh(NAN)));
|
||||
EXPECT_TRUE(isnan(acosh(.5)));
|
||||
EXPECT_TRUE(isnan(acosh(-.5)));
|
||||
EXPECT_TRUE(isnan(acosh(-1.5)));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoa(acosh(INFINITY))));
|
||||
}
|
||||
|
||||
TEST(acoshf, test) {
|
||||
EXPECT_STREQ(".962424", gc(xdtoaf(acoshf(1.5))));
|
||||
EXPECT_STREQ("0", gc(xdtoaf(acoshf(1))));
|
||||
EXPECT_TRUE(isnan(acoshf(NAN)));
|
||||
EXPECT_TRUE(isnan(acoshf(.5)));
|
||||
EXPECT_TRUE(isnan(acoshf(-.5)));
|
||||
EXPECT_TRUE(isnan(acoshf(-1.5)));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoaf(acoshf(INFINITY))));
|
||||
}
|
||||
|
||||
TEST(acoshl, test) {
|
||||
EXPECT_STREQ(".9624236501192069", gc(xdtoal(acoshl(1.5))));
|
||||
EXPECT_STREQ("0", gc(xdtoal(acoshl(1))));
|
||||
EXPECT_TRUE(isnan(acoshl(NAN)));
|
||||
EXPECT_TRUE(isnan(acoshl(.5)));
|
||||
EXPECT_TRUE(isnan(acoshl(-.5)));
|
||||
EXPECT_TRUE(isnan(acoshl(-1.5)));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoal(acoshl(INFINITY))));
|
||||
}
|
50
test/libc/tinymath/asinh_test.c
Normal file
50
test/libc/tinymath/asinh_test.c
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
#include "libc/runtime/gc.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
#include "libc/x/x.h"
|
||||
|
||||
#define asinhl(x) asinhl(VEIL("t", (long double)(x)))
|
||||
#define asinh(x) asinh(VEIL("x", (double)(x)))
|
||||
#define asinhf(x) asinhf(VEIL("x", (float)(x)))
|
||||
|
||||
TEST(asinh, test) {
|
||||
EXPECT_STREQ(".481211825059603", gc(xdtoa(asinh(+.5))));
|
||||
EXPECT_STREQ("-.481211825059603", gc(xdtoa(asinh(-.5))));
|
||||
EXPECT_STREQ("0", gc(xdtoa(asinh(0))));
|
||||
EXPECT_STREQ("NAN", gc(xdtoa(asinh(NAN))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoa(asinh(INFINITY))));
|
||||
}
|
||||
|
||||
TEST(asinhf, test) {
|
||||
EXPECT_STREQ(".481212", gc(xdtoaf(asinhf(+.5))));
|
||||
EXPECT_STREQ("-.481212", gc(xdtoaf(asinhf(-.5))));
|
||||
EXPECT_STREQ("0", gc(xdtoaf(asinhf(0))));
|
||||
EXPECT_STREQ("NAN", gc(xdtoaf(asinhf(NAN))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoaf(asinhf(INFINITY))));
|
||||
}
|
||||
|
||||
TEST(asinhl, test) {
|
||||
EXPECT_STREQ(".4812118250596034", gc(xdtoal(asinhl(+.5))));
|
||||
EXPECT_STREQ("-.4812118250596034", gc(xdtoal(asinhl(-.5))));
|
||||
EXPECT_STREQ("0", gc(xdtoal(asinhl(0))));
|
||||
EXPECT_STREQ("NAN", gc(xdtoal(asinhl(NAN))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoal(asinhl(INFINITY))));
|
||||
}
|
56
test/libc/tinymath/atanh_test.c
Normal file
56
test/libc/tinymath/atanh_test.c
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
#include "libc/runtime/gc.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
#include "libc/x/x.h"
|
||||
|
||||
#define atanhl(x) atanhl(VEIL("t", (long double)(x)))
|
||||
#define atanh(x) atanh(VEIL("x", (double)(x)))
|
||||
#define atanhf(x) atanhf(VEIL("x", (float)(x)))
|
||||
|
||||
TEST(atanh, test) {
|
||||
EXPECT_STREQ("0", gc(xdtoa(atanh(0))));
|
||||
EXPECT_STREQ(".549306144334055", gc(xdtoa(atanh(.5))));
|
||||
EXPECT_STREQ("-.549306144334055", gc(xdtoa(atanh(-.5))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoa(atanh(+1))));
|
||||
EXPECT_STREQ("-INFINITY", gc(xdtoa(atanh(-1))));
|
||||
EXPECT_TRUE(isnan(atanh(+1.1)));
|
||||
EXPECT_TRUE(isnan(atanh(-1.1)));
|
||||
}
|
||||
|
||||
TEST(atanhl, test) {
|
||||
EXPECT_STREQ("0", gc(xdtoal(atanhl(0))));
|
||||
EXPECT_STREQ(".5493061443340548", gc(xdtoal(atanhl(.5))));
|
||||
EXPECT_STREQ("-.5493061443340548", gc(xdtoal(atanhl(-.5))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoal(atanhl(+1))));
|
||||
EXPECT_STREQ("-INFINITY", gc(xdtoal(atanhl(-1))));
|
||||
EXPECT_TRUE(isnan(atanhl(+1.1)));
|
||||
EXPECT_TRUE(isnan(atanhl(-1.1)));
|
||||
}
|
||||
|
||||
TEST(atanhf, test) {
|
||||
EXPECT_STREQ("0", gc(xdtoaf(atanhf(0))));
|
||||
EXPECT_STREQ(".549306", gc(xdtoaf(atanhf(.5))));
|
||||
EXPECT_STREQ("-.549306", gc(xdtoaf(atanhf(-.5))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoaf(atanhf(+1))));
|
||||
EXPECT_STREQ("-INFINITY", gc(xdtoaf(atanhf(-1))));
|
||||
EXPECT_TRUE(isnan(atanhf(+1.1)));
|
||||
EXPECT_TRUE(isnan(atanhf(-1.1)));
|
||||
}
|
62
test/libc/tinymath/cosh_test.c
Normal file
62
test/libc/tinymath/cosh_test.c
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
#include "libc/runtime/gc.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
#include "libc/x/x.h"
|
||||
|
||||
#define coshl(x) coshl(VEIL("t", (long double)(x)))
|
||||
#define cosh(x) cosh(VEIL("x", (double)(x)))
|
||||
#define coshf(x) coshf(VEIL("x", (float)(x)))
|
||||
|
||||
TEST(coshl, test) {
|
||||
EXPECT_STREQ("1.127625965206381", gc(xdtoal(coshl(+.5))));
|
||||
EXPECT_STREQ("1.127625965206381", gc(xdtoal(coshl(-.5))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoal(coshl(30000))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoal(coshl(-30000))));
|
||||
EXPECT_STREQ("1", gc(xdtoal(coshl(+0.))));
|
||||
EXPECT_STREQ("1", gc(xdtoal(coshl(-0.))));
|
||||
EXPECT_TRUE(isnan(coshl(NAN)));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoal(coshl(INFINITY))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoal(coshl(-INFINITY))));
|
||||
}
|
||||
|
||||
TEST(cosh, test) {
|
||||
EXPECT_STREQ("1.12762596520638", gc(xdtoa(cosh(+.5))));
|
||||
EXPECT_STREQ("1.12762596520638", gc(xdtoa(cosh(-.5))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoa(cosh(30000))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoa(cosh(-30000))));
|
||||
EXPECT_STREQ("1", gc(xdtoa(cosh(+0.))));
|
||||
EXPECT_STREQ("1", gc(xdtoa(cosh(-0.))));
|
||||
EXPECT_TRUE(isnan(cosh(NAN)));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoa(cosh(INFINITY))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoa(cosh(-INFINITY))));
|
||||
}
|
||||
|
||||
TEST(coshf, test) {
|
||||
EXPECT_STREQ("1.12763", gc(xdtoaf(coshf(+.5))));
|
||||
EXPECT_STREQ("1.12763", gc(xdtoaf(coshf(-.5))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoaf(coshf(30000))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoaf(coshf(-30000))));
|
||||
EXPECT_STREQ("1", gc(xdtoaf(coshf(+0.))));
|
||||
EXPECT_STREQ("1", gc(xdtoaf(coshf(-0.))));
|
||||
EXPECT_TRUE(isnan(coshf(NAN)));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoaf(coshf(INFINITY))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoaf(coshf(-INFINITY))));
|
||||
}
|
59
test/libc/tinymath/sinh_test.c
Normal file
59
test/libc/tinymath/sinh_test.c
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
#include "libc/runtime/gc.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
#include "libc/x/x.h"
|
||||
|
||||
#define sinhl(x) sinhl(VEIL("t", (long double)(x)))
|
||||
#define sinh(x) sinh(VEIL("x", (double)(x)))
|
||||
#define sinhf(x) sinhf(VEIL("x", (float)(x)))
|
||||
|
||||
TEST(sinh, test) {
|
||||
EXPECT_STREQ(".521095305493747", gc(xdtoa(sinh(+.5))));
|
||||
EXPECT_STREQ("-.521095305493747", gc(xdtoa(sinh(-.5))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoa(sinh(30000))));
|
||||
EXPECT_STREQ("-INFINITY", gc(xdtoa(sinh(-30000))));
|
||||
EXPECT_STREQ("0", gc(xdtoa(sinh(0))));
|
||||
EXPECT_STREQ("NAN", gc(xdtoa(sinh(NAN))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoa(sinh(INFINITY))));
|
||||
EXPECT_STREQ("-INFINITY", gc(xdtoa(sinh(-INFINITY))));
|
||||
}
|
||||
|
||||
TEST(sinhl, test) {
|
||||
EXPECT_STREQ(".5210953054937474", gc(xdtoal(sinhl(+.5))));
|
||||
EXPECT_STREQ("-.5210953054937474", gc(xdtoal(sinhl(-.5))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoal(sinhl(30000))));
|
||||
EXPECT_STREQ("-INFINITY", gc(xdtoal(sinhl(-30000))));
|
||||
EXPECT_STREQ("0", gc(xdtoal(sinhl(0))));
|
||||
EXPECT_STREQ("NAN", gc(xdtoal(sinhl(NAN))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoal(sinhl(INFINITY))));
|
||||
EXPECT_STREQ("-INFINITY", gc(xdtoal(sinhl(-INFINITY))));
|
||||
}
|
||||
|
||||
TEST(sinhf, test) {
|
||||
EXPECT_STREQ(".521095", gc(xdtoaf(sinhf(+.5))));
|
||||
EXPECT_STREQ("-.521095", gc(xdtoaf(sinhf(-.5))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoaf(sinhf(30000))));
|
||||
EXPECT_STREQ("-INFINITY", gc(xdtoaf(sinhf(-30000))));
|
||||
EXPECT_STREQ("0", gc(xdtoaf(sinhf(0))));
|
||||
EXPECT_STREQ("NAN", gc(xdtoaf(sinhf(NAN))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoaf(sinhf(INFINITY))));
|
||||
EXPECT_STREQ("-INFINITY", gc(xdtoaf(sinhf(-INFINITY))));
|
||||
}
|
53
test/libc/tinymath/tanh_test.c
Normal file
53
test/libc/tinymath/tanh_test.c
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
#include "libc/runtime/gc.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
#include "libc/x/x.h"
|
||||
|
||||
#define tanhl(x) tanhl(VEIL("t", (long double)(x)))
|
||||
#define tanh(x) tanh(VEIL("x", (double)(x)))
|
||||
#define tanhf(x) tanhf(VEIL("x", (float)(x)))
|
||||
|
||||
TEST(tanhl, test) {
|
||||
EXPECT_STREQ(".09966799462495582", gc(xdtoal(tanhl(+.1))));
|
||||
EXPECT_STREQ("-.09966799462495582", gc(xdtoal(tanhl(-.1))));
|
||||
EXPECT_STREQ("0", gc(xdtoal(tanhl(0))));
|
||||
EXPECT_TRUE(isnan(tanhl(NAN)));
|
||||
EXPECT_STREQ("1", gc(xdtoal(tanhl(INFINITY))));
|
||||
EXPECT_STREQ("-1", gc(xdtoal(tanhl(-INFINITY))));
|
||||
}
|
||||
|
||||
TEST(tanh, test) {
|
||||
EXPECT_STREQ(".0996679946249559", gc(xdtoa(tanh(+.1))));
|
||||
EXPECT_STREQ("-.0996679946249559", gc(xdtoa(tanh(-.1))));
|
||||
EXPECT_STREQ("0", gc(xdtoa(tanh(0))));
|
||||
EXPECT_TRUE(isnan(tanh(NAN)));
|
||||
EXPECT_STREQ("1", gc(xdtoa(tanh(INFINITY))));
|
||||
EXPECT_STREQ("-1", gc(xdtoa(tanh(-INFINITY))));
|
||||
}
|
||||
|
||||
TEST(tanhf, test) {
|
||||
EXPECT_STREQ(".099668", gc(xdtoaf(tanhf(+.1))));
|
||||
EXPECT_STREQ("-.099668", gc(xdtoaf(tanhf(-.1))));
|
||||
EXPECT_STREQ("0", gc(xdtoaf(tanhf(0))));
|
||||
EXPECT_TRUE(isnan(tanhf(NAN)));
|
||||
EXPECT_STREQ("1", gc(xdtoaf(tanhf(INFINITY))));
|
||||
EXPECT_STREQ("-1", gc(xdtoaf(tanhf(-INFINITY))));
|
||||
}
|
Loading…
Reference in a new issue