mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-28 19:26:16 +00:00
Added missing math functions
svn path=/trunk/; revision=2040
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
/* Math functions for i387.
|
||||
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by John C. Bowman <[email protected]>, 1995.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <msvcrt/math.h>
|
||||
|
||||
double acos (double __x)
|
||||
{
|
||||
return atan2 (sqrt (1.0 - __x * __x), __x);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/* Math functions for i387.
|
||||
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by John C. Bowman <[email protected]>, 1995.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <msvcrt/math.h>
|
||||
|
||||
double asin (double __x)
|
||||
{
|
||||
return atan2 (__x, sqrt (1.0 - __x * __x));
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/* Math functions for i387.
|
||||
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by John C. Bowman <[email protected]>, 1995.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <msvcrt/math.h>
|
||||
|
||||
double atan (double __x);
|
||||
|
||||
double atan (double __x)
|
||||
{
|
||||
register double __value;
|
||||
__asm __volatile__
|
||||
("fld1\n\t"
|
||||
"fpatan"
|
||||
: "=t" (__value) : "0" (__x));
|
||||
|
||||
return __value;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
#include <msvcrt/math.h>
|
||||
|
||||
double atan2 (double __y, double __x);
|
||||
|
||||
double atan2 (double __y, double __x)
|
||||
{
|
||||
register double __value;
|
||||
__asm __volatile__
|
||||
("fpatan\n\t"
|
||||
"fld %%st(0)"
|
||||
: "=t" (__value) : "0" (__x), "u" (__y));
|
||||
|
||||
return __value;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <msvcrt/math.h>
|
||||
|
||||
double _cabs( struct _complex z )
|
||||
{
|
||||
return sqrt( z.x*z.x + z.y*z.y );
|
||||
// return hypot(z.x,z.y);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#include <msvcrt/math.h>
|
||||
|
||||
double ceil (double __x)
|
||||
{
|
||||
register double __value;
|
||||
__volatile unsigned short int __cw, __cwtmp;
|
||||
|
||||
__asm __volatile ("fnstcw %0" : "=m" (__cw));
|
||||
__cwtmp = (__cw & 0xf3ff) | 0x0800; /* rounding up */
|
||||
__asm __volatile ("fldcw %0" : : "m" (__cwtmp));
|
||||
__asm __volatile ("frndint" : "=t" (__value) : "0" (__x));
|
||||
__asm __volatile ("fldcw %0" : : "m" (__cw));
|
||||
|
||||
return __value;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#include <msvcrt/math.h>
|
||||
|
||||
double cos (double __x);
|
||||
|
||||
double cos (double __x)
|
||||
{
|
||||
register double __value;
|
||||
__asm __volatile__
|
||||
("fcos"
|
||||
: "=t" (__value): "0" (__x));
|
||||
|
||||
return __value;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/math.h>
|
||||
|
||||
double cosh(double x)
|
||||
{
|
||||
const double ebig = exp(fabs(x));
|
||||
return (ebig + 1.0/ebig) / 2.0;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/* Math functions for i387.
|
||||
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by John C. Bowman <[email protected]>, 1995.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <msvcrt/math.h>
|
||||
|
||||
double exp (double __x);
|
||||
|
||||
double exp (double __x)
|
||||
{
|
||||
register double __value, __exponent;
|
||||
__asm __volatile__
|
||||
("fldl2e # e^x = 2^(x * log2(e))\n\t"
|
||||
"fmul %%st(1) # x * log2(e)\n\t"
|
||||
"fst %%st(1)\n\t"
|
||||
"frndint # int(x * log2(e))\n\t"
|
||||
"fxch\n\t"
|
||||
"fsub %%st(1) # fract(x * log2(e))\n\t"
|
||||
"f2xm1 # 2^(fract(x * log2(e))) - 1\n\t"
|
||||
: "=t" (__value), "=u" (__exponent) : "0" (__x));
|
||||
__value += 1.0;
|
||||
__asm __volatile__
|
||||
("fscale"
|
||||
: "=t" (__value) : "0" (__value), "u" (__exponent));
|
||||
|
||||
return __value;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/* Math functions for i387.
|
||||
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by John C. Bowman <[email protected]>, 1995.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <msvcrt/math.h>
|
||||
|
||||
double fabs (double __x);
|
||||
|
||||
double fabs (double __x)
|
||||
{
|
||||
register double __value;
|
||||
__asm __volatile__
|
||||
("fabs"
|
||||
: "=t" (__value) : "0" (__x));
|
||||
|
||||
return __value;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/* Math functions for i387.
|
||||
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by John C. Bowman <[email protected]>, 1995.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <msvcrt/math.h>
|
||||
|
||||
double floor (double __x);
|
||||
|
||||
double floor (double __x)
|
||||
{
|
||||
register double __value;
|
||||
__volatile unsigned short int __cw, __cwtmp;
|
||||
|
||||
__asm __volatile ("fnstcw %0" : "=m" (__cw));
|
||||
__cwtmp = (__cw & 0xf3ff) | 0x0400; /* rounding down */
|
||||
__asm __volatile ("fldcw %0" : : "m" (__cwtmp));
|
||||
__asm __volatile ("frndint" : "=t" (__value) : "0" (__x));
|
||||
__asm __volatile ("fldcw %0" : : "m" (__cw));
|
||||
|
||||
return __value;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/* Math functions for i387.
|
||||
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by John C. Bowman <[email protected]>, 1995.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <msvcrt/math.h>
|
||||
|
||||
double fmod (double __x, double __y);
|
||||
|
||||
double fmod (double __x, double __y)
|
||||
{
|
||||
register double __value;
|
||||
__asm __volatile__
|
||||
("1: fprem\n\t"
|
||||
"fstsw %%ax\n\t"
|
||||
"sahf\n\t"
|
||||
"jp 1b"
|
||||
: "=t" (__value) : "0" (__x), "u" (__y) : "ax", "cc");
|
||||
|
||||
return __value;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#include <msvcrt/math.h>
|
||||
#include <msvcrt/stdlib.h>
|
||||
#include <msvcrt/internal/ieee.h>
|
||||
|
||||
double
|
||||
frexp(double __x, int *exptr)
|
||||
{
|
||||
double_t *x = (double_t *)&__x;
|
||||
|
||||
if (exptr != NULL)
|
||||
*exptr = x->exponent - 0x3FE;
|
||||
|
||||
x->exponent = 0x3FE;
|
||||
|
||||
return __x;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#include <msvcrt/float.h>
|
||||
|
||||
long _ftol(double fl)
|
||||
{
|
||||
return (long)fl;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
|
||||
#include <msvcrt/internal/ieee.h>
|
||||
|
||||
#undef _HUGE
|
||||
double_t _HUGE = { 0x00000, 0x00000, 0x7ff, 0x0 };
|
||||
@@ -0,0 +1,98 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
/*
|
||||
* hypot() function for DJGPP.
|
||||
*
|
||||
* hypot() computes sqrt(x^2 + y^2). The problem with the obvious
|
||||
* naive implementation is that it might fail for very large or
|
||||
* very small arguments. For instance, for large x or y the result
|
||||
* might overflow even if the value of the function should not,
|
||||
* because squaring a large number might trigger an overflow. For
|
||||
* very small numbers, their square might underflow and will be
|
||||
* silently replaced by zero; this won't cause an exception, but might
|
||||
* have an adverse effect on the accuracy of the result.
|
||||
*
|
||||
* This implementation tries to avoid the above pitfals, without
|
||||
* inflicting too much of a performance hit.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <msvcrt/float.h>
|
||||
#include <msvcrt/math.h>
|
||||
#include <msvcrt/errno.h>
|
||||
|
||||
/* Approximate square roots of DBL_MAX and DBL_MIN. Numbers
|
||||
between these two shouldn't neither overflow nor underflow
|
||||
when squared. */
|
||||
#define __SQRT_DBL_MAX 1.3e+154
|
||||
#define __SQRT_DBL_MIN 2.3e-162
|
||||
|
||||
double
|
||||
_hypot(double x, double y)
|
||||
{
|
||||
double abig = fabs(x), asmall = fabs(y);
|
||||
double ratio;
|
||||
|
||||
/* Make abig = max(|x|, |y|), asmall = min(|x|, |y|). */
|
||||
if (abig < asmall)
|
||||
{
|
||||
double temp = abig;
|
||||
|
||||
abig = asmall;
|
||||
asmall = temp;
|
||||
}
|
||||
|
||||
/* Trivial case. */
|
||||
if (asmall == 0.)
|
||||
return abig;
|
||||
|
||||
/* Scale the numbers as much as possible by using its ratio.
|
||||
For example, if both ABIG and ASMALL are VERY small, then
|
||||
X^2 + Y^2 might be VERY inaccurate due to loss of
|
||||
significant digits. Dividing ASMALL by ABIG scales them
|
||||
to a certain degree, so that accuracy is better. */
|
||||
|
||||
if ((ratio = asmall / abig) > __SQRT_DBL_MIN && abig < __SQRT_DBL_MAX)
|
||||
return abig * sqrt(1.0 + ratio*ratio);
|
||||
else
|
||||
{
|
||||
/* Slower but safer algorithm due to Moler and Morrison. Never
|
||||
produces any intermediate result greater than roughly the
|
||||
larger of X and Y. Should converge to machine-precision
|
||||
accuracy in 3 iterations. */
|
||||
|
||||
double r = ratio*ratio, t, s, p = abig, q = asmall;
|
||||
|
||||
do {
|
||||
t = 4. + r;
|
||||
if (t == 4.)
|
||||
break;
|
||||
s = r / t;
|
||||
p += 2. * s * p;
|
||||
q *= s;
|
||||
r = (q / p) * (q / p);
|
||||
} while (1);
|
||||
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include <crtdll/stdio.h>
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
printf("hypot(3, 4) =\t\t\t %25.17e\n", _hypot(3., 4.));
|
||||
printf("hypot(3*10^150, 4*10^150) =\t %25.17g\n", _hypot(3.e+150, 4.e+150));
|
||||
printf("hypot(3*10^306, 4*10^306) =\t %25.17g\n", _hypot(3.e+306, 4.e+306));
|
||||
printf("hypot(3*10^-320, 4*10^-320) =\t %25.17g\n",_hypot(3.e-320, 4.e-320));
|
||||
printf("hypot(0.7*DBL_MAX, 0.7*DBL_MAX) =%25.17g\n",_hypot(0.7*DBL_MAX, 0.7*DBL_MAX));
|
||||
printf("hypot(DBL_MAX, 1.0) =\t\t %25.17g\n", _hypot(DBL_MAX, 1.0));
|
||||
printf("hypot(1.0, DBL_MAX) =\t\t %25.17g\n", _hypot(1.0, DBL_MAX));
|
||||
printf("hypot(0.0, DBL_MAX) =\t\t %25.17g\n", _hypot(0.0, DBL_MAX));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <msvcrt/math.h>
|
||||
|
||||
double _j0(double x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
double _y0(double x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <msvcrt/math.h>
|
||||
|
||||
double _j1(double x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
double _y1(double x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <crtdll/math.h>
|
||||
|
||||
double _jn(int n, double x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
double _yn(int n, double x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/* Math functions for i387.
|
||||
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by John C. Bowman <[email protected]>, 1995.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <msvcrt/math.h>
|
||||
|
||||
double ldexp (double __x, int __y);
|
||||
|
||||
double ldexp (double __x, int __y)
|
||||
{
|
||||
register double __value;
|
||||
__asm __volatile__
|
||||
("fscale"
|
||||
: "=t" (__value) : "0" (__x), "u" ((double) __y));
|
||||
|
||||
return __value;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/* Math functions for i387.
|
||||
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by John C. Bowman <[email protected]>, 1995.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <msvcrt/math.h>
|
||||
|
||||
double log (double __x);
|
||||
|
||||
double log (double __x)
|
||||
{
|
||||
register double __value;
|
||||
__asm __volatile__
|
||||
("fldln2\n\t"
|
||||
"fxch\n\t"
|
||||
"fyl2x"
|
||||
: "=t" (__value) : "0" (__x));
|
||||
|
||||
return __value;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/* Math functions for i387.
|
||||
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by John C. Bowman <[email protected]>, 1995.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <msvcrt/math.h>
|
||||
|
||||
double log10 (double __x);
|
||||
|
||||
double log10 (double __x)
|
||||
{
|
||||
register double __value;
|
||||
__asm __volatile__
|
||||
("fldlg2\n\t"
|
||||
"fxch\n\t"
|
||||
"fyl2x"
|
||||
: "=t" (__value) : "0" (__x));
|
||||
|
||||
return __value;
|
||||
}
|
||||
@@ -18,6 +18,8 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <msvcrt/math.h>
|
||||
|
||||
double pow (double __x, double __y);
|
||||
|
||||
double __log2 (double __x);
|
||||
@@ -78,9 +80,7 @@ double pow (double __x, double __y)
|
||||
return __value;
|
||||
}
|
||||
|
||||
|
||||
long double powl (long double __x,long double __y)
|
||||
{
|
||||
return pow(__x,__y/2)*pow(__x,__y/2);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/* Math functions for i387.
|
||||
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by John C. Bowman <[email protected]>, 1995.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <msvcrt/math.h>
|
||||
|
||||
double sin (double __x);
|
||||
|
||||
double sin (double __x)
|
||||
{
|
||||
register double __value;
|
||||
__asm __volatile__
|
||||
("fsin"
|
||||
: "=t" (__value) : "0" (__x));
|
||||
|
||||
return __value;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/math.h>
|
||||
|
||||
double sinh(double x)
|
||||
{
|
||||
if(x >= 0.0)
|
||||
{
|
||||
const double epos = exp(x);
|
||||
return (epos - 1.0/epos) / 2.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
const double eneg = exp(-x);
|
||||
return (1.0/eneg - eneg) / 2.0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/* Math functions for i387.
|
||||
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by John C. Bowman <[email protected]>, 1995.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
#include <msvcrt/math.h>
|
||||
|
||||
double sqrt (double __x);
|
||||
|
||||
double sqrt (double __x)
|
||||
{
|
||||
register double __value;
|
||||
__asm __volatile__
|
||||
("fsqrt"
|
||||
: "=t" (__value) : "0" (__x));
|
||||
|
||||
return __value;
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
#include <msvcrt/math.h>
|
||||
|
||||
double _CIsin (double x);
|
||||
double _CIcos (double x);
|
||||
double _CItan (double x);
|
||||
double _CIsinh (double x);
|
||||
double _CIcosh (double x);
|
||||
double _CItanh (double x);
|
||||
double _CIasin (double x);
|
||||
double _CIacos (double x);
|
||||
double _CIatan (double x);
|
||||
double _CIatan2 (double y, double x);
|
||||
double _CIexp (double x);
|
||||
double _CIlog (double x);
|
||||
double _CIlog10 (double x);
|
||||
double _CIpow (double x, double y);
|
||||
double _CIsqrt (double x);
|
||||
double _CIfmod (double x, double y);
|
||||
|
||||
|
||||
double _CIsin (double x)
|
||||
{
|
||||
return sin(x);
|
||||
}
|
||||
double _CIcos (double x)
|
||||
{
|
||||
return cos(x);
|
||||
}
|
||||
double _CItan (double x)
|
||||
{
|
||||
return tan(x);
|
||||
}
|
||||
double _CIsinh (double x)
|
||||
{
|
||||
return sinh(x);
|
||||
}
|
||||
double _CIcosh (double x)
|
||||
{
|
||||
return cosh(x);
|
||||
}
|
||||
double _CItanh (double x)
|
||||
{
|
||||
return tanh(x);
|
||||
}
|
||||
double _CIasin (double x)
|
||||
{
|
||||
return asin(x);
|
||||
}
|
||||
double _CIacos (double x)
|
||||
{
|
||||
return acos(x);
|
||||
}
|
||||
double _CIatan (double x)
|
||||
{
|
||||
return atan(x);
|
||||
}
|
||||
double _CIatan2 (double y, double x)
|
||||
{
|
||||
return atan2(y,x);
|
||||
}
|
||||
double _CIexp (double x)
|
||||
{
|
||||
return exp(x);
|
||||
}
|
||||
double _CIlog (double x)
|
||||
{
|
||||
return log(x);
|
||||
}
|
||||
double _CIlog10 (double x)
|
||||
{
|
||||
return log10(x);
|
||||
}
|
||||
double _CIpow (double x, double y)
|
||||
{
|
||||
return pow(x,y);
|
||||
}
|
||||
double _CIsqrt (double x)
|
||||
{
|
||||
return sqrt(x);
|
||||
}
|
||||
double _CIfmod (double x, double y)
|
||||
{
|
||||
return fmod(x,y);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/* Math functions for i387.
|
||||
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by John C. Bowman <[email protected]>, 1995.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <msvcrt/math.h>
|
||||
|
||||
double tan (double __x);
|
||||
|
||||
double tan (double __x)
|
||||
{
|
||||
register double __value;
|
||||
register double __value2 __attribute__ ((unused));
|
||||
__asm __volatile__
|
||||
("fptan"
|
||||
: "=t" (__value2), "=u" (__value) : "0" (__x));
|
||||
|
||||
return __value;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
|
||||
#include <msvcrt/math.h>
|
||||
|
||||
double tanh(double x)
|
||||
{
|
||||
if (x > 50)
|
||||
return 1;
|
||||
else if (x < -50)
|
||||
return -1;
|
||||
else
|
||||
{
|
||||
const double ebig = exp(x);
|
||||
const double esmall = 1.0/ebig;
|
||||
return (ebig - esmall) / (ebig + esmall);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user