diff options
Diffstat (limited to 'nuttx/libc/math')
76 files changed, 0 insertions, 4415 deletions
diff --git a/nuttx/libc/math/Kconfig b/nuttx/libc/math/Kconfig deleted file mode 100644 index db9dfae63..000000000 --- a/nuttx/libc/math/Kconfig +++ /dev/null @@ -1,26 +0,0 @@ -# -# For a description of the syntax of this configuration file, -# see misc/tools/kconfig-language.txt. -# - -config LIBM - bool "Standard Math library" - default n - depends on !ARCH_MATH_H - ---help--- - By default, no math library will be provided by NuttX. In this this case, it - is assumed that (1) no math library is required, or (2) you will be using the - math.h header file and the libm library provided by your toolchain. - - This is may be a very good choice is possible because your toolchain may have - have a highly optimized version of libm. - - Another possibility is that you have a custom, architecture-specific math - libary and that the corresponding math.h file resides at arch/<architecture>/include/math.h. - The option is selected via ARCH_MATH_H. If ARCH_MATH_H is selected,then the include/nuttx/math.h - header file will be copied to include/math.h where it can be used by your applications. - - If ARCH_MATH_H is not defined, then this option can be selected to build a generic, - math library built into NuttX. This math library comes from the Rhombus OS and - was written by Nick Johnson. The Rhombus OS math library port was contributed by - Darcy Gong. diff --git a/nuttx/libc/math/Make.defs b/nuttx/libc/math/Make.defs deleted file mode 100644 index ece25f4e5..000000000 --- a/nuttx/libc/math/Make.defs +++ /dev/null @@ -1,62 +0,0 @@ -############################################################################ -# libc/math/Make.defs -# -# Copyright (C) 2012 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <gnutt@nuttx.org> -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name NuttX nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -ifeq ($(CONFIG_LIBM),y) - -# Add the floating point math C files to the build - -CSRCS += lib_acosf.c lib_asinf.c lib_atan2f.c lib_atanf.c lib_ceilf.c lib_cosf.c -CSRCS += lib_coshf.c lib_expf.c lib_fabsf.c lib_floorf.c lib_fmodf.c lib_frexpf.c -CSRCS += lib_ldexpf.c lib_logf.c lib_log10f.c lib_log2f.c lib_modff.c lib_powf.c -CSRCS += lib_roundf.c lib_sinf.c lib_sinhf.c lib_sqrtf.c lib_tanf.c lib_tanhf.c - -CSRCS += lib_acos.c lib_asin.c lib_atan.c lib_atan2.c lib_ceil.c lib_cos.c -CSRCS += lib_cosh.c lib_exp.c lib_fabs.c lib_floor.c lib_fmod.c lib_frexp.c -CSRCS += lib_ldexp.c lib_log.c lib_log10.c lib_log2.c lib_modf.c lib_pow.c -CSRCS += lib_round.c lib_sin.c lib_sinh.c lib_sqrt.c lib_tan.c lib_tanh.c - -CSRCS += lib_acosl.c lib_asinl.c lib_atan2l.c lib_atanl.c lib_ceill.c lib_cosl.c -CSRCS += lib_coshl.c lib_expl.c lib_fabsl.c lib_floorl.c lib_fmodl.c lib_frexpl.c -CSRCS += lib_ldexpl.c lib_logl.c lib_log10l.c lib_log2l.c lib_modfl.c lib_powl.c -CSRCS += lib_roundl.c lib_sinl.c lib_sinhl.c lib_sqrtl.c lib_tanl.c lib_tanhl.c - -CSRCS += lib_libexpi.c lib_libsqrtapprox.c - -# Add the floating point math directory to the build - -DEPPATH += --dep-path math -VPATH += :math - -endif diff --git a/nuttx/libc/math/lib_acos.c b/nuttx/libc/math/lib_acos.c deleted file mode 100644 index 147003237..000000000 --- a/nuttx/libc/math/lib_acos.c +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************ - * libc/math/lib_acos.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_DOUBLE -double acos(double x) -{ - return (M_PI_2 - asin(x)); -} -#endif diff --git a/nuttx/libc/math/lib_acosf.c b/nuttx/libc/math/lib_acosf.c deleted file mode 100644 index 447b2767f..000000000 --- a/nuttx/libc/math/lib_acosf.c +++ /dev/null @@ -1,41 +0,0 @@ -/************************************************************************ - * libc/math/lib_acosf.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -float acosf(float x) -{ - return (M_PI_2 - asinf(x)); -} diff --git a/nuttx/libc/math/lib_acosl.c b/nuttx/libc/math/lib_acosl.c deleted file mode 100644 index a0f226238..000000000 --- a/nuttx/libc/math/lib_acosl.c +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************ - * libc/math/lib_acos.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_LONG_DOUBLE -long double acosl(long double x) -{ - return (M_PI_2 - asinl(x)); -} -#endif diff --git a/nuttx/libc/math/lib_asin.c b/nuttx/libc/math/lib_asin.c deleted file mode 100644 index d9941a7e5..000000000 --- a/nuttx/libc/math/lib_asin.c +++ /dev/null @@ -1,69 +0,0 @@ -/************************************************************************ - * libc/math/lib_sin.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> -#include <float.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_DOUBLE -double asin(double x) -{ - long double y, y_sin, y_cos; - - y = 0; - - while (1) - { - y_sin = sin(y); - y_cos = cos(y); - - if (y > M_PI_2 || y < -M_PI_2) - { - y = fmod(y, M_PI); - } - - if (y_sin + DBL_EPSILON >= x && y_sin - DBL_EPSILON <= x) - { - break; - } - - y = y - (y_sin - x) / y_cos; - } - - return y; -} -#endif diff --git a/nuttx/libc/math/lib_asinf.c b/nuttx/libc/math/lib_asinf.c deleted file mode 100644 index 57e518acb..000000000 --- a/nuttx/libc/math/lib_asinf.c +++ /dev/null @@ -1,65 +0,0 @@ -/************************************************************************ - * libc/math/lib_sinf.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <math.h> -#include <float.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -float asinf(float x) -{ - long double y, y_sin, y_cos; - - y = 0; - - while (1) - { - y_sin = sinf(y); - y_cos = cosf(y); - - if (y > M_PI_2 || y < -M_PI_2) - { - y = fmodf(y, M_PI); - } - - if (y_sin + FLT_EPSILON >= x && y_sin - FLT_EPSILON <= x) - { - break; - } - - y = y - (y_sin - x) / y_cos; - } - - return y; -} - diff --git a/nuttx/libc/math/lib_asinl.c b/nuttx/libc/math/lib_asinl.c deleted file mode 100644 index 19f284e53..000000000 --- a/nuttx/libc/math/lib_asinl.c +++ /dev/null @@ -1,69 +0,0 @@ -/************************************************************************ - * libc/math/lib_sinl.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> -#include <float.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_LONG_DOUBLE -long double asinl(long double x) -{ - long double y, y_sin, y_cos; - - y = 0; - - while (1) - { - y_sin = sinl(y); - y_cos = cosl(y); - - if (y > M_PI_2 || y < -M_PI_2) - { - y = fmodl(y, M_PI); - } - - if (y_sin + LDBL_EPSILON >= x && y_sin - LDBL_EPSILON <= x) - { - break; - } - - y = y - (y_sin - x) / y_cos; - } - - return y; -} -#endif diff --git a/nuttx/libc/math/lib_atan.c b/nuttx/libc/math/lib_atan.c deleted file mode 100644 index 44d68ece2..000000000 --- a/nuttx/libc/math/lib_atan.c +++ /dev/null @@ -1,48 +0,0 @@ -/************************************************************************ - * libc/math/lib_atan.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> -#include <stddef.h> -#include <stdint.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_DOUBLE -double atan(double x) -{ - return asin(x / sqrt(x * x + 1)); -} -#endif diff --git a/nuttx/libc/math/lib_atan2.c b/nuttx/libc/math/lib_atan2.c deleted file mode 100644 index 6d7d2ad48..000000000 --- a/nuttx/libc/math/lib_atan2.c +++ /dev/null @@ -1,86 +0,0 @@ -/************************************************************************ - * libc/math/lib_atan2.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_DOUBLE -double atan2(double y, double x) -{ - if (y == 0.0) - { - if (x >= 0.0) - { - return 0.0; - } - else - { - return M_PI; - } - } - else if (y > 0.0) - { - if (x == 0.0) - { - return M_PI_2; - } - else if (x > 0.0) - { - return atan(y / x); - } - else - { - return M_PI - atan(y / x); - } - } - else - { - if (x == 0.0) - { - return M_PI + M_PI_2; - } - else if (x > 0.0) - { - return 2 * M_PI - atan(y / x); - } - else - { - return M_PI + atan(y / x); - } - } -} -#endif diff --git a/nuttx/libc/math/lib_atan2f.c b/nuttx/libc/math/lib_atan2f.c deleted file mode 100644 index 7ff9af130..000000000 --- a/nuttx/libc/math/lib_atan2f.c +++ /dev/null @@ -1,81 +0,0 @@ -/************************************************************************ - * libc/math/lib_atan2f.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -float atan2f(float y, float x) -{ - if (y == 0.0) - { - if (x >= 0.0) - { - return 0.0; - } - else - { - return M_PI; - } - } - else if (y > 0.0) - { - if (x == 0.0) - { - return M_PI_2; - } - else if (x > 0.0) - { - return atanf(y / x); - } - else - { - return M_PI - atanf(y / x); - } - } - else - { - if (x == 0.0) - { - return M_PI + M_PI_2; - } - else if (x > 0.0) - { - return 2 * M_PI - atanf(y / x); - } - else - { - return M_PI + atanf(y / x); - } - } -} diff --git a/nuttx/libc/math/lib_atan2l.c b/nuttx/libc/math/lib_atan2l.c deleted file mode 100644 index 48bfd06f3..000000000 --- a/nuttx/libc/math/lib_atan2l.c +++ /dev/null @@ -1,87 +0,0 @@ -/************************************************************************ - * libc/math/lib_atan2l.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_LONG_DOUBLE -long double atan2l(long double y, long double x) -{ - - if (y == 0.0) - { - if (x >= 0.0) - { - return 0.0; - } - else - { - return M_PI; - } - } - else if (y > 0.0) - { - if (x == 0.0) - { - return M_PI_2; - } - else if (x > 0.0) - { - return atanl(y / x); - } - else - { - return M_PI - atanl(y / x); - } - } - else - { - if (x == 0.0) - { - return M_PI + M_PI_2; - } - else if (x > 0.0) - { - return 2 * M_PI - atanl(y / x); - } - else - { - return M_PI + atanl(y / x); - } - } -} -#endif diff --git a/nuttx/libc/math/lib_atanf.c b/nuttx/libc/math/lib_atanf.c deleted file mode 100644 index a84605787..000000000 --- a/nuttx/libc/math/lib_atanf.c +++ /dev/null @@ -1,43 +0,0 @@ -/************************************************************************ - * libc/math/lib_atanf.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <math.h> -#include <stddef.h> -#include <stdint.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -float atanf(float x) -{ - return asinf(x / sqrtf(x * x + 1)); -} diff --git a/nuttx/libc/math/lib_atanl.c b/nuttx/libc/math/lib_atanl.c deleted file mode 100644 index 752d49307..000000000 --- a/nuttx/libc/math/lib_atanl.c +++ /dev/null @@ -1,48 +0,0 @@ -/************************************************************************ - * libc/math/lib_atanl.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> -#include <stddef.h> -#include <stdint.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_LONG_DOUBLE -long double atanl(long double x) -{ - return asinl(x / sqrtl(x * x + 1)); -} -#endif diff --git a/nuttx/libc/math/lib_ceil.c b/nuttx/libc/math/lib_ceil.c deleted file mode 100644 index 3c6678dc1..000000000 --- a/nuttx/libc/math/lib_ceil.c +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************************************ - * libc/math/lib_ceil.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_DOUBLE -double ceil(double x) -{ - modf(x, &x); - if (x > 0.0) - { - x += 1.0; - } - - return x; -} -#endif diff --git a/nuttx/libc/math/lib_ceilf.c b/nuttx/libc/math/lib_ceilf.c deleted file mode 100644 index afbe2cf13..000000000 --- a/nuttx/libc/math/lib_ceilf.c +++ /dev/null @@ -1,47 +0,0 @@ -/************************************************************************ - * libc/math/lib_ceilf.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -float ceilf(float x) -{ - modff(x, &x); - if (x > 0.0) - { - x += 1.0; - } - - return x; -} diff --git a/nuttx/libc/math/lib_ceill.c b/nuttx/libc/math/lib_ceill.c deleted file mode 100644 index 757016b53..000000000 --- a/nuttx/libc/math/lib_ceill.c +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************************************ - * libc/math/lib_ceil;.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_LONG_DOUBLE -long double ceill(long double x) -{ - modfl(x, &x); - if (x > 0.0) - { - x += 1.0; - } - - return x; -} -#endif diff --git a/nuttx/libc/math/lib_cos.c b/nuttx/libc/math/lib_cos.c deleted file mode 100644 index 4b4e1a20b..000000000 --- a/nuttx/libc/math/lib_cos.c +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************ - * libc/math/lib_cos.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_DOUBLE -double cos(double x) -{ - return sin(x + M_PI_2); -} -#endif diff --git a/nuttx/libc/math/lib_cosf.c b/nuttx/libc/math/lib_cosf.c deleted file mode 100644 index d9ac951f6..000000000 --- a/nuttx/libc/math/lib_cosf.c +++ /dev/null @@ -1,41 +0,0 @@ -/************************************************************************ - * libc/math/lib_cosf.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -float cosf(float x) -{ - return sinf(x + M_PI_2); -} diff --git a/nuttx/libc/math/lib_cosh.c b/nuttx/libc/math/lib_cosh.c deleted file mode 100644 index 3246ea5f9..000000000 --- a/nuttx/libc/math/lib_cosh.c +++ /dev/null @@ -1,47 +0,0 @@ -/************************************************************************ - * libc/math/lib_cosh.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_DOUBLE -double cosh(double x) -{ - x = exp(x); - return ((x + (1.0 / x)) / 2.0); -} -#endif diff --git a/nuttx/libc/math/lib_coshf.c b/nuttx/libc/math/lib_coshf.c deleted file mode 100644 index f0c28ab2e..000000000 --- a/nuttx/libc/math/lib_coshf.c +++ /dev/null @@ -1,42 +0,0 @@ -/************************************************************************ - * libc/math/lib_coshf.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -float coshf(float x) -{ - x = expf(x); - return ((x + (1.0 / x)) / 2.0); -} diff --git a/nuttx/libc/math/lib_coshl.c b/nuttx/libc/math/lib_coshl.c deleted file mode 100644 index 957ec61a7..000000000 --- a/nuttx/libc/math/lib_coshl.c +++ /dev/null @@ -1,47 +0,0 @@ -/************************************************************************ - * libc/math/lib_coshl.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_LONG_DOUBLE -long double coshl(long double x) -{ - x = expl(x); - return ((x + (1.0 / x)) / 2.0); -} -#endif diff --git a/nuttx/libc/math/lib_cosl.c b/nuttx/libc/math/lib_cosl.c deleted file mode 100644 index 972d4aa9d..000000000 --- a/nuttx/libc/math/lib_cosl.c +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************ - * libc/math/lib_cosl.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_LONG_DOUBLE -long double cosl(long double x) -{ - return sinl(x + M_PI_2); -} -#endif diff --git a/nuttx/libc/math/lib_exp.c b/nuttx/libc/math/lib_exp.c deleted file mode 100644 index 62494251d..000000000 --- a/nuttx/libc/math/lib_exp.c +++ /dev/null @@ -1,126 +0,0 @@ -/************************************************************************ - * libc/math/lib_exp.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <sys/types.h> -#include <math.h> - -#include "lib_internal.h" - -#ifdef CONFIG_HAVE_DOUBLE - -/************************************************************************ - * Private Data - ************************************************************************/ - -static double _dbl_inv_fact[] = -{ - 1.0 / 1.0, // 1 / 0! - 1.0 / 1.0, // 1 / 1! - 1.0 / 2.0, // 1 / 2! - 1.0 / 6.0, // 1 / 3! - 1.0 / 24.0, // 1 / 4! - 1.0 / 120.0, // 1 / 5! - 1.0 / 720.0, // 1 / 6! - 1.0 / 5040.0, // 1 / 7! - 1.0 / 40320.0, // 1 / 8! - 1.0 / 362880.0, // 1 / 9! - 1.0 / 3628800.0, // 1 / 10! - 1.0 / 39916800.0, // 1 / 11! - 1.0 / 479001600.0, // 1 / 12! - 1.0 / 6227020800.0, // 1 / 13! - 1.0 / 87178291200.0, // 1 / 14! - 1.0 / 1307674368000.0, // 1 / 15! - 1.0 / 20922789888000.0, // 1 / 16! - 1.0 / 355687428096000.0, // 1 / 17! - 1.0 / 6402373705728000.0, // 1 / 18! -}; - -/************************************************************************ - * Public Functions - ************************************************************************/ - -double exp(double x) -{ - size_t int_part; - bool invert; - double value; - double x0; - size_t i; - - if (x == 0) - { - return 1; - } - else if (x < 0) - { - invert = true; - x = -x; - } - else - { - invert = false; - } - - /* Extract integer component */ - - int_part = (size_t) x; - - /* Set x to fractional component */ - - x -= (double)int_part; - - /* Perform Taylor series approximation with nineteen terms */ - - value = 0.0; - x0 = 1.0; - for (i = 0; i < 19; i++) - { - value += x0 * _dbl_inv_fact[i]; - x0 *= x; - } - - /* Multiply by exp of the integer component */ - - value *= lib_expi(int_part); - - if (invert) - { - return (1.0 / value); - } - else - { - return value; - } -} -#endif diff --git a/nuttx/libc/math/lib_expf.c b/nuttx/libc/math/lib_expf.c deleted file mode 100644 index 3e43c54a6..000000000 --- a/nuttx/libc/math/lib_expf.c +++ /dev/null @@ -1,112 +0,0 @@ -/************************************************************************ - * libc/math/lib_expf.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <sys/types.h> -#include <math.h> - -#include "lib_internal.h" - -/************************************************************************ - * Private Data - ************************************************************************/ - -static float _flt_inv_fact[] = -{ - 1.0 / 1.0, // 1/0! - 1.0 / 1.0, // 1/1! - 1.0 / 2.0, // 1/2! - 1.0 / 6.0, // 1/3! - 1.0 / 24.0, // 1/4! - 1.0 / 120.0, // 1/5! - 1.0 / 720.0, // 1/6! - 1.0 / 5040.0, // 1/7! - 1.0 / 40320.0, // 1/8! - 1.0 / 362880.0, // 1/9! - 1.0 / 3628800.0, // 1/10! -}; - -/************************************************************************ - * Public Functions - ************************************************************************/ - -float expf(float x) -{ - size_t int_part; - bool invert; - float value; - float x0; - size_t i; - - if (x == 0) - { - return 1; - } - else if (x < 0) - { - invert = true; - x = -x; - } - else - { - invert = false; - } - - /* Extract integer component */ - - int_part = (size_t) x; - - /* set x to fractional component */ - - x -= (float)int_part; - - /* Perform Taylor series approximation with eleven terms */ - - value = 0.0; - x0 = 1.0; - for (i = 0; i < 10; i++) - { - value += x0 * _flt_inv_fact[i]; - x0 *= x; - } - - /* Multiply by exp of the integer component */ - - value *= lib_expi(int_part); - - if (invert) - { - return (1.0 / value); - } - else - { - return value; - } -} diff --git a/nuttx/libc/math/lib_expl.c b/nuttx/libc/math/lib_expl.c deleted file mode 100644 index 231faa35f..000000000 --- a/nuttx/libc/math/lib_expl.c +++ /dev/null @@ -1,126 +0,0 @@ -/************************************************************************ - * libc/math/lib_expl.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <sys/types.h> -#include <math.h> - -#include "lib_internal.h" - -#ifdef CONFIG_HAVE_LONG_DOUBLE - -/************************************************************************ - * Private Data - ************************************************************************/ - -static long double _ldbl_inv_fact[] = -{ - 1.0 / 1.0, // 1 / 0! - 1.0 / 1.0, // 1 / 1! - 1.0 / 2.0, // 1 / 2! - 1.0 / 6.0, // 1 / 3! - 1.0 / 24.0, // 1 / 4! - 1.0 / 120.0, // 1 / 5! - 1.0 / 720.0, // 1 / 6! - 1.0 / 5040.0, // 1 / 7! - 1.0 / 40320.0, // 1 / 8! - 1.0 / 362880.0, // 1 / 9! - 1.0 / 3628800.0, // 1 / 10! - 1.0 / 39916800.0, // 1 / 11! - 1.0 / 479001600.0, // 1 / 12! - 1.0 / 6227020800.0, // 1 / 13! - 1.0 / 87178291200.0, // 1 / 14! - 1.0 / 1307674368000.0, // 1 / 15! - 1.0 / 20922789888000.0, // 1 / 16! - 1.0 / 355687428096000.0, // 1 / 17! - 1.0 / 6402373705728000.0, // 1 / 18! -}; - -/************************************************************************ - * Public Functions - ************************************************************************/ - -long double expl(long double x) -{ - size_t int_part; - bool invert; - long double value; - long double x0; - size_t i; - - if (x == 0) - { - return 1; - } - else if (x < 0) - { - invert = true; - x = -x; - } - else - { - invert = false; - } - - /* Extract integer component */ - - int_part = (size_t) x; - - /* Set x to fractional component */ - - x -= (long double)int_part; - - /* Perform Taylor series approximation with nineteen terms */ - - value = 0.0; - x0 = 1.0; - for (i = 0; i < 19; i++) - { - value += x0 * _ldbl_inv_fact[i]; - x0 *= x; - } - - /* Multiply by exp of the integer component */ - - value *= lib_expi(int_part); - - if (invert) - { - return (1.0 / value); - } - else - { - return value; - } -} -#endif diff --git a/nuttx/libc/math/lib_fabs.c b/nuttx/libc/math/lib_fabs.c deleted file mode 100644 index 774755087..000000000 --- a/nuttx/libc/math/lib_fabs.c +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************ - * libc/math/lib_fabs.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_DOUBLE -double fabs(double x) -{ - return ((x < 0) ? -x : x); -} -#endif diff --git a/nuttx/libc/math/lib_fabsf.c b/nuttx/libc/math/lib_fabsf.c deleted file mode 100644 index 4c8ebae62..000000000 --- a/nuttx/libc/math/lib_fabsf.c +++ /dev/null @@ -1,41 +0,0 @@ -/************************************************************************ - * libc/math/lib_fabsf.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -float fabsf(float x) -{ - return ((x < 0) ? -x : x); -} diff --git a/nuttx/libc/math/lib_fabsl.c b/nuttx/libc/math/lib_fabsl.c deleted file mode 100644 index 96ac7d5db..000000000 --- a/nuttx/libc/math/lib_fabsl.c +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************ - * libc/math/lib_fabsl.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_LONG_DOUBLE -long double fabsl(long double x) -{ - return ((x < 0) ? -x : x); -} -#endif diff --git a/nuttx/libc/math/lib_floor.c b/nuttx/libc/math/lib_floor.c deleted file mode 100644 index 3330607ce..000000000 --- a/nuttx/libc/math/lib_floor.c +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************************************ - * libc/math/lib_floor.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_DOUBLE -double floor(double x) -{ - modf(x, &x); - if (x < 0.0) - { - x -= 1.0; - } - - return x; -} -#endif diff --git a/nuttx/libc/math/lib_floorf.c b/nuttx/libc/math/lib_floorf.c deleted file mode 100644 index 81483d4c9..000000000 --- a/nuttx/libc/math/lib_floorf.c +++ /dev/null @@ -1,47 +0,0 @@ -/************************************************************************ - * libc/math/lib_floorf.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -float floorf(float x) -{ - modff(x, &x); - if (x < 0.0) - { - x -= 1.0; - } - - return x; -} diff --git a/nuttx/libc/math/lib_floorl.c b/nuttx/libc/math/lib_floorl.c deleted file mode 100644 index 0d9ec43b4..000000000 --- a/nuttx/libc/math/lib_floorl.c +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************************************ - * libc/math/lib_floorl.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_LONG_DOUBLE -long double floorl(long double x) -{ - modfl(x, &x); - if (x < 0.0) - { - x -= 1.0; - } - - return x; -} -#endif diff --git a/nuttx/libc/math/lib_fmod.c b/nuttx/libc/math/lib_fmod.c deleted file mode 100644 index c66210cde..000000000 --- a/nuttx/libc/math/lib_fmod.c +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************************************ - * libc/math/lib_fmod.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_DOUBLE -double fmod(double x, double div) -{ - double n0; - - x /= div; - x = modf(x, &n0); - x *= div; - - return x; -} -#endif diff --git a/nuttx/libc/math/lib_fmodf.c b/nuttx/libc/math/lib_fmodf.c deleted file mode 100644 index d70bb791c..000000000 --- a/nuttx/libc/math/lib_fmodf.c +++ /dev/null @@ -1,47 +0,0 @@ -/************************************************************************ - * libc/math/lib_fmodf.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -float fmodf(float x, float div) -{ - float n0; - - x /= div; - x = modff(x, &n0); - x *= div; - - return x; -} diff --git a/nuttx/libc/math/lib_fmodl.c b/nuttx/libc/math/lib_fmodl.c deleted file mode 100644 index 1299bf6e8..000000000 --- a/nuttx/libc/math/lib_fmodl.c +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************************************ - * libc/math/lib_fmodl.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_LONG_DOUBLE -long double fmodl(long double x, long double div) -{ - long double n0; - - x /= div; - x = modfl(x, &n0); - x *= div; - - return x; -} -#endif diff --git a/nuttx/libc/math/lib_frexp.c b/nuttx/libc/math/lib_frexp.c deleted file mode 100644 index b9576dfd4..000000000 --- a/nuttx/libc/math/lib_frexp.c +++ /dev/null @@ -1,47 +0,0 @@ -/************************************************************************ - * libc/math/lib_frexp.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_DOUBLE -double frexp(double x, int *exponent) -{ - *exponent = (int)ceil(log2(x)); - return x / ldexp(1.0, *exponent); -} -#endif diff --git a/nuttx/libc/math/lib_frexpf.c b/nuttx/libc/math/lib_frexpf.c deleted file mode 100644 index d93ffb173..000000000 --- a/nuttx/libc/math/lib_frexpf.c +++ /dev/null @@ -1,42 +0,0 @@ -/************************************************************************ - * libc/math/lib_frexpf.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -float frexpf(float x, int *exponent) -{ - *exponent = (int)ceilf(log2f(x)); - return x / ldexpf(1.0, *exponent); -} diff --git a/nuttx/libc/math/lib_frexpl.c b/nuttx/libc/math/lib_frexpl.c deleted file mode 100644 index 90993b137..000000000 --- a/nuttx/libc/math/lib_frexpl.c +++ /dev/null @@ -1,47 +0,0 @@ -/************************************************************************ - * libc/math/lib_frexpl.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_LONG_DOUBLE -long double frexpl(long double x, int *exponent) -{ - *exponent = (int)ceill(log2(x)); - return x / ldexpl(1.0, *exponent); -} -#endif diff --git a/nuttx/libc/math/lib_ldexp.c b/nuttx/libc/math/lib_ldexp.c deleted file mode 100644 index 9b74d53d7..000000000 --- a/nuttx/libc/math/lib_ldexp.c +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************ - * libc/math/lib_ldexp.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_DOUBLE -double ldexp(double x, int n) -{ - return (x * pow(2.0, (double)n)); -} -#endif diff --git a/nuttx/libc/math/lib_ldexpf.c b/nuttx/libc/math/lib_ldexpf.c deleted file mode 100644 index f3aaf555b..000000000 --- a/nuttx/libc/math/lib_ldexpf.c +++ /dev/null @@ -1,41 +0,0 @@ -/************************************************************************ - * libc/math/lib_ldexpf.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -float ldexpf(float x, int n) -{ - return (x * powf(2.0, (float)n)); -} diff --git a/nuttx/libc/math/lib_ldexpl.c b/nuttx/libc/math/lib_ldexpl.c deleted file mode 100644 index 29764aaba..000000000 --- a/nuttx/libc/math/lib_ldexpl.c +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************ - * libc/math/lib_ldexpl.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_LONG_DOUBLE -long double ldexpl(long double x, int n) -{ - return (x * powl(2.0, (long double)n)); -} -#endif diff --git a/nuttx/libc/math/lib_libexpi.c b/nuttx/libc/math/lib_libexpi.c deleted file mode 100644 index 33ba537b1..000000000 --- a/nuttx/libc/math/lib_libexpi.c +++ /dev/null @@ -1,103 +0,0 @@ -/************************************************************************ - * libc/math/lib_libexpi.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <sys/types.h> -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -/************************************************************************ - * Pre-processor Definitions - ************************************************************************/ - -#define M_E2 (M_E * M_E) -#define M_E4 (M_E2 * M_E2) -#define M_E8 (M_E4 * M_E4) -#define M_E16 (M_E8 * M_E8) -#define M_E32 (M_E16 * M_E16) -#define M_E64 (M_E32 * M_E32) -#define M_E128 (M_E64 * M_E64) -#define M_E256 (M_E128 * M_E128) -#define M_E512 (M_E256 * M_E256) -#define M_E1024 (M_E512 * M_E512) - -/************************************************************************ - * Private Data - ************************************************************************/ - -static double _expi_square_tbl[11] = -{ - M_E, // e^1 - M_E2, // e^2 - M_E4, // e^4 - M_E8, // e^8 - M_E16, // e^16 - M_E32, // e^32 - M_E64, // e^64 - M_E128, // e^128 - M_E256, // e^256 - M_E512, // e^512 - M_E1024, // e^1024 -}; - -/************************************************************************ - * Public Functions - ************************************************************************/ - -double lib_expi(size_t n) -{ - size_t i; - double val; - - if (n > 1024) - { - return INFINITY; - } - - val = 1.0; - - for (i = 0; n; i++) - { - if (n & (1 << i)) - { - n &= ~(1 << i); - val *= _expi_square_tbl[i]; - } - } - - return val; -} - diff --git a/nuttx/libc/math/lib_libsqrtapprox.c b/nuttx/libc/math/lib_libsqrtapprox.c deleted file mode 100644 index b6a9b0d54..000000000 --- a/nuttx/libc/math/lib_libsqrtapprox.c +++ /dev/null @@ -1,50 +0,0 @@ -/************************************************************************ - * libc/math/lib_libsqrtapprox.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <stdint.h> -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -float lib_sqrtapprox(float x) -{ - int32_t i; - - /* Floats + bit manipulation = +inf fun! */ - - i = *((int32_t *) & x); - i = 0x1fc00000 + (i >> 1); - x = *((float *)&i); - - return x; -} diff --git a/nuttx/libc/math/lib_log.c b/nuttx/libc/math/lib_log.c deleted file mode 100644 index 7156f6b41..000000000 --- a/nuttx/libc/math/lib_log.c +++ /dev/null @@ -1,82 +0,0 @@ -/************************************************************************ - * libc/math/lib_log.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> -#include <float.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_DOUBLE -double log(double x) -{ - double y, y_old, ey, epsilon; - - y = 0.0; - y_old = 1.0; - epsilon = DBL_EPSILON; - - while (y > y_old + epsilon || y < y_old - epsilon) - { - y_old = y; - ey = exp(y); - y -= (ey - x) / ey; - - if (y > 700.0) - { - y = 700.0; - } - - if (y < -700.0) - { - y = -700.0; - } - - epsilon = (fabs(y) > 1.0) ? fabs(y) * DBL_EPSILON : DBL_EPSILON; - } - - if (y == 700.0) - { - return INFINITY; - } - - if (y == -700.0) - { - return INFINITY; - } - - return y; -} -#endif diff --git a/nuttx/libc/math/lib_log10.c b/nuttx/libc/math/lib_log10.c deleted file mode 100644 index 9daa91492..000000000 --- a/nuttx/libc/math/lib_log10.c +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************ - * libc/math/lib_log10.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_DOUBLE -double log10(double x) -{ - return (log(x) / M_LN10); -} -#endif diff --git a/nuttx/libc/math/lib_log10f.c b/nuttx/libc/math/lib_log10f.c deleted file mode 100644 index 778daedd5..000000000 --- a/nuttx/libc/math/lib_log10f.c +++ /dev/null @@ -1,41 +0,0 @@ -/************************************************************************ - * libc/math/lib_log10f.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -float log10f(float x) -{ - return (logf(x) / M_LN10); -} diff --git a/nuttx/libc/math/lib_log10l.c b/nuttx/libc/math/lib_log10l.c deleted file mode 100644 index efbeb721b..000000000 --- a/nuttx/libc/math/lib_log10l.c +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************ - * libc/math/lib_log10l.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_LONG_DOUBLE -long double log10l(long double x) -{ - return (logl(x) / M_LN10); -} -#endif diff --git a/nuttx/libc/math/lib_log2.c b/nuttx/libc/math/lib_log2.c deleted file mode 100644 index 4da39acdc..000000000 --- a/nuttx/libc/math/lib_log2.c +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************ - * libc/math/lib_log2.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_DOUBLE -double log2(double x) -{ - return (log(x) / M_LN2); -} -#endif diff --git a/nuttx/libc/math/lib_log2f.c b/nuttx/libc/math/lib_log2f.c deleted file mode 100644 index f514e5a9e..000000000 --- a/nuttx/libc/math/lib_log2f.c +++ /dev/null @@ -1,41 +0,0 @@ -/************************************************************************ - * libc/math/lib_log2f.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -float log2f(float x) -{ - return (logf(x) / M_LN2); -} diff --git a/nuttx/libc/math/lib_log2l.c b/nuttx/libc/math/lib_log2l.c deleted file mode 100644 index 21e80a930..000000000 --- a/nuttx/libc/math/lib_log2l.c +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************ - * libc/math/lib_log2l.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_LONG_DOUBLE -long double log2l(long double x) -{ - return (logl(x) / M_LN2); -} -#endif diff --git a/nuttx/libc/math/lib_logf.c b/nuttx/libc/math/lib_logf.c deleted file mode 100644 index 3815fef84..000000000 --- a/nuttx/libc/math/lib_logf.c +++ /dev/null @@ -1,77 +0,0 @@ -/************************************************************************ - * libc/math/lib_logf.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <math.h> -#include <float.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -float logf(float x) -{ - float y, y_old, ey, epsilon; - - y = 0.0; - y_old = 1.0; - epsilon = FLT_EPSILON; - - while (y > y_old + epsilon || y < y_old - epsilon) - { - y_old = y; - ey = exp(y); - y -= (ey - x) / ey; - - if (y > 700.0) - { - y = 700.0; - } - - if (y < -700.0) - { - y = -700.0; - } - - epsilon = (fabs(y) > 1.0) ? fabs(y) * FLT_EPSILON : FLT_EPSILON; - } - - if (y == 700.0) - { - return INFINITY; - } - - if (y == -700.0) - { - return INFINITY; - } - - return y; -} diff --git a/nuttx/libc/math/lib_logl.c b/nuttx/libc/math/lib_logl.c deleted file mode 100644 index 612816011..000000000 --- a/nuttx/libc/math/lib_logl.c +++ /dev/null @@ -1,80 +0,0 @@ -/************************************************************************ - * libc/math/lib_lol.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> -#include <float.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_LONG_DOUBLE -long double logl(long double x) -{ - long double y, y_old, ey, epsilon; - - y = 0.0; - y_old = 1.0; - epsilon = LDBL_EPSILON; - - while (y > y_old + epsilon || y < y_old - epsilon) - { - y_old = y; - ey = expl(y); - y -= (ey - x) / ey; - - if (y > 700.0) - { - y = 700.0; - } - - if (y < -700.0) - { - y = -700.0; - } - } - - if (y == 700.0) - { - return INFINITY; - } - - if (y == -700.0) - { - return INFINITY; - } - - return y; -} -#endif diff --git a/nuttx/libc/math/lib_modf.c b/nuttx/libc/math/lib_modf.c deleted file mode 100644 index f3f25f6fb..000000000 --- a/nuttx/libc/math/lib_modf.c +++ /dev/null @@ -1,58 +0,0 @@ -/************************************************************************ - * libc/math/lib_modf.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <stdint.h> -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_DOUBLE -double modf(double x, double *iptr) -{ - if (fabs(x) >= 4503599627370496.0) - { - *iptr = x; - return 0.0; - } - else if (fabs(x) < 1.0) - { - *iptr = 0.0; - return x; - } - else - { - *iptr = (double)(int64_t) x; - return (x - *iptr); - } -} -#endif diff --git a/nuttx/libc/math/lib_modff.c b/nuttx/libc/math/lib_modff.c deleted file mode 100644 index 28d3a3ae0..000000000 --- a/nuttx/libc/math/lib_modff.c +++ /dev/null @@ -1,55 +0,0 @@ -/************************************************************************ - * libc/math/lib_modff.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -float modff(float x, float *iptr) -{ - if (fabsf(x) >= 8388608.0) - { - *iptr = x; - return 0.0; - } - else if (fabs(x) < 1.0) - { - *iptr = 0.0; - return x; - } - else - { - *iptr = (float)(int)x; - return (x - *iptr); - } -} diff --git a/nuttx/libc/math/lib_modfl.c b/nuttx/libc/math/lib_modfl.c deleted file mode 100644 index 77bba0e0c..000000000 --- a/nuttx/libc/math/lib_modfl.c +++ /dev/null @@ -1,61 +0,0 @@ -/************************************************************************ - * libc/math/lib_modfl.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <stdint.h> -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_LONG_DOUBLE -long double modfl(long double x, long double *iptr) -{ - if (fabs(x) >= 4503599627370496.0) - { - *iptr = x; - return 0.0; - } - else if (fabs(x) < 1.0) - { - *iptr = 0.0; - return x; - } - else - { - *iptr = (long double)(int64_t) x; - return (x - *iptr); - } -} -#endif diff --git a/nuttx/libc/math/lib_pow.c b/nuttx/libc/math/lib_pow.c deleted file mode 100644 index a19d491fa..000000000 --- a/nuttx/libc/math/lib_pow.c +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************ - * libc/math/lib_pow.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_DOUBLE -double pow(double b, double e) -{ - return exp(e * log(b)); -} -#endif diff --git a/nuttx/libc/math/lib_powf.c b/nuttx/libc/math/lib_powf.c deleted file mode 100644 index 570904898..000000000 --- a/nuttx/libc/math/lib_powf.c +++ /dev/null @@ -1,41 +0,0 @@ -/************************************************************************ - * libc/math/lib_powf.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -float powf(float b, float e) -{ - return expf(e * logf(b)); -} diff --git a/nuttx/libc/math/lib_powl.c b/nuttx/libc/math/lib_powl.c deleted file mode 100644 index 81438217c..000000000 --- a/nuttx/libc/math/lib_powl.c +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************ - * libc/math/lib_powl.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_LONG_DOUBLE -long double powl(long double b, long double e) -{ - return expl(e * logl(b)); -} -#endif diff --git a/nuttx/libc/math/lib_round.c b/nuttx/libc/math/lib_round.c deleted file mode 100644 index 6191cee5b..000000000 --- a/nuttx/libc/math/lib_round.c +++ /dev/null @@ -1,40 +0,0 @@ -/************************************************************************ - * lib/math/lib_round.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * (C) 2012 Petteri Aimonen <jpa@nx.mail.kapsi.fi> - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_DOUBLE -double round(double x) -{ - double f = modf(x, &x); - if (x <= 0.0 && f <= -0.5) - { - x -= 1.0; - } - - if (x >= 0.0 && f >= 0.5) - { - x += 1.0; - } - - return x; -} -#endif diff --git a/nuttx/libc/math/lib_roundf.c b/nuttx/libc/math/lib_roundf.c deleted file mode 100644 index 145cf3df6..000000000 --- a/nuttx/libc/math/lib_roundf.c +++ /dev/null @@ -1,38 +0,0 @@ -/************************************************************************ - * lib/math/lib_roundf.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * (C) 2012 Petteri Aimonen <jpa@nx.mail.kapsi.fi> - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -float roundf(float x) -{ - float f = modff(x, &x); - if (x <= 0.0f && f <= -0.5f) - { - x -= 1.0f; - } - - if (x >= 0.0f && f >= 0.5f) - { - x += 1.0f; - } - - return x; -} diff --git a/nuttx/libc/math/lib_roundl.c b/nuttx/libc/math/lib_roundl.c deleted file mode 100644 index b2ddba670..000000000 --- a/nuttx/libc/math/lib_roundl.c +++ /dev/null @@ -1,40 +0,0 @@ -/************************************************************************ - * lib/math/lib_round.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * (C) 2012 Petteri Aimonen <jpa@nx.mail.kapsi.fi> - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_LONG_DOUBLE -long double roundl(long double x) -{ - long double f = modfl(x, &x); - if (x <= 0.0 && f <= -0.5) - { - x -= 1.0; - } - - if (x >= 0.0 && f >= 0.5) - { - x += 1.0; - } - - return x; -} -#endif diff --git a/nuttx/libc/math/lib_sin.c b/nuttx/libc/math/lib_sin.c deleted file mode 100644 index e005d98cb..000000000 --- a/nuttx/libc/math/lib_sin.c +++ /dev/null @@ -1,114 +0,0 @@ -/************************************************************************ - * libc/math/lib_sin.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <sys/types.h> -#include <math.h> - -#ifdef CONFIG_HAVE_DOUBLE - -/************************************************************************ - * Private Data - ************************************************************************/ - -static double _dbl_inv_fact[] = -{ - 1.0 / 1.0, // 1 / 1! - 1.0 / 6.0, // 1 / 3! - 1.0 / 120.0, // 1 / 5! - 1.0 / 5040.0, // 1 / 7! - 1.0 / 362880.0, // 1 / 9! - 1.0 / 39916800.0, // 1 / 11! - 1.0 / 6227020800.0, // 1 / 13! - 1.0 / 1307674368000.0, // 1 / 15! - 1.0 / 355687428096000.0, // 1 / 17! - 1.0 / 121645100408832000.0, // 1 / 19! -}; - -/************************************************************************ - * Public Functions - ************************************************************************/ - -double sin(double x) -{ - double x_squared; - double sin_x; - size_t i; - - /* Move x to [-pi, pi) */ - - x = fmod(x, 2 * M_PI); - if (x >= M_PI) - { - x -= 2 * M_PI; - } - - if (x < -M_PI) - { - x += 2 * M_PI; - } - - /* Move x to [-pi/2, pi/2) */ - - if (x >= M_PI_2) - { - x = M_PI - x; - } - - if (x < -M_PI_2) - { - x = -M_PI - x; - } - - x_squared = x * x; - sin_x = 0.0; - - /* Perform Taylor series approximation for sin(x) with ten terms */ - - for (i = 0; i < 10; i++) - { - if (i % 2 == 0) - { - sin_x += x * _dbl_inv_fact[i]; - } - else - { - sin_x -= x * _dbl_inv_fact[i]; - } - - x *= x_squared; - } - - return sin_x; -} -#endif diff --git a/nuttx/libc/math/lib_sinf.c b/nuttx/libc/math/lib_sinf.c deleted file mode 100644 index 9e493d8ef..000000000 --- a/nuttx/libc/math/lib_sinf.c +++ /dev/null @@ -1,104 +0,0 @@ -/************************************************************************ - * libc/math/lib_sinf.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <sys/types.h> -#include <math.h> - -/************************************************************************ - * Private Data - ************************************************************************/ - -static float _flt_inv_fact[] = -{ - 1.0 / 1.0, // 1 / 1! - 1.0 / 6.0, // 1 / 3! - 1.0 / 120.0, // 1 / 5! - 1.0 / 5040.0, // 1 / 7! - 1.0 / 362880.0, // 1 / 9! - 1.0 / 39916800.0, // 1 / 11! -}; - -/************************************************************************ - * Public Functions - ************************************************************************/ - -float sinf(float x) -{ - float x_squared; - float sin_x; - size_t i; - - /* Move x to [-pi, pi) */ - - x = fmodf(x, 2 * M_PI); - if (x >= M_PI) - { - x -= 2 * M_PI; - } - - if (x < -M_PI) - { - x += 2 * M_PI; - } - - /* Move x to [-pi/2, pi/2) */ - - if (x >= M_PI_2) - { - x = M_PI - x; - } - - if (x < -M_PI_2) - { - x = -M_PI - x; - } - - x_squared = x * x; - sin_x = 0.0; - - /* Perform Taylor series approximation for sin(x) with six terms */ - - for (i = 0; i < 6; i++) - { - if (i % 2 == 0) - { - sin_x += x * _flt_inv_fact[i]; - } - else - { - sin_x -= x * _flt_inv_fact[i]; - } - - x *= x_squared; - } - - return sin_x; -} diff --git a/nuttx/libc/math/lib_sinh.c b/nuttx/libc/math/lib_sinh.c deleted file mode 100644 index 0c3e2d11d..000000000 --- a/nuttx/libc/math/lib_sinh.c +++ /dev/null @@ -1,47 +0,0 @@ -/************************************************************************ - * libc/math/lib_sinh.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_DOUBLE -double sinh(double x) -{ - x = exp(x); - return ((x - (1.0 / x)) / 2.0); -} -#endif diff --git a/nuttx/libc/math/lib_sinhf.c b/nuttx/libc/math/lib_sinhf.c deleted file mode 100644 index e9d198440..000000000 --- a/nuttx/libc/math/lib_sinhf.c +++ /dev/null @@ -1,42 +0,0 @@ -/************************************************************************ - * libc/math/lib_sinhf.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -float sinhf(float x) -{ - x = expf(x); - return ((x - (1.0 / x)) / 2.0); -} diff --git a/nuttx/libc/math/lib_sinhl.c b/nuttx/libc/math/lib_sinhl.c deleted file mode 100644 index a1bcad81e..000000000 --- a/nuttx/libc/math/lib_sinhl.c +++ /dev/null @@ -1,47 +0,0 @@ -/************************************************************************ - * libc/math/lib_sinhl.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_LONG_DOUBLE -long double sinhl(long double x) -{ - x = expl(x); - return ((x - (1.0 / x)) / 2.0); -} -#endif diff --git a/nuttx/libc/math/lib_sinl.c b/nuttx/libc/math/lib_sinl.c deleted file mode 100644 index 6ed539a39..000000000 --- a/nuttx/libc/math/lib_sinl.c +++ /dev/null @@ -1,114 +0,0 @@ -/************************************************************************ - * libc/math/lib_sinl.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <sys/types.h> -#include <math.h> - -#ifdef CONFIG_HAVE_LONG_DOUBLE - -/************************************************************************ - * Private Data - ************************************************************************/ - -static long double _ldbl_inv_fact[] = -{ - 1.0 / 1.0, // 1 / 1! - 1.0 / 6.0, // 1 / 3! - 1.0 / 120.0, // 1 / 5! - 1.0 / 5040.0, // 1 / 7! - 1.0 / 362880.0, // 1 / 9! - 1.0 / 39916800.0, // 1 / 11! - 1.0 / 6227020800.0, // 1 / 13! - 1.0 / 1307674368000.0, // 1 / 15! - 1.0 / 355687428096000.0, // 1 / 17! - 1.0 / 121645100408832000.0, // 1 / 19! -}; - -/************************************************************************ - * Public Functions - ************************************************************************/ - -long double sinl(long double x) -{ - long double x_squared; - long double sin_x; - size_t i; - - /* Move x to [-pi, pi) */ - - x = fmodl(x, 2 * M_PI); - if (x >= M_PI) - { - x -= 2 * M_PI; - } - - if (x < -M_PI) - { - x += 2 * M_PI; - } - - /* Move x to [-pi/2, pi/2) */ - - if (x >= M_PI_2) - { - x = M_PI - x; - } - - if (x < -M_PI_2) - { - x = -M_PI - x; - } - - x_squared = x * x; - sin_x = 0.0; - - /* Perform Taylor series approximation for sin(x) with ten terms */ - - for (i = 0; i < 10; i++) - { - if (i % 2 == 0) - { - sin_x += x * _ldbl_inv_fact[i]; - } - else - { - sin_x -= x * _ldbl_inv_fact[i]; - } - - x *= x_squared; - } - - return sin_x; -} -#endif diff --git a/nuttx/libc/math/lib_sqrt.c b/nuttx/libc/math/lib_sqrt.c deleted file mode 100644 index e8a1c42ea..000000000 --- a/nuttx/libc/math/lib_sqrt.c +++ /dev/null @@ -1,99 +0,0 @@ -/************************************************************************ - * libc/math/lib_sqrt.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> -#include <errno.h> - -#include "lib_internal.h" - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_DOUBLE -double sqrt(double x) -{ - long double y, y1; - - if (x < 0.0) - { - errno = EDOM; - return NAN; - } - - if (isnan(x)) - { - return NAN; - } - - if (isinf(x)) - { - return INFINITY; - } - - if (x == 0.0) - { - return 0.0; - } - - /* Guess square root (using bit manipulation) */ - - y = lib_sqrtapprox(x); - - /* Perform four iterations of approximation. This number (4) is - * definitely optimal - */ - - y = 0.5 * (y + x / y); - y = 0.5 * (y + x / y); - y = 0.5 * (y + x / y); - y = 0.5 * (y + x / y); - - /* If guess was terribe (out of range of float). Repeat approximation - * until convergence. - */ - - if (y * y < x - 1.0 || y * y > x + 1.0) - { - y1 = -1.0; - while (y != y1) - { - y1 = y; - y = 0.5 * (y + x / y); - } - } - - return y; -} -#endif diff --git a/nuttx/libc/math/lib_sqrtf.c b/nuttx/libc/math/lib_sqrtf.c deleted file mode 100644 index cf45ccacc..000000000 --- a/nuttx/libc/math/lib_sqrtf.c +++ /dev/null @@ -1,84 +0,0 @@ -/************************************************************************ - * libc/math/lib_sqrtf.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> -#include <errno.h> - -#include "lib_internal.h" - -/************************************************************************ - * Public Functions - ************************************************************************/ - -float sqrtf(float x) -{ - float y; - - /* Filter out invalid/trivial inputs */ - - if (x < 0.0) - { - errno = EDOM; - return NAN; - } - - if (isnan(x)) - { - return NAN; - } - - if (isinf(x)) - { - return INFINITY; - } - - if (x == 0.0) - { - return 0.0; - } - - /* Guess square root (using bit manipulation) */ - - y = lib_sqrtapprox(x); - - /* Perform three iterations of approximation. This number (3) is - * definitely optimal - */ - - y = 0.5 * (y + x / y); - y = 0.5 * (y + x / y); - y = 0.5 * (y + x / y); - - return y; -} diff --git a/nuttx/libc/math/lib_sqrtl.c b/nuttx/libc/math/lib_sqrtl.c deleted file mode 100644 index 4035992fe..000000000 --- a/nuttx/libc/math/lib_sqrtl.c +++ /dev/null @@ -1,101 +0,0 @@ -/************************************************************************ - * libc/math/lib_sqrtl.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> -#include <errno.h> - -#include "lib_internal.h" - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_LONG_DOUBLE -long double sqrtl(long double x) -{ - long double y, y1; - - /* Filter out invalid/trivial inputs */ - - if (x < 0.0) - { - errno = EDOM; - return NAN; - } - - if (isnan(x)) - { - return NAN; - } - - if (isinf(x)) - { - return INFINITY; - } - - if (x == 0.0) - { - return 0.0; - } - - /* Guess square root (using bit manipulation) */ - - y = lib_sqrtapprox(x); - - /* Perform four iterations of approximation. This number (4) is - * definitely optimal - */ - - y = 0.5 * (y + x / y); - y = 0.5 * (y + x / y); - y = 0.5 * (y + x / y); - y = 0.5 * (y + x / y); - - /* If guess was terribe (out of range of float). Repeat approximation - * until convergence - */ - - if (y * y < x - 1.0 || y * y > x + 1.0) - { - y1 = -1.0; - while (y != y1) - { - y1 = y; - y = 0.5 * (y + x / y); - } - } - - return y; -} -#endif diff --git a/nuttx/libc/math/lib_tan.c b/nuttx/libc/math/lib_tan.c deleted file mode 100644 index 4c091c09b..000000000 --- a/nuttx/libc/math/lib_tan.c +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************ - * libc/math/lib_tan.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_DOUBLE -double tan(double x) -{ - return (sin(x) / cos(x)); -} -#endif diff --git a/nuttx/libc/math/lib_tanf.c b/nuttx/libc/math/lib_tanf.c deleted file mode 100644 index 0c9110a0b..000000000 --- a/nuttx/libc/math/lib_tanf.c +++ /dev/null @@ -1,41 +0,0 @@ -/************************************************************************ - * libc/math/lib_tanf.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -float tanf(float x) -{ - return (sinf(x) / cosf(x)); -} diff --git a/nuttx/libc/math/lib_tanh.c b/nuttx/libc/math/lib_tanh.c deleted file mode 100644 index 3b9ea0f41..000000000 --- a/nuttx/libc/math/lib_tanh.c +++ /dev/null @@ -1,49 +0,0 @@ -/************************************************************************ - * libc/math/lib_tanh.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_DOUBLE -double tanh(double x) -{ - double x0 = exp(x); - double x1 = 1.0 / x0; - - return ((x0 + x1) / (x0 - x1)); -} -#endif diff --git a/nuttx/libc/math/lib_tanhf.c b/nuttx/libc/math/lib_tanhf.c deleted file mode 100644 index 43d418204..000000000 --- a/nuttx/libc/math/lib_tanhf.c +++ /dev/null @@ -1,44 +0,0 @@ -/************************************************************************ - * libc/math/lib_tanhf.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -float tanhf(float x) -{ - float x0 = expf(x); - float x1 = 1.0 / x0; - - return ((x0 + x1) / (x0 - x1)); -} diff --git a/nuttx/libc/math/lib_tanhl.c b/nuttx/libc/math/lib_tanhl.c deleted file mode 100644 index 5aafd1e7b..000000000 --- a/nuttx/libc/math/lib_tanhl.c +++ /dev/null @@ -1,49 +0,0 @@ -/************************************************************************ - * libc/math/lib_tanhl.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_LONG_DOUBLE -long double tanhl(long double x) -{ - long double x0 = exp(x); - long double x1 = 1.0 / x0; - - return ((x0 + x1) / (x0 - x1)); -} -#endif diff --git a/nuttx/libc/math/lib_tanl.c b/nuttx/libc/math/lib_tanl.c deleted file mode 100644 index e77abe0f1..000000000 --- a/nuttx/libc/math/lib_tanl.c +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************ - * libc/math/lib_tanl.c - * - * This file is a part of NuttX: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Ported by: Darcy Gong - * - * It derives from the Rhombs OS math library by Nick Johnson which has - * a compatibile, MIT-style license: - * - * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> - * - * Permission to use, copy, modify, and 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. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <math.h> - -/************************************************************************ - * Public Functions - ************************************************************************/ - -#ifdef CONFIG_HAVE_LONG_DOUBLE -long double tanl(long double x) -{ - return (sinl(x) / cosl(x)); -} -#endif |