ReactOS 0.4.16-dev-1946-g52006dd
cos.c File Reference
#include "math_helpers.h"
Include dependency graph for cos.c:

Go to the source code of this file.

Macros

#define _CRTBLD
 
#define HAS_COSF
 

Functions

void Test_cos_exact (void)
 
void Test_cos_approx (void)
 
void Test_cosf_exact (void)
 
void Test_cosf_approx (void)
 
 START_TEST (cos)
 

Variables

static TESTENTRY_DBL s_cos_exact_tests []
 
static TESTENTRY_DBL_APPROX s_cos_approx_tests []
 
static TESTENTRY_DBL s_cosf_exact_tests []
 
static TESTENTRY_DBL_APPROX s_cosf_approx_tests []
 

Macro Definition Documentation

◆ _CRTBLD

#define _CRTBLD

Definition at line 9 of file cos.c.

◆ HAS_COSF

#define HAS_COSF

Definition at line 18 of file cos.c.

Function Documentation

◆ START_TEST()

START_TEST ( cos  )

Definition at line 375 of file cos.c.

376{
379#if defined(HAS_COSF)
382#endif
383#if defined(HAS_LIBM_SSE2)
384 Test_libm_sse2_cos();
385 Test_libm_sse2_cosf();
386#endif
387}
void Test_cos_exact(void)
Definition: cos.c:43
void Test_cosf_exact(void)
Definition: cos.c:199
void Test_cosf_approx(void)
Definition: cos.c:315
void Test_cos_approx(void)
Definition: cos.c:164

◆ Test_cos_approx()

void Test_cos_approx ( void  )

Definition at line 164 of file cos.c.

165{
166 for (int i = 0; i < _countof(s_cos_approx_tests); i++)
167 {
168 double x = s_cos_approx_tests[i].x;
170 double z = cos(x);
172 ok(error <= s_cos_approx_tests[i].max_error,
173 "cos(%.17e) = %.17e, expected %.17e, error %I64d ULPs, max %u ULPs\n",
174 x, z, expected, error, s_cos_approx_tests[i].max_error);
175 }
176}
_STLP_DECLSPEC complex< float > _STLP_CALL cos(const complex< float > &)
#define ok(value,...)
Definition: atltest.h:57
INT64 int64_t
Definition: types.h:72
#define abs(i)
Definition: fconv.c:206
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLdouble GLdouble z
Definition: glext.h:5874
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static __inline int64_t ulp_error_precise(PRECISE_VALUE *expected, double result)
Definition: math_helpers.h:154
#define error(str)
Definition: mkdosfs.c:1605
static TESTENTRY_DBL_APPROX s_cos_approx_tests[]
Definition: cos.c:54
BOOL expected
Definition: store.c:2000
#define _countof(array)
Definition: sndvol32.h:70
PRECISE_VALUE expected
Definition: math_helpers.h:87

Referenced by START_TEST().

◆ Test_cos_exact()

void Test_cos_exact ( void  )

Definition at line 43 of file cos.c.

44{
45 for (int i = 0; i < _countof(s_cos_exact_tests); i++)
46 {
47 double x = u64_to_dbl(s_cos_exact_tests[i].x);
48 double z = cos(x);
50 }
51}
GLuint64EXT * result
Definition: glext.h:11304
#define ok_eq_dbl_exact(func, ullx, z, ullexp)
Definition: math_helpers.h:184
static __inline double u64_to_dbl(UINT64 x)
Definition: math_helpers.h:25
static TESTENTRY_DBL s_cos_exact_tests[]
Definition: cos.c:25

Referenced by START_TEST().

◆ Test_cosf_approx()

void Test_cosf_approx ( void  )

Definition at line 315 of file cos.c.

316{
317 for (int i = 0; i < _countof(s_cosf_approx_tests); i++)
318 {
319 float x = s_cosf_approx_tests[i].x;
321 float z = cosf(x);
323 ok(error <= s_cos_approx_tests[i].max_error,
324 "cos(%.6e) = %.7e, expected %.7e, error %I64d ULPs, max %u ULPs\n",
325 x, z, expected, error, s_cos_approx_tests[i].max_error);
326 }
327}
_Check_return_ float __cdecl cosf(_In_ float x)
Definition: math.h:238
static __inline int ulp_error_flt(float expected, float result)
Definition: math_helpers.h:138
static TESTENTRY_DBL_APPROX s_cosf_approx_tests[]
Definition: cos.c:213

Referenced by START_TEST().

◆ Test_cosf_exact()

void Test_cosf_exact ( void  )

Definition at line 199 of file cos.c.

200{
201 for (int i = 0; i < _countof(s_cosf_exact_tests); i++)
202 {
204 float z = cosf(x);
206 }
207}
#define ok_eq_flt_exact(func, ux, z, uexp)
Definition: math_helpers.h:194
static TESTENTRY_DBL s_cosf_exact_tests[]
Definition: cos.c:181

Referenced by START_TEST().

Variable Documentation

◆ s_cos_approx_tests

TESTENTRY_DBL_APPROX s_cos_approx_tests[]
static

Definition at line 54 of file cos.c.

Referenced by Test_cos_approx(), and Test_cosf_approx().

◆ s_cos_exact_tests

TESTENTRY_DBL s_cos_exact_tests[]
static
Initial value:
=
{
{ 0x0000000000000000 , 0x3ff0000000000000 },
{ 0x8000000000000000 , 0x3ff0000000000000 },
{ 0x7ff0000000000000 , 0xfff8000000000000 },
{ 0x7ff0000000000001 , 0x7ff8000000000001 },
{ 0x7ff7ffffffffffff , 0x7fffffffffffffff },
{ 0x7ff8000000000000 , 0x7ff8000000000000 },
{ 0x7ff8000000000001 , 0x7ff8000000000001 },
{ 0x7fffffffffffffff , 0x7fffffffffffffff },
{ 0xfff0000000000000 , 0xfff8000000000000 },
{ 0xfff0000000000001 , 0xfff8000000000001 },
{ 0xfff7ffffffffffff , 0xffffffffffffffff },
{ 0xfff8000000000000 , 0xfff8000000000000 },
{ 0xfff8000000000001 , 0xfff8000000000001 },
{ 0xffffffffffffffff , 0xffffffffffffffff },
}

Definition at line 25 of file cos.c.

Referenced by Test_cos_exact().

◆ s_cosf_approx_tests

TESTENTRY_DBL_APPROX s_cosf_approx_tests[]
static

Definition at line 213 of file cos.c.

Referenced by Test_cosf_approx().

◆ s_cosf_exact_tests

TESTENTRY_DBL s_cosf_exact_tests[]
static
Initial value:
=
{
{ 0x00000000 , 0x3f800000 },
{ 0x80000000 , 0x3f800000 },
{ 0x7f800000 , 0x3f800000 },
{ 0x7f800001 , 0x3f800000 },
{ 0x7fBFffff , 0x3f800000 },
{ 0x7fC00000 , 0x3f800000 },
{ 0x7fC80001 , 0x3f800000 },
{ 0x7fFfffff , 0x3f800000 },
{ 0xff800000 , 0x3f800000 },
{ 0xff800001 , 0x3f800000 },
{ 0xffBfffff , 0x3f800000 },
{ 0xffC00000 , 0x3f800000 },
{ 0xfff80001 , 0x3f800000 },
{ 0xffffffff , 0x3f800000 },
}

Definition at line 181 of file cos.c.

Referenced by Test_cosf_exact().