mirror of
https://github.com/VSadov/Satori.git
synced 2025-06-09 17:44:48 +09:00
Remove CoreCLR math.h CRT PAL Redefines (#98048)
This commit is contained in:
parent
304cedfbf8
commit
0ce3c32f6c
82 changed files with 187 additions and 9516 deletions
|
@ -58,15 +58,6 @@ if(DARWIN)
|
|||
set_cache_value(HAVE_CLOCK_REALTIME_EXITCODE 0)
|
||||
set_cache_value(HAVE_CLOCK_THREAD_CPUTIME_EXITCODE 0)
|
||||
set_cache_value(HAVE_CLOCK_GETTIME_NSEC_NP_EXITCODE 0)
|
||||
set_cache_value(HAVE_COMPATIBLE_ACOS_EXITCODE 0)
|
||||
set_cache_value(HAVE_COMPATIBLE_ASIN_EXITCODE 0)
|
||||
set_cache_value(HAVE_COMPATIBLE_ATAN2_EXITCODE 0)
|
||||
set_cache_value(HAVE_COMPATIBLE_EXP_EXITCODE 1)
|
||||
set_cache_value(HAVE_COMPATIBLE_ILOGB0_EXITCODE 0)
|
||||
set_cache_value(HAVE_COMPATIBLE_ILOGBNAN_EXITCODE 1)
|
||||
set_cache_value(HAVE_COMPATIBLE_LOG10_EXITCODE 0)
|
||||
set_cache_value(HAVE_COMPATIBLE_LOG_EXITCODE 0)
|
||||
set_cache_value(HAVE_COMPATIBLE_POW_EXITCODE 0)
|
||||
set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 1)
|
||||
set_cache_value(HAVE_LARGE_SNPRINTF_SUPPORT_EXITCODE 0)
|
||||
set_cache_value(HAVE_MMAP_DEV_ZERO_EXITCODE 1)
|
||||
|
@ -75,8 +66,6 @@ if(DARWIN)
|
|||
set_cache_value(HAVE_PROCFS_STATM_EXITCODE 1)
|
||||
set_cache_value(HAVE_SCHED_GETCPU_EXITCODE 1)
|
||||
set_cache_value(HAVE_SCHED_GET_PRIORITY_EXITCODE 0)
|
||||
set_cache_value(HAVE_VALID_NEGATIVE_INF_POW_EXITCODE 0)
|
||||
set_cache_value(HAVE_VALID_POSITIVE_INF_POW_EXITCODE 0)
|
||||
set_cache_value(HAVE_WORKING_CLOCK_GETTIME_EXITCODE 0)
|
||||
set_cache_value(HAVE_WORKING_GETTIMEOFDAY_EXITCODE 0)
|
||||
set_cache_value(MMAP_ANON_IGNORES_PROTECTION_EXITCODE 1)
|
||||
|
@ -97,14 +86,6 @@ elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|armv6|arm64|loongarch64|riscv64|s39
|
|||
set_cache_value(HAVE_CLOCK_MONOTONIC_EXITCODE 0)
|
||||
set_cache_value(HAVE_CLOCK_REALTIME_EXITCODE 0)
|
||||
set_cache_value(HAVE_CLOCK_THREAD_CPUTIME_EXITCODE 0)
|
||||
set_cache_value(HAVE_COMPATIBLE_ACOS_EXITCODE 0)
|
||||
set_cache_value(HAVE_COMPATIBLE_ASIN_EXITCODE 0)
|
||||
set_cache_value(HAVE_COMPATIBLE_ATAN2_EXITCODE 0)
|
||||
set_cache_value(HAVE_COMPATIBLE_ILOGB0_EXITCODE 1)
|
||||
set_cache_value(HAVE_COMPATIBLE_ILOGBNAN_EXITCODE 1)
|
||||
set_cache_value(HAVE_COMPATIBLE_LOG10_EXITCODE 0)
|
||||
set_cache_value(HAVE_COMPATIBLE_LOG_EXITCODE 0)
|
||||
set_cache_value(HAVE_COMPATIBLE_POW_EXITCODE 0)
|
||||
set_cache_value(HAVE_LARGE_SNPRINTF_SUPPORT_EXITCODE 0)
|
||||
set_cache_value(HAVE_MMAP_DEV_ZERO_EXITCODE 0)
|
||||
set_cache_value(HAVE_PROCFS_CTL_EXITCODE 1)
|
||||
|
@ -112,8 +93,6 @@ elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|armv6|arm64|loongarch64|riscv64|s39
|
|||
set_cache_value(HAVE_PROCFS_STATM_EXITCODE 0)
|
||||
set_cache_value(HAVE_SCHED_GETCPU_EXITCODE 0)
|
||||
set_cache_value(HAVE_SCHED_GET_PRIORITY_EXITCODE 0)
|
||||
set_cache_value(HAVE_VALID_NEGATIVE_INF_POW_EXITCODE 0)
|
||||
set_cache_value(HAVE_VALID_POSITIVE_INF_POW_EXITCODE 0)
|
||||
set_cache_value(HAVE_WORKING_CLOCK_GETTIME_EXITCODE 0)
|
||||
set_cache_value(HAVE_WORKING_GETTIMEOFDAY_EXITCODE 0)
|
||||
set_cache_value(ONE_SHARED_MAPPING_PER_FILEREGION_PER_PROCESS_EXITCODE 1)
|
||||
|
@ -140,16 +119,8 @@ elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|armv6|arm64|loongarch64|riscv64|s39
|
|||
set_cache_value(HAVE_PROCFS_STAT 0)
|
||||
set_cache_value(HAVE_PROCFS_STATM 0)
|
||||
set_cache_value(UNGETC_NOT_RETURN_EOF 0)
|
||||
set_cache_value(HAVE_COMPATIBLE_ILOGBNAN 1)
|
||||
set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 0)
|
||||
elseif(ILLUMOS)
|
||||
set_cache_value(HAVE_COMPATIBLE_ACOS_EXITCODE 1)
|
||||
set_cache_value(HAVE_COMPATIBLE_ASIN_EXITCODE 1)
|
||||
set_cache_value(HAVE_COMPATIBLE_ATAN2_EXITCODE 1)
|
||||
set_cache_value(HAVE_COMPATIBLE_POW_EXITCODE 1)
|
||||
set_cache_value(HAVE_COMPATIBLE_ILOGBNAN_EXITCODE 0)
|
||||
set_cache_value(HAVE_COMPATIBLE_LOG10_EXITCODE 1)
|
||||
set_cache_value(HAVE_COMPATIBLE_LOG_EXITCODE 1)
|
||||
set_cache_value(HAVE_LARGE_SNPRINTF_SUPPORT_EXITCODE 1)
|
||||
set_cache_value(HAVE_PROCFS_CTL_EXITCODE 0)
|
||||
set_cache_value(SSCANF_SUPPORT_ll_EXITCODE 1)
|
||||
|
@ -162,8 +133,6 @@ elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|armv6|arm64|loongarch64|riscv64|s39
|
|||
set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 0)
|
||||
elseif(HAIKU)
|
||||
set_cache_value(HAVE_CLOCK_MONOTONIC_COARSE_EXITCODE 1)
|
||||
set_cache_value(HAVE_COMPATIBLE_EXP_EXITCODE 0)
|
||||
set_cache_value(HAVE_COMPATIBLE_ILOGBNAN_EXITCODE 0)
|
||||
set_cache_value(HAVE_PROCFS_STAT_EXITCODE 1)
|
||||
set_cache_value(HAVE_PROCFS_STATM_EXITCODE 1)
|
||||
endif()
|
||||
|
|
|
@ -17,15 +17,6 @@ set_cache_value(HAVE_BROKEN_FIFO_SELECT_EXITCODE 1)
|
|||
set_cache_value(HAVE_CLOCK_REALTIME_EXITCODE 0)
|
||||
set_cache_value(HAVE_CLOCK_THREAD_CPUTIME_EXITCODE 0)
|
||||
set_cache_value(HAVE_CLOCK_GETTIME_NSEC_NP_EXITCODE 0)
|
||||
set_cache_value(HAVE_COMPATIBLE_ACOS_EXITCODE 0)
|
||||
set_cache_value(HAVE_COMPATIBLE_ASIN_EXITCODE 0)
|
||||
set_cache_value(HAVE_COMPATIBLE_ATAN2_EXITCODE 0)
|
||||
set_cache_value(HAVE_COMPATIBLE_EXP_EXITCODE 1)
|
||||
set_cache_value(HAVE_COMPATIBLE_ILOGB0_EXITCODE 0)
|
||||
set_cache_value(HAVE_COMPATIBLE_ILOGBNAN_EXITCODE 1)
|
||||
set_cache_value(HAVE_COMPATIBLE_LOG10_EXITCODE 0)
|
||||
set_cache_value(HAVE_COMPATIBLE_LOG_EXITCODE 0)
|
||||
set_cache_value(HAVE_COMPATIBLE_POW_EXITCODE 0)
|
||||
set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 1)
|
||||
set_cache_value(HAVE_LARGE_SNPRINTF_SUPPORT_EXITCODE 0)
|
||||
set_cache_value(HAVE_MMAP_DEV_ZERO_EXITCODE 1)
|
||||
|
@ -33,8 +24,6 @@ set_cache_value(HAVE_PROCFS_CTL_EXITCODE 1)
|
|||
set_cache_value(HAVE_PROCFS_STAT_EXITCODE 1)
|
||||
set_cache_value(HAVE_PROCFS_STATM_EXITCODE 1)
|
||||
set_cache_value(HAVE_SCHED_GET_PRIORITY_EXITCODE 0)
|
||||
set_cache_value(HAVE_VALID_NEGATIVE_INF_POW_EXITCODE 0)
|
||||
set_cache_value(HAVE_VALID_POSITIVE_INF_POW_EXITCODE 0)
|
||||
set_cache_value(HAVE_WORKING_CLOCK_GETTIME_EXITCODE 0)
|
||||
set_cache_value(HAVE_WORKING_GETTIMEOFDAY_EXITCODE 0)
|
||||
set_cache_value(MMAP_ANON_IGNORES_PROTECTION_EXITCODE 1)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
include_directories("../inc")
|
||||
|
||||
set(FLOAT_SOURCES
|
||||
|
|
|
@ -262,6 +262,8 @@ FCIMPL3_VII(void, COMDouble::SinCos, double x, double* pSin, double* pCos)
|
|||
#ifdef _MSC_VER
|
||||
*pSin = sin(x);
|
||||
*pCos = cos(x);
|
||||
#elif defined(__APPLE__)
|
||||
__sincos(x, pSin, pCos);
|
||||
#else
|
||||
sincos(x, pSin, pCos);
|
||||
#endif
|
||||
|
|
|
@ -237,6 +237,8 @@ FCIMPL3_VII(void, COMSingle::SinCos, float x, float* pSin, float* pCos)
|
|||
#ifdef _MSC_VER
|
||||
*pSin = sinf(x);
|
||||
*pCos = cosf(x);
|
||||
#elif defined(__APPLE__)
|
||||
__sincosf(x, pSin, pCos);
|
||||
#else
|
||||
sincosf(x, pSin, pCos);
|
||||
#endif
|
||||
|
|
|
@ -1368,7 +1368,7 @@ AssertionIndex Compiler::optCreateAssertion(GenTree* op1,
|
|||
{
|
||||
noway_assert(op2->gtOper == GT_CNS_DBL);
|
||||
/* If we have an NaN value then don't record it */
|
||||
if (_isnan(op2->AsDblCon()->DconValue()))
|
||||
if (FloatingPointUtils::isNaN(op2->AsDblCon()->DconValue()))
|
||||
{
|
||||
goto DONE_ASSERTION; // Don't make an assertion
|
||||
}
|
||||
|
@ -1691,8 +1691,8 @@ bool Compiler::optAssertionVnInvolvesNan(AssertionDsc* assertion)
|
|||
if (vnStore->IsVNConstant(vns[i]))
|
||||
{
|
||||
var_types type = vnStore->TypeOfVN(vns[i]);
|
||||
if ((type == TYP_FLOAT && _isnan(vnStore->ConstantValue<float>(vns[i])) != 0) ||
|
||||
(type == TYP_DOUBLE && _isnan(vnStore->ConstantValue<double>(vns[i])) != 0))
|
||||
if ((type == TYP_FLOAT && FloatingPointUtils::isNaN(vnStore->ConstantValue<float>(vns[i])) != 0) ||
|
||||
(type == TYP_DOUBLE && FloatingPointUtils::isNaN(vnStore->ConstantValue<double>(vns[i])) != 0))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -4351,7 +4351,7 @@ GenTree* Compiler::optAssertionPropGlobal_RelOp(ASSERT_VALARG_TP assertions, Gen
|
|||
// which will yield a false correctly. Instead if IL had "op1 != NaN", then we already
|
||||
// made op1 NaN which will yield a true correctly. Note that this is irrespective of the
|
||||
// assertion we have made.
|
||||
allowReverse = (_isnan(constant) == 0);
|
||||
allowReverse = !FloatingPointUtils::isNaN(constant);
|
||||
}
|
||||
else if (op1->TypeGet() == TYP_FLOAT)
|
||||
{
|
||||
|
@ -4359,7 +4359,7 @@ GenTree* Compiler::optAssertionPropGlobal_RelOp(ASSERT_VALARG_TP assertions, Gen
|
|||
op1->BashToConst(constant);
|
||||
|
||||
// See comments for TYP_DOUBLE.
|
||||
allowReverse = (_isnan(constant) == 0);
|
||||
allowReverse = !FloatingPointUtils::isNaN(constant);
|
||||
}
|
||||
else if (op1->TypeGet() == TYP_REF)
|
||||
{
|
||||
|
|
|
@ -16091,7 +16091,7 @@ GenTree* Compiler::gtFoldExprConst(GenTree* tree)
|
|||
// For unordered operations (i.e. the GTF_RELOP_NAN_UN flag is set)
|
||||
// the result is always true - return 1.
|
||||
|
||||
if (_isnan(d1) || _isnan(d2))
|
||||
if (FloatingPointUtils::isNaN(d1) || FloatingPointUtils::isNaN(d2))
|
||||
{
|
||||
JITDUMP("Double operator(s) is NaN\n");
|
||||
|
||||
|
|
|
@ -2399,22 +2399,10 @@ double FloatingPointUtils::round(double x)
|
|||
// noting that we also need to copy back the original sign to
|
||||
// correctly handle -0.0
|
||||
|
||||
double temp = _copysign(IntegerBoundary, x);
|
||||
return _copysign((x + temp) - temp, x);
|
||||
double temp = copysign(IntegerBoundary, x);
|
||||
return copysign((x + temp) - temp, x);
|
||||
}
|
||||
|
||||
// Windows x86 and Windows ARM/ARM64 may not define _copysignf() but they do define _copysign().
|
||||
// We will redirect the macro to this other functions if the macro is not defined for the platform.
|
||||
// This has the side effect of a possible implicit upcasting for arguments passed in and an explicit
|
||||
// downcasting for the _copysign() call.
|
||||
#if (defined(TARGET_X86) || defined(TARGET_ARM) || defined(TARGET_ARM64)) && !defined(TARGET_UNIX)
|
||||
|
||||
#if !defined(_copysignf)
|
||||
#define _copysignf (float)_copysign
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// Rounds a single-precision floating-point value to the nearest integer,
|
||||
// and rounds midpoint values to the nearest even number.
|
||||
float FloatingPointUtils::round(float x)
|
||||
|
@ -2456,8 +2444,8 @@ float FloatingPointUtils::round(float x)
|
|||
// noting that we also need to copy back the original sign to
|
||||
// correctly handle -0.0
|
||||
|
||||
float temp = _copysignf(IntegerBoundary, x);
|
||||
return _copysignf((x + temp) - temp, x);
|
||||
float temp = copysignf(IntegerBoundary, x);
|
||||
return copysignf((x + temp) - temp, x);
|
||||
}
|
||||
|
||||
bool FloatingPointUtils::isNormal(double x)
|
||||
|
@ -2584,6 +2572,38 @@ bool FloatingPointUtils::isAllBitsSet(double val)
|
|||
return bits == 0xFFFFFFFFFFFFFFFFULL;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// isFinite: Determines whether the specified value is finite
|
||||
//
|
||||
// Arguments:
|
||||
// val - value to check is not NaN or infinity
|
||||
//
|
||||
// Return Value:
|
||||
// True if val is finite
|
||||
//
|
||||
|
||||
bool FloatingPointUtils::isFinite(float val)
|
||||
{
|
||||
UINT32 bits = *reinterpret_cast<UINT32*>(&val);
|
||||
return (~bits & 0x7F800000U) != 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// isFinite: Determines whether the specified value is finite
|
||||
//
|
||||
// Arguments:
|
||||
// val - value to check is not NaN or infinity
|
||||
//
|
||||
// Return Value:
|
||||
// True if val is finite
|
||||
//
|
||||
|
||||
bool FloatingPointUtils::isFinite(double val)
|
||||
{
|
||||
UINT64 bits = *reinterpret_cast<UINT64*>(&val);
|
||||
return (~bits & 0x7FF0000000000000ULL) != 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// isNegative: Determines whether the specified value is negative
|
||||
//
|
||||
|
@ -3202,6 +3222,32 @@ double FloatingPointUtils::normalize(double value)
|
|||
#endif
|
||||
}
|
||||
|
||||
int FloatingPointUtils::ilogb(double value)
|
||||
{
|
||||
if (value == 0.0)
|
||||
{
|
||||
return -2147483648;
|
||||
}
|
||||
else if (isNaN(value))
|
||||
{
|
||||
return 2147483647;
|
||||
}
|
||||
return ilogb(value);
|
||||
}
|
||||
|
||||
int FloatingPointUtils::ilogb(float value)
|
||||
{
|
||||
if (value == 0.0f)
|
||||
{
|
||||
return -2147483648;
|
||||
}
|
||||
else if (isNaN(value))
|
||||
{
|
||||
return 2147483647;
|
||||
}
|
||||
return ilogbf(value);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// BitOperations::BitScanReverse: Search the mask data from most significant bit (MSB) to least significant bit
|
||||
// (LSB) for a set bit (1).
|
||||
|
|
|
@ -813,6 +813,10 @@ public:
|
|||
|
||||
static bool isAllBitsSet(double val);
|
||||
|
||||
static bool isFinite(float val);
|
||||
|
||||
static bool isFinite(double val);
|
||||
|
||||
static bool isNegative(float val);
|
||||
|
||||
static bool isNegative(double val);
|
||||
|
@ -858,6 +862,10 @@ public:
|
|||
static float minimumNumber(float val1, float val2);
|
||||
|
||||
static double normalize(double x);
|
||||
|
||||
static int ilogb(double x);
|
||||
|
||||
static int ilogb(float f);
|
||||
};
|
||||
|
||||
class BitOperations
|
||||
|
|
|
@ -18,17 +18,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
|||
#include "valuenum.h"
|
||||
#include "ssaconfig.h"
|
||||
|
||||
// Windows x86 and Windows ARM/ARM64 may not define _isnanf() but they do define _isnan().
|
||||
// We will redirect the macros to these other functions if the macro is not defined for the
|
||||
// platform. This has the side effect of a possible implicit upcasting for arguments passed.
|
||||
#if (defined(HOST_X86) || defined(HOST_ARM) || defined(HOST_ARM64)) && !defined(HOST_UNIX)
|
||||
|
||||
#if !defined(_isnanf)
|
||||
#define _isnanf _isnan
|
||||
#endif
|
||||
|
||||
#endif // (defined(HOST_X86) || defined(HOST_ARM) || defined(HOST_ARM64)) && !defined(HOST_UNIX)
|
||||
|
||||
// We need to use target-specific NaN values when statically compute expressions.
|
||||
// Otherwise, cross crossgen (e.g. x86_arm) would have different binary outputs
|
||||
// from native crossgen (i.e. arm_arm) when the NaN got "embedded" into code.
|
||||
|
@ -112,7 +101,7 @@ TFp FpAdd(TFp value1, TFp value2)
|
|||
// If [value1] is positive infinity and [value2] is negative infinity
|
||||
// the result is NaN.
|
||||
|
||||
if (!_finite(value1) && !_finite(value2))
|
||||
if (!FloatingPointUtils::isFinite(value1) && !FloatingPointUtils::isFinite(value2))
|
||||
{
|
||||
if (value1 < 0 && value2 > 0)
|
||||
{
|
||||
|
@ -148,7 +137,7 @@ TFp FpSub(TFp value1, TFp value2)
|
|||
// If [value1] is negative infinity and [value2] is negative infinity
|
||||
// the result is NaN.
|
||||
|
||||
if (!_finite(value1) && !_finite(value2))
|
||||
if (!FloatingPointUtils::isFinite(value1) && !FloatingPointUtils::isFinite(value2))
|
||||
{
|
||||
if (value1 > 0 && value2 > 0)
|
||||
{
|
||||
|
@ -186,11 +175,11 @@ TFp FpMul(TFp value1, TFp value2)
|
|||
// If [value1] is infinity and [value2] is zero
|
||||
// the result is NaN.
|
||||
|
||||
if (value1 == 0 && !_finite(value2) && !_isnan(value2))
|
||||
if (value1 == 0 && !FloatingPointUtils::isFinite(value2) && !FloatingPointUtils::isNaN(value2))
|
||||
{
|
||||
return TFpTraits::NaN();
|
||||
}
|
||||
if (!_finite(value1) && !_isnan(value1) && value2 == 0)
|
||||
if (!FloatingPointUtils::isFinite(value1) && !FloatingPointUtils::isNaN(value1) && value2 == 0)
|
||||
{
|
||||
return TFpTraits::NaN();
|
||||
}
|
||||
|
@ -224,7 +213,8 @@ TFp FpDiv(TFp dividend, TFp divisor)
|
|||
{
|
||||
return TFpTraits::NaN();
|
||||
}
|
||||
else if (!_finite(dividend) && !_isnan(dividend) && !_finite(divisor) && !_isnan(divisor))
|
||||
else if (!FloatingPointUtils::isFinite(dividend) && !FloatingPointUtils::isNaN(dividend) &&
|
||||
!FloatingPointUtils::isFinite(divisor) && !FloatingPointUtils::isNaN(divisor))
|
||||
{
|
||||
return TFpTraits::NaN();
|
||||
}
|
||||
|
@ -243,11 +233,11 @@ TFp FpRem(TFp dividend, TFp divisor)
|
|||
// If [divisor] is infinity,
|
||||
// the result is [dividend]
|
||||
|
||||
if (divisor == 0 || !_finite(dividend))
|
||||
if (divisor == 0 || !FloatingPointUtils::isFinite(dividend))
|
||||
{
|
||||
return TFpTraits::NaN();
|
||||
}
|
||||
else if (!_finite(divisor) && !_isnan(divisor))
|
||||
else if (!FloatingPointUtils::isFinite(divisor) && !FloatingPointUtils::isNaN(divisor))
|
||||
{
|
||||
return dividend;
|
||||
}
|
||||
|
@ -817,7 +807,7 @@ int ValueNumStore::EvalComparison<double>(VNFunc vnf, double v0, double v1)
|
|||
// Here we handle specialized double comparisons.
|
||||
|
||||
// We must check for a NaN argument as they they need special handling
|
||||
bool hasNanArg = (_isnan(v0) || _isnan(v1));
|
||||
bool hasNanArg = (FloatingPointUtils::isNaN(v0) || FloatingPointUtils::isNaN(v1));
|
||||
|
||||
if (vnf < VNF_Boundary)
|
||||
{
|
||||
|
@ -881,7 +871,7 @@ int ValueNumStore::EvalComparison<float>(VNFunc vnf, float v0, float v1)
|
|||
// Here we handle specialized float comparisons.
|
||||
|
||||
// We must check for a NaN argument as they they need special handling
|
||||
bool hasNanArg = (_isnanf(v0) || _isnanf(v1));
|
||||
bool hasNanArg = (FloatingPointUtils::isNaN(v0) || FloatingPointUtils::isNaN(v1));
|
||||
|
||||
if (vnf < VNF_Boundary)
|
||||
{
|
||||
|
@ -8500,14 +8490,14 @@ ValueNum ValueNumStore::EvalMathFuncUnary(var_types typ, NamedIntrinsic gtMathFN
|
|||
case TYP_DOUBLE:
|
||||
{
|
||||
double arg0Val = GetConstantDouble(arg0VN);
|
||||
res = ilogb(arg0Val);
|
||||
res = FloatingPointUtils::ilogb(arg0Val);
|
||||
break;
|
||||
}
|
||||
|
||||
case TYP_FLOAT:
|
||||
{
|
||||
float arg0Val = GetConstantSingle(arg0VN);
|
||||
res = ilogbf(arg0Val);
|
||||
res = FloatingPointUtils::ilogb(arg0Val);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -4002,24 +4002,6 @@ PAL_GetCurrentThreadAffinitySet(SIZE_T size, UINT_PTR* data);
|
|||
#define fgetpos PAL_fgetpos
|
||||
#define fsetpos PAL_fsetpos
|
||||
#define setvbuf PAL_setvbuf
|
||||
#define acos PAL_acos
|
||||
#define asin PAL_asin
|
||||
#define atan2 PAL_atan2
|
||||
#define exp PAL_exp
|
||||
#define ilogb PAL_ilogb
|
||||
#define log PAL_log
|
||||
#define log10 PAL_log10
|
||||
#define pow PAL_pow
|
||||
#define sincos PAL_sincos
|
||||
#define acosf PAL_acosf
|
||||
#define asinf PAL_asinf
|
||||
#define atan2f PAL_atan2f
|
||||
#define expf PAL_expf
|
||||
#define ilogbf PAL_ilogbf
|
||||
#define logf PAL_logf
|
||||
#define log10f PAL_log10f
|
||||
#define powf PAL_powf
|
||||
#define sincosf PAL_sincosf
|
||||
#define malloc PAL_malloc
|
||||
#define free PAL_free
|
||||
#define _open PAL__open
|
||||
|
@ -4223,9 +4205,7 @@ PALIMPORT int __cdecl abs(int);
|
|||
PALIMPORT long long __cdecl llabs(long long);
|
||||
#ifndef PAL_STDCPP_COMPAT
|
||||
|
||||
PALIMPORT int __cdecl _finite(double);
|
||||
PALIMPORT int __cdecl _isnan(double);
|
||||
PALIMPORT double __cdecl _copysign(double, double);
|
||||
PALIMPORT double __cdecl copysign(double, double);
|
||||
PALIMPORT double __cdecl acos(double);
|
||||
PALIMPORT double __cdecl acosh(double) MATH_THROW_DECL;
|
||||
PALIMPORT double __cdecl asin(double);
|
||||
|
@ -4250,15 +4230,16 @@ PALIMPORT double __cdecl modf(double, double*);
|
|||
PALIMPORT double __cdecl pow(double, double);
|
||||
PALIMPORT double __cdecl sin(double);
|
||||
PALIMPORT void __cdecl sincos(double, double*, double*);
|
||||
#ifdef __APPLE__
|
||||
PALIMPORT void __cdecl __sincos(double, double*, double*);
|
||||
#endif
|
||||
PALIMPORT double __cdecl sinh(double);
|
||||
PALIMPORT double __cdecl sqrt(double);
|
||||
PALIMPORT double __cdecl tan(double);
|
||||
PALIMPORT double __cdecl tanh(double);
|
||||
PALIMPORT double __cdecl trunc(double);
|
||||
|
||||
PALIMPORT int __cdecl _finitef(float);
|
||||
PALIMPORT int __cdecl _isnanf(float);
|
||||
PALIMPORT float __cdecl _copysignf(float, float);
|
||||
PALIMPORT float __cdecl copysignf(float, float);
|
||||
PALIMPORT float __cdecl acosf(float);
|
||||
PALIMPORT float __cdecl acoshf(float) MATH_THROW_DECL;
|
||||
PALIMPORT float __cdecl asinf(float);
|
||||
|
@ -4283,6 +4264,9 @@ PALIMPORT float __cdecl modff(float, float*);
|
|||
PALIMPORT float __cdecl powf(float, float);
|
||||
PALIMPORT float __cdecl sinf(float);
|
||||
PALIMPORT void __cdecl sincosf(float, float*, float*);
|
||||
#ifdef __APPLE__
|
||||
PALIMPORT void __cdecl __sincosf(float, float*, float*);
|
||||
#endif
|
||||
PALIMPORT float __cdecl sinhf(float);
|
||||
PALIMPORT float __cdecl sqrtf(float);
|
||||
PALIMPORT float __cdecl tanf(float);
|
||||
|
|
|
@ -132,7 +132,6 @@ set(SOURCES
|
|||
cruntime/file.cpp
|
||||
cruntime/filecrt.cpp
|
||||
cruntime/malloc.cpp
|
||||
cruntime/math.cpp
|
||||
cruntime/misc.cpp
|
||||
cruntime/printfcpp.cpp
|
||||
cruntime/thread.cpp
|
||||
|
|
|
@ -119,17 +119,6 @@
|
|||
#cmakedefine01 SEM_INIT_MODIFIES_ERRNO
|
||||
#cmakedefine01 HAVE_PROCFS_CTL
|
||||
#cmakedefine01 HAVE_PROCFS_STAT
|
||||
#cmakedefine01 HAVE_COMPATIBLE_ACOS
|
||||
#cmakedefine01 HAVE_COMPATIBLE_ASIN
|
||||
#cmakedefine01 HAVE_COMPATIBLE_POW
|
||||
#cmakedefine01 HAVE_VALID_NEGATIVE_INF_POW
|
||||
#cmakedefine01 HAVE_VALID_POSITIVE_INF_POW
|
||||
#cmakedefine01 HAVE_COMPATIBLE_ATAN2
|
||||
#cmakedefine01 HAVE_COMPATIBLE_EXP
|
||||
#cmakedefine01 HAVE_COMPATIBLE_ILOGB0
|
||||
#cmakedefine01 HAVE_COMPATIBLE_ILOGBNAN
|
||||
#cmakedefine01 HAVE_COMPATIBLE_LOG
|
||||
#cmakedefine01 HAVE_COMPATIBLE_LOG10
|
||||
#cmakedefine01 UNGETC_NOT_RETURN_EOF
|
||||
#cmakedefine01 HAS_POSIX_SEMAPHORES
|
||||
#cmakedefine01 FILE_OPS_CHECK_FERROR_OF_PREVIOUS_CALL
|
||||
|
|
|
@ -644,214 +644,6 @@ int main(void) {
|
|||
exit(0);
|
||||
}" HAVE_PROCFS_STAT)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
set(CMAKE_REQUIRED_LIBRARIES m)
|
||||
check_cxx_source_runs("
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
volatile double x = 10;
|
||||
if (!isnan(acos(x))) {
|
||||
exit(1);
|
||||
}
|
||||
exit(0);
|
||||
}" HAVE_COMPATIBLE_ACOS)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
set(CMAKE_REQUIRED_LIBRARIES m)
|
||||
check_cxx_source_runs("
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
volatile double arg = 10;
|
||||
if (!isnan(asin(arg))) {
|
||||
exit(1);
|
||||
}
|
||||
exit(0);
|
||||
}" HAVE_COMPATIBLE_ASIN)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
set(CMAKE_REQUIRED_LIBRARIES m)
|
||||
check_cxx_source_runs("
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
volatile double base = 1.0;
|
||||
volatile double infinity = 1.0 / 0.0;
|
||||
if (pow(base, infinity) != 1.0 || pow(base, -infinity) != 1.0) {
|
||||
exit(1);
|
||||
}
|
||||
if (pow(-base, infinity) != 1.0 || pow(-base, -infinity) != 1.0) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
base = 0.0;
|
||||
if (pow(base, infinity) != 0.0) {
|
||||
exit(1);
|
||||
}
|
||||
if (pow(base, -infinity) != infinity) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
base = 1.1;
|
||||
if (pow(-base, infinity) != infinity || pow(base, infinity) != infinity) {
|
||||
exit(1);
|
||||
}
|
||||
if (pow(-base, -infinity) != 0.0 || pow(base, -infinity) != 0.0) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
base = 0.0;
|
||||
volatile int iexp = 1;
|
||||
if (pow(-base, -iexp) != -infinity) {
|
||||
exit(1);
|
||||
}
|
||||
if (pow(base, -iexp) != infinity) {
|
||||
exit(1);
|
||||
}
|
||||
exit(0);
|
||||
}" HAVE_COMPATIBLE_POW)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
set(CMAKE_REQUIRED_LIBRARIES m)
|
||||
check_cxx_source_runs("
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
double result;
|
||||
volatile double base = 3.2e-10;
|
||||
volatile double exp = 1 - 5e14;
|
||||
|
||||
result = pow(-base, exp);
|
||||
if (result != -1.0 / 0.0) {
|
||||
exit(1);
|
||||
}
|
||||
exit(0);
|
||||
}" HAVE_VALID_NEGATIVE_INF_POW)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
set(CMAKE_REQUIRED_LIBRARIES m)
|
||||
check_cxx_source_runs("
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
double result;
|
||||
volatile double base = 3.5;
|
||||
volatile double exp = 3e100;
|
||||
|
||||
result = pow(-base, exp);
|
||||
if (result != 1.0 / 0.0) {
|
||||
exit(1);
|
||||
}
|
||||
exit(0);
|
||||
}" HAVE_VALID_POSITIVE_INF_POW)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
set(CMAKE_REQUIRED_LIBRARIES m)
|
||||
check_cxx_source_runs("
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
double pi = 3.14159265358979323846;
|
||||
double result;
|
||||
volatile double y = 0.0;
|
||||
volatile double x = 0.0;
|
||||
|
||||
result = atan2(y, -x);
|
||||
if (fabs(pi - result) > 0.0000001) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
result = atan2(-y, -x);
|
||||
if (fabs(-pi - result) > 0.0000001) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
result = atan2 (-y, x);
|
||||
if (result != 0.0 || copysign (1.0, result) > 0) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
result = atan2 (y, x);
|
||||
if (result != 0.0 || copysign (1.0, result) < 0) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
exit (0);
|
||||
}" HAVE_COMPATIBLE_ATAN2)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
set(CMAKE_REQUIRED_LIBRARIES m)
|
||||
check_cxx_source_runs("
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
double d = exp(1.0), e = M_E;
|
||||
|
||||
/* Used memcmp rather than == to test that the doubles are equal to
|
||||
prevent gcc's optimizer from using its 80 bit internal long
|
||||
doubles. If you use ==, then on BSD you get a false negative since
|
||||
exp(1.0) == M_E to 64 bits, but not 80.
|
||||
*/
|
||||
|
||||
if (memcmp (&d, &e, sizeof (double)) == 0) {
|
||||
exit(0);
|
||||
}
|
||||
exit(1);
|
||||
}" HAVE_COMPATIBLE_EXP)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
set(CMAKE_REQUIRED_LIBRARIES m)
|
||||
check_cxx_source_runs("
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
if (FP_ILOGB0 != -2147483648) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}" HAVE_COMPATIBLE_ILOGB0)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
set(CMAKE_REQUIRED_LIBRARIES m)
|
||||
check_cxx_source_runs("
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
if (FP_ILOGBNAN != 2147483647) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}" HAVE_COMPATIBLE_ILOGBNAN)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
set(CMAKE_REQUIRED_LIBRARIES m)
|
||||
check_cxx_source_runs("
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
volatile int arg = 10000;
|
||||
if (!isnan(log(-arg))) {
|
||||
exit(1);
|
||||
}
|
||||
exit(0);
|
||||
}" HAVE_COMPATIBLE_LOG)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
set(CMAKE_REQUIRED_LIBRARIES m)
|
||||
check_cxx_source_runs("
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
volatile int arg = 10000;
|
||||
if (!isnan(log10(-arg))) {
|
||||
exit(1);
|
||||
}
|
||||
exit(0);
|
||||
}" HAVE_COMPATIBLE_LOG10)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
check_cxx_source_runs("
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -1,859 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*++
|
||||
|
||||
|
||||
|
||||
Module Name:
|
||||
|
||||
math.cpp
|
||||
|
||||
Abstract:
|
||||
|
||||
Implementation of math family functions.
|
||||
|
||||
|
||||
|
||||
--*/
|
||||
|
||||
#include "pal/palinternal.h"
|
||||
#include "pal/dbgmsg.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#if HAVE_IEEEFP_H
|
||||
#include <ieeefp.h>
|
||||
#endif // HAVE_IEEEFP_H
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#define PAL_NAN_DBL sqrt(-1.0)
|
||||
#define PAL_POSINF_DBL -log(0.0)
|
||||
#define PAL_NEGINF_DBL log(0.0)
|
||||
|
||||
#define IS_DBL_NEGZERO(x) (((*((INT64*)((void*)&x))) & I64(0xFFFFFFFFFFFFFFFF)) == I64(0x8000000000000000))
|
||||
|
||||
#define PAL_NAN_FLT sqrtf(-1.0f)
|
||||
#define PAL_POSINF_FLT -logf(0.0f)
|
||||
#define PAL_NEGINF_FLT logf(0.0f)
|
||||
|
||||
#define IS_FLT_NEGZERO(x) (((*((INT32*)((void*)&x))) & 0xFFFFFFFF) == 0x80000000)
|
||||
|
||||
SET_DEFAULT_DEBUG_CHANNEL(CRT);
|
||||
|
||||
/*++
|
||||
Function:
|
||||
_finite
|
||||
|
||||
Determines whether given double-precision floating point value is finite.
|
||||
|
||||
Return Value
|
||||
|
||||
_finite returns a nonzero value (TRUE) if its argument x is not
|
||||
infinite, that is, if -INF < x < +INF. It returns 0 (FALSE) if the
|
||||
argument is infinite or a NaN.
|
||||
|
||||
Parameter
|
||||
|
||||
x Double-precision floating-point value
|
||||
|
||||
--*/
|
||||
int __cdecl _finite(double x)
|
||||
{
|
||||
int ret;
|
||||
PERF_ENTRY(_finite);
|
||||
ENTRY("_finite (x=%f)\n", x);
|
||||
|
||||
ret = isfinite(x);
|
||||
|
||||
LOGEXIT("_finite returns int %d\n", ret);
|
||||
PERF_EXIT(_finite);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*++
|
||||
Function:
|
||||
_isnan
|
||||
|
||||
See MSDN doc
|
||||
--*/
|
||||
int __cdecl _isnan(double x)
|
||||
{
|
||||
int ret;
|
||||
PERF_ENTRY(_isnan);
|
||||
ENTRY("_isnan (x=%f)\n", x);
|
||||
|
||||
ret = isnan(x);
|
||||
|
||||
LOGEXIT("_isnan returns int %d\n", ret);
|
||||
PERF_EXIT(_isnan);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*++
|
||||
Function:
|
||||
_copysign
|
||||
|
||||
See MSDN doc
|
||||
--*/
|
||||
double __cdecl _copysign(double x, double y)
|
||||
{
|
||||
double ret;
|
||||
PERF_ENTRY(_copysign);
|
||||
ENTRY("_copysign (x=%f, y=%f)\n", x, y);
|
||||
|
||||
ret = copysign(x, y);
|
||||
|
||||
LOGEXIT("_copysign returns double %f\n", ret);
|
||||
PERF_EXIT(_copysign);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*++
|
||||
Function:
|
||||
acos
|
||||
|
||||
See MSDN.
|
||||
--*/
|
||||
PALIMPORT double __cdecl PAL_acos(double x)
|
||||
{
|
||||
double ret;
|
||||
PERF_ENTRY(acos);
|
||||
ENTRY("acos (x=%f)\n", x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_ACOS
|
||||
errno = 0;
|
||||
#endif // HAVE_COMPATIBLE_ACOS
|
||||
|
||||
ret = acos(x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_ACOS
|
||||
if (errno == EDOM)
|
||||
{
|
||||
ret = PAL_NAN_DBL; // NaN
|
||||
}
|
||||
#endif // HAVE_COMPATIBLE_ACOS
|
||||
|
||||
LOGEXIT("acos returns double %f\n", ret);
|
||||
PERF_EXIT(acos);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*++
|
||||
Function:
|
||||
asin
|
||||
|
||||
See MSDN.
|
||||
--*/
|
||||
PALIMPORT double __cdecl PAL_asin(double x)
|
||||
{
|
||||
double ret;
|
||||
PERF_ENTRY(asin);
|
||||
ENTRY("asin (x=%f)\n", x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_ASIN
|
||||
errno = 0;
|
||||
#endif // HAVE_COMPATIBLE_ASIN
|
||||
|
||||
ret = asin(x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_ASIN
|
||||
if (errno == EDOM)
|
||||
{
|
||||
ret = PAL_NAN_DBL; // NaN
|
||||
}
|
||||
#endif // HAVE_COMPATIBLE_ASIN
|
||||
|
||||
LOGEXIT("asin returns double %f\n", ret);
|
||||
PERF_EXIT(asin);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*++
|
||||
Function:
|
||||
atan2
|
||||
|
||||
See MSDN.
|
||||
--*/
|
||||
PALIMPORT double __cdecl PAL_atan2(double y, double x)
|
||||
{
|
||||
double ret;
|
||||
PERF_ENTRY(atan2);
|
||||
ENTRY("atan2 (y=%f, x=%f)\n", y, x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_ATAN2
|
||||
errno = 0;
|
||||
#endif // !HAVE_COMPATIBLE_ATAN2
|
||||
|
||||
ret = atan2(y, x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_ATAN2
|
||||
if ((errno == EDOM) && (x == 0.0) && (y == 0.0))
|
||||
{
|
||||
const double sign_x = copysign(1.0, x);
|
||||
const double sign_y = copysign(1.0, y);
|
||||
|
||||
if (sign_x > 0)
|
||||
{
|
||||
ret = copysign(0.0, sign_y);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = copysign(atan2(0.0, -1.0), sign_y);
|
||||
}
|
||||
}
|
||||
#endif // !HAVE_COMPATIBLE_ATAN2
|
||||
|
||||
LOGEXIT("atan2 returns double %f\n", ret);
|
||||
PERF_EXIT(atan2);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*++
|
||||
Function:
|
||||
exp
|
||||
|
||||
See MSDN.
|
||||
--*/
|
||||
PALIMPORT double __cdecl PAL_exp(double x)
|
||||
{
|
||||
double ret;
|
||||
PERF_ENTRY(exp);
|
||||
ENTRY("exp (x=%f)\n", x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_EXP
|
||||
if (x == 1.0)
|
||||
{
|
||||
ret = M_E;
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif // HAVE_COMPATIBLE_EXP
|
||||
|
||||
ret = exp(x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_EXP
|
||||
}
|
||||
#endif // HAVE_COMPATIBLE_EXP
|
||||
|
||||
LOGEXIT("exp returns double %f\n", ret);
|
||||
PERF_EXIT(exp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*++
|
||||
Function:
|
||||
ilogb
|
||||
|
||||
See MSDN.
|
||||
--*/
|
||||
PALIMPORT int __cdecl PAL_ilogb(double x)
|
||||
{
|
||||
int ret;
|
||||
PERF_ENTRY(ilogb);
|
||||
ENTRY("ilogb (x=%f)\n", x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_ILOGB0
|
||||
if (x == 0.0)
|
||||
{
|
||||
ret = -2147483648;
|
||||
}
|
||||
else
|
||||
#endif // !HAVE_COMPATIBLE_ILOGB0
|
||||
|
||||
#if !HAVE_COMPATIBLE_ILOGBNAN
|
||||
if (isnan(x))
|
||||
{
|
||||
ret = 2147483647;
|
||||
}
|
||||
else
|
||||
#endif // !HAVE_COMPATIBLE_ILOGBNAN
|
||||
|
||||
{
|
||||
ret = ilogb(x);
|
||||
}
|
||||
|
||||
LOGEXIT("ilogb returns int %d\n", ret);
|
||||
PERF_EXIT(ilogb);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*++
|
||||
Function:
|
||||
log
|
||||
|
||||
See MSDN.
|
||||
--*/
|
||||
PALIMPORT double __cdecl PAL_log(double x)
|
||||
{
|
||||
double ret;
|
||||
PERF_ENTRY(log);
|
||||
ENTRY("log (x=%f)\n", x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_LOG
|
||||
errno = 0;
|
||||
#endif // !HAVE_COMPATIBLE_LOG
|
||||
|
||||
ret = log(x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_LOG
|
||||
if ((errno == EDOM) && (x < 0))
|
||||
{
|
||||
ret = PAL_NAN_DBL; // NaN
|
||||
}
|
||||
#endif // !HAVE_COMPATIBLE_LOG
|
||||
|
||||
LOGEXIT("log returns double %f\n", ret);
|
||||
PERF_EXIT(log);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*++
|
||||
Function:
|
||||
log10
|
||||
|
||||
See MSDN.
|
||||
--*/
|
||||
PALIMPORT double __cdecl PAL_log10(double x)
|
||||
{
|
||||
double ret;
|
||||
PERF_ENTRY(log10);
|
||||
ENTRY("log10 (x=%f)\n", x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_LOG10
|
||||
errno = 0;
|
||||
#endif // !HAVE_COMPATIBLE_LOG10
|
||||
|
||||
ret = log10(x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_LOG10
|
||||
if ((errno == EDOM) && (x < 0))
|
||||
{
|
||||
ret = PAL_NAN_DBL; // NaN
|
||||
}
|
||||
#endif // !HAVE_COMPATIBLE_LOG10
|
||||
|
||||
LOGEXIT("log10 returns double %f\n", ret);
|
||||
PERF_EXIT(log10);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*++
|
||||
Function:
|
||||
pow
|
||||
|
||||
See MSDN.
|
||||
--*/
|
||||
PALIMPORT double __cdecl PAL_pow(double x, double y)
|
||||
{
|
||||
double ret;
|
||||
PERF_ENTRY(pow);
|
||||
ENTRY("pow (x=%f, y=%f)\n", x, y);
|
||||
|
||||
#if !HAVE_COMPATIBLE_POW
|
||||
if ((y == PAL_POSINF_DBL) && !isnan(x)) // +Inf
|
||||
{
|
||||
if (x == 1.0)
|
||||
{
|
||||
ret = x;
|
||||
}
|
||||
else if (x == -1.0)
|
||||
{
|
||||
ret = 1.0;
|
||||
}
|
||||
else if ((x > -1.0) && (x < 1.0))
|
||||
{
|
||||
ret = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = PAL_POSINF_DBL; // +Inf
|
||||
}
|
||||
}
|
||||
else if ((y == PAL_NEGINF_DBL) && !isnan(x)) // -Inf
|
||||
{
|
||||
if (x == 1.0)
|
||||
{
|
||||
ret = x;
|
||||
}
|
||||
else if (x == -1.0)
|
||||
{
|
||||
ret = 1.0;
|
||||
}
|
||||
else if ((x > -1.0) && (x < 1.0))
|
||||
{
|
||||
ret = PAL_POSINF_DBL; // +Inf
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = 0.0;
|
||||
}
|
||||
}
|
||||
else if (IS_DBL_NEGZERO(x) && (y == -1.0))
|
||||
{
|
||||
ret = PAL_NEGINF_DBL; // -Inf
|
||||
}
|
||||
else if ((x == 0.0) && (y < 0.0))
|
||||
{
|
||||
ret = PAL_POSINF_DBL; // +Inf
|
||||
}
|
||||
else
|
||||
#endif // !HAVE_COMPATIBLE_POW
|
||||
|
||||
ret = pow(x, y);
|
||||
|
||||
#if !HAVE_VALID_NEGATIVE_INF_POW
|
||||
if ((ret == PAL_POSINF_DBL) && (x < 0) && isfinite(x) && (ceil(y / 2) != floor(y / 2)))
|
||||
{
|
||||
ret = PAL_NEGINF_DBL; // -Inf
|
||||
}
|
||||
#endif // !HAVE_VALID_NEGATIVE_INF_POW
|
||||
|
||||
#if !HAVE_VALID_POSITIVE_INF_POW
|
||||
/*
|
||||
* The even/odd test in the if (this one and the one above) used to be ((long long) y % 2 == 0)
|
||||
* on SPARC (long long) y for large y (>2**63) is always 0x7fffffff7fffffff, which
|
||||
* is an odd number, so the test ((long long) y % 2 == 0) will always fail for
|
||||
* large y. Since large double numbers are always even (e.g., the representation of
|
||||
* 1E20+1 is the same as that of 1E20, the last .+1. is too insignificant to be part
|
||||
* of the representation), this test will always return the wrong result for large y.
|
||||
*
|
||||
* The (ceil(y/2) == floor(y/2)) test is slower, but more robust.
|
||||
*/
|
||||
if ((ret == PAL_NEGINF_DBL) && (x < 0) && isfinite(x) && (ceil(y / 2) == floor(y / 2)))
|
||||
{
|
||||
ret = PAL_POSINF_DBL; // +Inf
|
||||
}
|
||||
#endif // !HAVE_VALID_POSITIVE_INF_POW
|
||||
|
||||
LOGEXIT("pow returns double %f\n", ret);
|
||||
PERF_EXIT(pow);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*++
|
||||
Function:
|
||||
sincos
|
||||
|
||||
See MSDN.
|
||||
--*/
|
||||
PALIMPORT void __cdecl PAL_sincos(double x, double* sin, double* cos)
|
||||
{
|
||||
PERF_ENTRY(sincos);
|
||||
ENTRY("sincos (x=%f)\n", x);
|
||||
|
||||
#if defined(__APPLE__)
|
||||
__sincos(x, sin, cos);
|
||||
#else
|
||||
sincos(x, sin, cos);
|
||||
#endif // !__APPLE__
|
||||
|
||||
LOGEXIT("sincos returns (double %f, double %f)\n", *sin, *cos);
|
||||
PERF_EXIT(sincos);
|
||||
}
|
||||
|
||||
/*++
|
||||
Function:
|
||||
_finitef
|
||||
|
||||
Determines whether given single-precision floating point value is finite.
|
||||
|
||||
Return Value
|
||||
|
||||
_finitef returns a nonzero value (TRUE) if its argument x is not
|
||||
infinite, that is, if -INF < x < +INF. It returns 0 (FALSE) if the
|
||||
argument is infinite or a NaN.
|
||||
|
||||
Parameter
|
||||
|
||||
x Single-precision floating-point value
|
||||
|
||||
--*/
|
||||
int __cdecl _finitef(float x)
|
||||
{
|
||||
int ret;
|
||||
PERF_ENTRY(_finitef);
|
||||
ENTRY("_finitef (x=%f)\n", x);
|
||||
|
||||
ret = isfinite(x);
|
||||
|
||||
LOGEXIT("_finitef returns int %d\n", ret);
|
||||
PERF_EXIT(_finitef);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*++
|
||||
Function:
|
||||
_isnanf
|
||||
|
||||
See MSDN doc
|
||||
--*/
|
||||
int __cdecl _isnanf(float x)
|
||||
{
|
||||
int ret;
|
||||
PERF_ENTRY(_isnanf);
|
||||
ENTRY("_isnanf (x=%f)\n", x);
|
||||
|
||||
ret = isnan(x);
|
||||
|
||||
LOGEXIT("_isnanf returns int %d\n", ret);
|
||||
PERF_EXIT(_isnanf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*++
|
||||
Function:
|
||||
_copysignf
|
||||
|
||||
See MSDN doc
|
||||
--*/
|
||||
float __cdecl _copysignf(float x, float y)
|
||||
{
|
||||
float ret;
|
||||
PERF_ENTRY(_copysignf);
|
||||
ENTRY("_copysignf (x=%f, y=%f)\n", x, y);
|
||||
|
||||
ret = copysign(x, y);
|
||||
|
||||
LOGEXIT("_copysignf returns float %f\n", ret);
|
||||
PERF_EXIT(_copysignf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*++
|
||||
Function:
|
||||
acosf
|
||||
|
||||
See MSDN.
|
||||
--*/
|
||||
PALIMPORT float __cdecl PAL_acosf(float x)
|
||||
{
|
||||
float ret;
|
||||
PERF_ENTRY(acosf);
|
||||
ENTRY("acosf (x=%f)\n", x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_ACOS
|
||||
errno = 0;
|
||||
#endif // HAVE_COMPATIBLE_ACOS
|
||||
|
||||
ret = acosf(x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_ACOS
|
||||
if (errno == EDOM)
|
||||
{
|
||||
ret = PAL_NAN_FLT; // NaN
|
||||
}
|
||||
#endif // HAVE_COMPATIBLE_ACOS
|
||||
|
||||
LOGEXIT("acosf returns float %f\n", ret);
|
||||
PERF_EXIT(acosf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*++
|
||||
Function:
|
||||
asinf
|
||||
|
||||
See MSDN.
|
||||
--*/
|
||||
PALIMPORT float __cdecl PAL_asinf(float x)
|
||||
{
|
||||
float ret;
|
||||
PERF_ENTRY(asinf);
|
||||
ENTRY("asinf (x=%f)\n", x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_ASIN
|
||||
errno = 0;
|
||||
#endif // HAVE_COMPATIBLE_ASIN
|
||||
|
||||
ret = asinf(x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_ASIN
|
||||
if (errno == EDOM)
|
||||
{
|
||||
ret = PAL_NAN_FLT; // NaN
|
||||
}
|
||||
#endif // HAVE_COMPATIBLE_ASIN
|
||||
|
||||
LOGEXIT("asinf returns float %f\n", ret);
|
||||
PERF_EXIT(asinf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*++
|
||||
Function:
|
||||
atan2f
|
||||
|
||||
See MSDN.
|
||||
--*/
|
||||
PALIMPORT float __cdecl PAL_atan2f(float y, float x)
|
||||
{
|
||||
float ret;
|
||||
PERF_ENTRY(atan2f);
|
||||
ENTRY("atan2f (y=%f, x=%f)\n", y, x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_ATAN2
|
||||
errno = 0;
|
||||
#endif // !HAVE_COMPATIBLE_ATAN2
|
||||
|
||||
ret = atan2f(y, x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_ATAN2
|
||||
if ((errno == EDOM) && (x == 0.0f) && (y == 0.0f))
|
||||
{
|
||||
const float sign_x = copysign(1.0f, x);
|
||||
const float sign_y = copysign(1.0f, y);
|
||||
|
||||
if (sign_x > 0)
|
||||
{
|
||||
ret = copysign(0.0f, sign_y);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = copysign(atan2f(0.0f, -1.0f), sign_y);
|
||||
}
|
||||
}
|
||||
#endif // !HAVE_COMPATIBLE_ATAN2
|
||||
|
||||
LOGEXIT("atan2f returns float %f\n", ret);
|
||||
PERF_EXIT(atan2f);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*++
|
||||
Function:
|
||||
expf
|
||||
|
||||
See MSDN.
|
||||
--*/
|
||||
PALIMPORT float __cdecl PAL_expf(float x)
|
||||
{
|
||||
float ret;
|
||||
PERF_ENTRY(expf);
|
||||
ENTRY("expf (x=%f)\n", x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_EXP
|
||||
if (x == 1.0f)
|
||||
{
|
||||
ret = M_E;
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif // HAVE_COMPATIBLE_EXP
|
||||
|
||||
ret = expf(x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_EXP
|
||||
}
|
||||
#endif // HAVE_COMPATIBLE_EXP
|
||||
|
||||
LOGEXIT("expf returns float %f\n", ret);
|
||||
PERF_EXIT(expf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*++
|
||||
Function:
|
||||
ilogbf
|
||||
|
||||
See MSDN.
|
||||
--*/
|
||||
PALIMPORT int __cdecl PAL_ilogbf(float x)
|
||||
{
|
||||
int ret;
|
||||
PERF_ENTRY(ilogbf);
|
||||
ENTRY("ilogbf (x=%f)\n", x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_ILOGB0
|
||||
if (x == 0.0f)
|
||||
{
|
||||
ret = -2147483648;
|
||||
}
|
||||
else
|
||||
#endif // !HAVE_COMPATIBLE_ILOGB0
|
||||
|
||||
#if !HAVE_COMPATIBLE_ILOGBNAN
|
||||
if (isnan(x))
|
||||
{
|
||||
ret = 2147483647;
|
||||
}
|
||||
else
|
||||
#endif // !HAVE_COMPATIBLE_ILOGBNAN
|
||||
|
||||
{
|
||||
ret = ilogbf(x);
|
||||
}
|
||||
|
||||
LOGEXIT("ilogbf returns int %d\n", ret);
|
||||
PERF_EXIT(ilogbf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*++
|
||||
Function:
|
||||
logf
|
||||
|
||||
See MSDN.
|
||||
--*/
|
||||
PALIMPORT float __cdecl PAL_logf(float x)
|
||||
{
|
||||
float ret;
|
||||
PERF_ENTRY(logf);
|
||||
ENTRY("logf (x=%f)\n", x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_LOG
|
||||
errno = 0;
|
||||
#endif // !HAVE_COMPATIBLE_LOG
|
||||
|
||||
ret = logf(x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_LOG
|
||||
if ((errno == EDOM) && (x < 0))
|
||||
{
|
||||
ret = PAL_NAN_FLT; // NaN
|
||||
}
|
||||
#endif // !HAVE_COMPATIBLE_LOG
|
||||
|
||||
LOGEXIT("logf returns float %f\n", ret);
|
||||
PERF_EXIT(logf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*++
|
||||
Function:
|
||||
log10f
|
||||
|
||||
See MSDN.
|
||||
--*/
|
||||
PALIMPORT float __cdecl PAL_log10f(float x)
|
||||
{
|
||||
float ret;
|
||||
PERF_ENTRY(log10f);
|
||||
ENTRY("log10f (x=%f)\n", x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_LOG10
|
||||
errno = 0;
|
||||
#endif // !HAVE_COMPATIBLE_LOG10
|
||||
|
||||
ret = log10f(x);
|
||||
|
||||
#if !HAVE_COMPATIBLE_LOG10
|
||||
if ((errno == EDOM) && (x < 0))
|
||||
{
|
||||
ret = PAL_NAN_FLT; // NaN
|
||||
}
|
||||
#endif // !HAVE_COMPATIBLE_LOG10
|
||||
|
||||
LOGEXIT("log10f returns float %f\n", ret);
|
||||
PERF_EXIT(log10f);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*++
|
||||
Function:
|
||||
powf
|
||||
|
||||
See MSDN.
|
||||
--*/
|
||||
PALIMPORT float __cdecl PAL_powf(float x, float y)
|
||||
{
|
||||
float ret;
|
||||
PERF_ENTRY(powf);
|
||||
ENTRY("powf (x=%f, y=%f)\n", x, y);
|
||||
|
||||
#if !HAVE_COMPATIBLE_POW
|
||||
if ((y == PAL_POSINF_FLT) && !isnan(x)) // +Inf
|
||||
{
|
||||
if (x == 1.0f)
|
||||
{
|
||||
ret = x;
|
||||
}
|
||||
else if (x == -1.0f)
|
||||
{
|
||||
ret = 1.0f;
|
||||
}
|
||||
else if ((x > -1.0f) && (x < 1.0f))
|
||||
{
|
||||
ret = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = PAL_POSINF_FLT; // +Inf
|
||||
}
|
||||
}
|
||||
else if ((y == PAL_NEGINF_FLT) && !isnan(x)) // -Inf
|
||||
{
|
||||
if (x == 1.0f)
|
||||
{
|
||||
ret = x;
|
||||
}
|
||||
else if (x == -1.0f)
|
||||
{
|
||||
ret = 1.0f;
|
||||
}
|
||||
else if ((x > -1.0f) && (x < 1.0f))
|
||||
{
|
||||
ret = PAL_POSINF_FLT; // +Inf
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = 0.0f;
|
||||
}
|
||||
}
|
||||
else if (IS_FLT_NEGZERO(x) && (y == -1.0f))
|
||||
{
|
||||
ret = PAL_NEGINF_FLT; // -Inf
|
||||
}
|
||||
else if ((x == 0.0f) && (y < 0.0f))
|
||||
{
|
||||
ret = PAL_POSINF_FLT; // +Inf
|
||||
}
|
||||
else
|
||||
#endif // !HAVE_COMPATIBLE_POW
|
||||
|
||||
ret = powf(x, y);
|
||||
|
||||
#if !HAVE_VALID_NEGATIVE_INF_POW
|
||||
if ((ret == PAL_POSINF_FLT) && (x < 0) && isfinite(x) && (ceilf(y / 2) != floorf(y / 2)))
|
||||
{
|
||||
ret = PAL_NEGINF_FLT; // -Inf
|
||||
}
|
||||
#endif // !HAVE_VALID_NEGATIVE_INF_POW
|
||||
|
||||
#if !HAVE_VALID_POSITIVE_INF_POW
|
||||
/*
|
||||
* The (ceil(y/2) == floor(y/2)) test is slower, but more robust for platforms where large y
|
||||
* will return the wrong result for ((long) y % 2 == 0). See PAL_pow(double) above for more details.
|
||||
*/
|
||||
if ((ret == PAL_NEGINF_FLT) && (x < 0) && isfinite(x) && (ceilf(y / 2) == floorf(y / 2)))
|
||||
{
|
||||
ret = PAL_POSINF_FLT; // +Inf
|
||||
}
|
||||
#endif // !HAVE_VALID_POSITIVE_INF_POW
|
||||
|
||||
LOGEXIT("powf returns float %f\n", ret);
|
||||
PERF_EXIT(powf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*++
|
||||
Function:
|
||||
sincosf
|
||||
|
||||
See MSDN.
|
||||
--*/
|
||||
PALIMPORT void __cdecl PAL_sincosf(float x, float* sin, float* cos)
|
||||
{
|
||||
PERF_ENTRY(sincosf);
|
||||
ENTRY("sincosf (x=%f)\n", x);
|
||||
|
||||
#if defined(__APPLE__)
|
||||
__sincosf(x, sin, cos);
|
||||
#else
|
||||
sincosf(x, sin, cos);
|
||||
#endif // !__APPLE__
|
||||
|
||||
LOGEXIT("sincosf returns (float %f, float %f)\n", *sin, *cos);
|
||||
PERF_EXIT(sincosf);
|
||||
}
|
|
@ -236,6 +236,26 @@ function_name() to call the system's implementation
|
|||
#define tanf DUMMY_tanf
|
||||
#define tanhf DUMMY_tanhf
|
||||
#define truncf DUMMY_truncf
|
||||
#define acos DUMMMY_acos
|
||||
#define asin DUMMMY_asin
|
||||
#define atan2 DUMMMY_atan2
|
||||
#define exp DUMMMY_exp
|
||||
#define ilogb DUMMMY_ilogb
|
||||
#define log DUMMMY_log
|
||||
#define log10 DUMMMY_log10
|
||||
#define pow DUMMMY_pow
|
||||
#define sincos DUMMMY_sincos
|
||||
#define acosf DUMMMY_acosf
|
||||
#define asinf DUMMMY_asinf
|
||||
#define atan2f DUMMMY_atan2f
|
||||
#define expf DUMMMY_expf
|
||||
#define ilogbf DUMMMY_ilogbf
|
||||
#define logf DUMMMY_logf
|
||||
#define log10f DUMMMY_log10f
|
||||
#define powf DUMMMY_powf
|
||||
#define sincosf DUMMMY_sincosf
|
||||
#define copysign DUMMY_copysign
|
||||
#define copysignf DUMMY_copysignf
|
||||
#define remove DUMMY_remove
|
||||
#define printf DUMMY_printf
|
||||
#define vprintf DUMMY_vprintf
|
||||
|
@ -466,6 +486,7 @@ function_name() to call the system's implementation
|
|||
#undef pow
|
||||
#undef sin
|
||||
#undef sincos
|
||||
#undef copysign
|
||||
#undef sinh
|
||||
#undef sqrt
|
||||
#undef tan
|
||||
|
@ -495,11 +516,30 @@ function_name() to call the system's implementation
|
|||
#undef powf
|
||||
#undef sinf
|
||||
#undef sincosf
|
||||
#undef copysignf
|
||||
#undef sinhf
|
||||
#undef sqrtf
|
||||
#undef tanf
|
||||
#undef tanhf
|
||||
#undef truncf
|
||||
#undef acos
|
||||
#undef asin
|
||||
#undef atan2
|
||||
#undef exp
|
||||
#undef ilogb
|
||||
#undef log
|
||||
#undef log10
|
||||
#undef pow
|
||||
#undef sincos
|
||||
#undef acosf
|
||||
#undef asinf
|
||||
#undef atan2f
|
||||
#undef expf
|
||||
#undef ilogbf
|
||||
#undef logf
|
||||
#undef log10f
|
||||
#undef powf
|
||||
#undef sincosf
|
||||
#undef rand
|
||||
#undef srand
|
||||
#undef errno
|
||||
|
|
|
@ -63,53 +63,20 @@ add_executable_clr(paltests
|
|||
#composite/threading/threadsuspension_switchthread/threadsuspension.cpp
|
||||
#composite/wfmo/main.cpp
|
||||
#composite/wfmo/mutex.cpp
|
||||
c_runtime/abs/test1/abs.cpp
|
||||
c_runtime/acos/test1/test1.cpp
|
||||
c_runtime/acosf/test1/test1.cpp
|
||||
c_runtime/acosh/test1/test1.cpp
|
||||
c_runtime/acoshf/test1/test1.cpp
|
||||
c_runtime/asin/test1/test1.cpp
|
||||
c_runtime/asinf/test1/test1.cpp
|
||||
c_runtime/asinh/test1/test1.cpp
|
||||
c_runtime/asinhf/test1/test1.cpp
|
||||
c_runtime/atan/test1/test1.cpp
|
||||
c_runtime/atan2/test1/test1.cpp
|
||||
c_runtime/atan2f/test1/test1.cpp
|
||||
c_runtime/atanf/test1/test1.cpp
|
||||
c_runtime/atanh/test1/test1.cpp
|
||||
c_runtime/atanhf/test1/test1.cpp
|
||||
c_runtime/atof/test1/test1.cpp
|
||||
c_runtime/atoi/test1/test1.cpp
|
||||
c_runtime/bsearch/test1/test1.cpp
|
||||
c_runtime/bsearch/test2/test2.cpp
|
||||
c_runtime/cbrt/test1/test1.cpp
|
||||
c_runtime/cbrtf/test1/test1.cpp
|
||||
c_runtime/ceil/test1/test1.cpp
|
||||
c_runtime/ceilf/test1/test1.cpp
|
||||
c_runtime/cos/test1/test1.cpp
|
||||
c_runtime/cosf/test1/test1.cpp
|
||||
c_runtime/cosh/test1/test1.cpp
|
||||
c_runtime/coshf/test1/test1.cpp
|
||||
c_runtime/errno/test1/test1.cpp
|
||||
c_runtime/errno/test2/test2.cpp
|
||||
c_runtime/exit/test1/test1.cpp
|
||||
c_runtime/exit/test2/test2.cpp
|
||||
c_runtime/exp/test1/test1.cpp
|
||||
c_runtime/expf/test1/test1.cpp
|
||||
c_runtime/fabs/test1/test1.cpp
|
||||
c_runtime/fabsf/test1/test1.cpp
|
||||
c_runtime/ferror/test1/test1.cpp
|
||||
c_runtime/ferror/test2/test2.cpp
|
||||
c_runtime/fflush/test1/test1.cpp
|
||||
c_runtime/fgets/test1/test1.cpp
|
||||
c_runtime/fgets/test2/test2.cpp
|
||||
c_runtime/fgets/test3/test3.cpp
|
||||
c_runtime/floor/test1/test1.cpp
|
||||
c_runtime/floorf/test1/test1.cpp
|
||||
c_runtime/fma/test1/test1.cpp
|
||||
c_runtime/fmaf/test1/test1.cpp
|
||||
c_runtime/fmod/test1/test1.cpp
|
||||
c_runtime/fmodf/test1/test1.cpp
|
||||
c_runtime/fopen/test1/test1.cpp
|
||||
c_runtime/fopen/test2/test2.cpp
|
||||
c_runtime/fopen/test3/test3.cpp
|
||||
|
@ -126,8 +93,6 @@ add_executable_clr(paltests
|
|||
c_runtime/fseek/test1/test1.cpp
|
||||
c_runtime/ftell/test1/ftell.cpp
|
||||
c_runtime/fwrite/test1/test1.cpp
|
||||
c_runtime/ilogb/test1/test1.cpp
|
||||
c_runtime/ilogbf/test1/test1.cpp
|
||||
c_runtime/isalnum/test1/test1.cpp
|
||||
c_runtime/isalpha/test1/test1.cpp
|
||||
c_runtime/isdigit/test1/test1.cpp
|
||||
|
@ -140,34 +105,16 @@ add_executable_clr(paltests
|
|||
c_runtime/iswupper/test1/test1.cpp
|
||||
c_runtime/isxdigit/test1/test1.cpp
|
||||
c_runtime/llabs/test1/test1.cpp
|
||||
c_runtime/log/test1/test1.cpp
|
||||
c_runtime/log10/test1/test1.cpp
|
||||
c_runtime/log10f/test1/test1.cpp
|
||||
c_runtime/log2/test1/test1.cpp
|
||||
c_runtime/log2f/test1/test1.cpp
|
||||
c_runtime/logf/test1/test1.cpp
|
||||
c_runtime/malloc/test1/test1.cpp
|
||||
c_runtime/malloc/test2/test2.cpp
|
||||
c_runtime/memchr/test1/test1.cpp
|
||||
c_runtime/memcmp/test1/test1.cpp
|
||||
c_runtime/memmove/test1/test1.cpp
|
||||
c_runtime/memset/test1/test1.cpp
|
||||
c_runtime/modf/test1/test1.cpp
|
||||
c_runtime/modff/test1/test1.cpp
|
||||
c_runtime/pow/test1/test1.cpp
|
||||
c_runtime/powf/test1/test1.cpp
|
||||
c_runtime/qsort/test1/test1.cpp
|
||||
c_runtime/qsort/test2/test2.cpp
|
||||
c_runtime/rand_srand/test1/test1.cpp
|
||||
c_runtime/realloc/test1/test1.cpp
|
||||
c_runtime/sin/test1/test1.cpp
|
||||
c_runtime/sincos/test1/test1.cpp
|
||||
c_runtime/sincosf/test1/test1.cpp
|
||||
c_runtime/sinf/test1/test1.cpp
|
||||
c_runtime/sinh/test1/test1.cpp
|
||||
c_runtime/sinhf/test1/test1.cpp
|
||||
c_runtime/sqrt/test1/test1.cpp
|
||||
c_runtime/sqrtf/test1/test1.cpp
|
||||
c_runtime/sscanf_s/test1/test1.cpp
|
||||
c_runtime/sscanf_s/test10/test10.cpp
|
||||
c_runtime/sscanf_s/test11/test11.cpp
|
||||
|
@ -196,10 +143,6 @@ add_executable_clr(paltests
|
|||
c_runtime/strpbrk/test1/test1.cpp
|
||||
c_runtime/strrchr/test1/test1.cpp
|
||||
c_runtime/strstr/test1/test1.cpp
|
||||
c_runtime/tan/test1/test1.cpp
|
||||
c_runtime/tanf/test1/test1.cpp
|
||||
c_runtime/tanh/test1/test1.cpp
|
||||
c_runtime/tanhf/test1/test1.cpp
|
||||
c_runtime/time/test1/test1.cpp
|
||||
c_runtime/tolower/test1/test1.cpp
|
||||
c_runtime/toupper/test1/test1.cpp
|
||||
|
@ -224,12 +167,8 @@ add_executable_clr(paltests
|
|||
c_runtime/wcstoul/test5/test5.cpp
|
||||
c_runtime/wcstoul/test6/test6.cpp
|
||||
c_runtime/_alloca/test1/test1.cpp
|
||||
c_runtime/_finite/test1/test1.cpp
|
||||
c_runtime/_finitef/test1/test1.cpp
|
||||
#c_runtime/_gcvt/test1/_gcvt.cpp
|
||||
#c_runtime/_gcvt/test2/test2.cpp
|
||||
c_runtime/_isnan/test1/test1.cpp
|
||||
c_runtime/_isnanf/test1/test1.cpp
|
||||
c_runtime/_itow/test1/test1.cpp
|
||||
c_runtime/_putenv/test1/test1.cpp
|
||||
c_runtime/_putenv/test2/test2.cpp
|
||||
|
|
|
@ -1,118 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Checks that _finite correctly classifies all types
|
||||
** of floating point numbers (NaN, -Infinity, Infinity,
|
||||
** finite nonzero, unnormalized, 0, and -0)
|
||||
**
|
||||
**==========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
/*
|
||||
The IEEE double precision floating point standard looks like this:
|
||||
|
||||
S EEEEEEEEEEE FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
|
||||
0 1 11 12 63
|
||||
|
||||
S is the sign bit. The E bits are the exponent, and the 52 F bits are
|
||||
the fraction. These represent a value, V.
|
||||
|
||||
If E=2047 and F is nonzero, then V=NaN ("Not a number")
|
||||
If E=2047 and F is zero and S is 1, then V=-Infinity
|
||||
If E=2047 and F is zero and S is 0, then V=Infinity
|
||||
If 0<E<2047 then V=(-1)^S * 2^(E-1023) * (1.F) where "1.F" is the binary
|
||||
number created by prefixing F with a leading 1 and a binary point.
|
||||
If E=0 and F is nonzero, then V=(-1)^S * 2^(-1022) * (0.F) These are
|
||||
"unnormalized" values.
|
||||
If E=0 and F is zero and S is 1, then V=-0
|
||||
If E=0 and F is zero and S is 0, then V=0
|
||||
|
||||
*/
|
||||
|
||||
#define TO_DOUBLE(x) (*((double*)((void*)&x)))
|
||||
|
||||
PALTEST(c_runtime__finite_test1_paltest_finite_test1, "c_runtime/_finite/test1/paltest_finite_test1")
|
||||
{
|
||||
/*non-finite numbers*/
|
||||
UINT64 lsnan = UI64(0xffffffffffffffff);
|
||||
UINT64 lqnan = UI64(0x7fffffffffffffff);
|
||||
UINT64 lneginf = UI64(0xfff0000000000000);
|
||||
UINT64 lposinf = UI64(0x7ff0000000000000);
|
||||
|
||||
double snan = TO_DOUBLE(lsnan);
|
||||
double qnan = TO_DOUBLE(lqnan);
|
||||
double neginf = TO_DOUBLE(lneginf);
|
||||
double posinf = TO_DOUBLE(lposinf);
|
||||
|
||||
/*finite numbers*/
|
||||
UINT64 lnegunnormalized = UI64(0x800fffffffffffff);
|
||||
UINT64 lposunnormalized = UI64(0x000fffffffffffff);
|
||||
UINT64 lnegzero = UI64(0x8000000000000000);
|
||||
|
||||
double negunnormalized = TO_DOUBLE(lnegunnormalized);
|
||||
double posunnormalized = TO_DOUBLE(lposunnormalized);
|
||||
double negzero = TO_DOUBLE(lnegzero);
|
||||
|
||||
/*
|
||||
* Initialize the PAL and return FAIL if this fails
|
||||
*/
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
/*non-finite numbers*/
|
||||
if (_finite(snan) || _finite(qnan))
|
||||
{
|
||||
Fail("_finite() found NAN to be finite.\n");
|
||||
}
|
||||
|
||||
if (_finite(neginf))
|
||||
{
|
||||
Fail("_finite() found negative infinity to be finite.\n");
|
||||
}
|
||||
|
||||
if (_finite(posinf))
|
||||
{
|
||||
Fail("_finite() found infinity to be finite.\n");
|
||||
}
|
||||
|
||||
/*finite numbers*/
|
||||
if (!_finite(negunnormalized))
|
||||
{
|
||||
Fail("_finite() found a negative unnormalized value to be infinite.\n");
|
||||
}
|
||||
|
||||
if (!_finite(posunnormalized))
|
||||
{
|
||||
Fail("_finite() found an unnormalized value to be infinite.\n");
|
||||
}
|
||||
|
||||
if (!_finite(negzero))
|
||||
{
|
||||
Fail("_finite() found negative zero to be infinite.\n");
|
||||
}
|
||||
|
||||
if (!_finite(+0.0))
|
||||
{
|
||||
Fail("_finite() found zero to be infinite.\n");
|
||||
}
|
||||
|
||||
if (!_finite(-123.456))
|
||||
{
|
||||
Fail("_finite() found %f to be infinite.\n", -123.456);
|
||||
}
|
||||
|
||||
if (!_finite(+123.456))
|
||||
{
|
||||
Fail("_finite() found %f to be infinite.\n", +123.456);
|
||||
}
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,118 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Checks that _finitef correctly classifies all types
|
||||
** of floating point numbers (NaN, -Infinity, Infinity,
|
||||
** finite nonzero, unnormalized, 0, and -0)
|
||||
**
|
||||
**==========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
/*
|
||||
The IEEE single precision floating point standard looks like this:
|
||||
|
||||
S EEEEEEEE FFFFFFFFFFFFFFFFFFFFFFF
|
||||
0 1 8 9 31
|
||||
|
||||
S is the sign bit. The E bits are the exponent, and the 23 F bits are
|
||||
the fraction. These represent a value, V.
|
||||
|
||||
If E=255 and F is nonzero, then V=NaN ("Not a number")
|
||||
If E=255 and F is zero and S is 1, then V=-Infinity
|
||||
If E=255 and F is zero and S is 0, then V=Infinity
|
||||
If 0<E<255 then V=(-1)^S * 2^(E-1028) * (1.F) where "1.F" is the binary
|
||||
number created by prefixing F with a leading 1 and a binary point.
|
||||
If E=0 and F is nonzero, then V=(-1)^S * 2^(-127) * (0.F) These are
|
||||
"unnormalized" values.
|
||||
If E=0 and F is zero and S is 1, then V=-0
|
||||
If E=0 and F is zero and S is 0, then V=0
|
||||
|
||||
*/
|
||||
|
||||
#define TO_FLOAT(x) (*((float*)((void*)&x)))
|
||||
|
||||
PALTEST(c_runtime__finitef_test1_paltest_finitef_test1, "c_runtime/_finitef/test1/paltest_finitef_test1")
|
||||
{
|
||||
/*non-finite numbers*/
|
||||
UINT32 lsnan = 0xffffffffu;
|
||||
UINT32 lqnan = 0x7fffffffu;
|
||||
UINT32 lneginf = 0xff800000u;
|
||||
UINT32 lposinf = 0x7f800000u;
|
||||
|
||||
float snan = TO_FLOAT(lsnan);
|
||||
float qnan = TO_FLOAT(lqnan);
|
||||
float neginf = TO_FLOAT(lneginf);
|
||||
float posinf = TO_FLOAT(lposinf);
|
||||
|
||||
/*finite numbers*/
|
||||
UINT32 lnegunnormalized = 0x807fffffu;
|
||||
UINT32 lposunnormalized = 0x007fffffu;
|
||||
UINT32 lnegzero = 0x80000000u;
|
||||
|
||||
float negunnormalized = TO_FLOAT(lnegunnormalized);
|
||||
float posunnormalized = TO_FLOAT(lposunnormalized);
|
||||
float negzero = TO_FLOAT(lnegzero);
|
||||
|
||||
/*
|
||||
* Initialize the PAL and return FAIL if this fails
|
||||
*/
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
/*non-finite numbers*/
|
||||
if (_finitef(snan) || _finitef(qnan))
|
||||
{
|
||||
Fail("_finitef() found NAN to be finite.\n");
|
||||
}
|
||||
|
||||
if (_finitef(neginf))
|
||||
{
|
||||
Fail("_finitef() found negative infinity to be finite.\n");
|
||||
}
|
||||
|
||||
if (_finitef(posinf))
|
||||
{
|
||||
Fail("_finitef() found infinity to be finite.\n");
|
||||
}
|
||||
|
||||
/*finite numbers*/
|
||||
if (!_finitef(negunnormalized))
|
||||
{
|
||||
Fail("_finitef() found a negative unnormalized value to be infinite.\n");
|
||||
}
|
||||
|
||||
if (!_finitef(posunnormalized))
|
||||
{
|
||||
Fail("_finitef() found an unnormalized value to be infinite.\n");
|
||||
}
|
||||
|
||||
if (!_finitef(negzero))
|
||||
{
|
||||
Fail("_finitef() found negative zero to be infinite.\n");
|
||||
}
|
||||
|
||||
if (!_finitef(+0.0f))
|
||||
{
|
||||
Fail("_finitef() found zero to be infinite.\n");
|
||||
}
|
||||
|
||||
if (!_finitef(-123.456f))
|
||||
{
|
||||
Fail("_finitef() found %f to be infinite.\n", -123.456f);
|
||||
}
|
||||
|
||||
if (!_finitef(+123.456f))
|
||||
{
|
||||
Fail("_finitef() found %f to be infinite.\n", +123.456f);
|
||||
}
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,114 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose:
|
||||
** Test _isnan with a number of trivial values, to ensure they indicated that
|
||||
** they are numbers. Then try with Positive/Negative Infinite, which should
|
||||
** also be numbers. Finally set the least and most significant bits of
|
||||
** the fraction to positive and negative, at which point it should return
|
||||
** the true value.
|
||||
**
|
||||
**==========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
#define TO_DOUBLE(x) (*((double*)((void*)&x)))
|
||||
#define TO_I64(x) (*((INT64*)((void*)&x)))
|
||||
|
||||
/*
|
||||
* NaN: any double with maximum exponent (0x7ff) and non-zero fraction
|
||||
*/
|
||||
PALTEST(c_runtime__isnan_test1_paltest_isnan_test1, "c_runtime/_isnan/test1/paltest_isnan_test1")
|
||||
{
|
||||
/*
|
||||
* Initialize the PAL and return FAIL if this fails
|
||||
*/
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Try some trivial values
|
||||
*/
|
||||
if (_isnan(0.0))
|
||||
{
|
||||
Fail("_isnan() incorrectly identified %f as NaN!\n", 0.0);
|
||||
}
|
||||
|
||||
if (_isnan(1.23456))
|
||||
{
|
||||
Fail("_isnan() incorrectly identified %f as NaN!\n", 1.234567);
|
||||
}
|
||||
|
||||
if (_isnan(42.0))
|
||||
{
|
||||
Fail("_isnan() incorrectly identified %f as NaN!\n", 42.0);
|
||||
}
|
||||
|
||||
UINT64 lneginf = UI64(0xfff0000000000000);
|
||||
UINT64 lposinf = UI64(0x7ff0000000000000);
|
||||
|
||||
double neginf = TO_DOUBLE(lneginf);
|
||||
double posinf = TO_DOUBLE(lposinf);
|
||||
|
||||
/*
|
||||
* Try positive and negative infinity
|
||||
*/
|
||||
if (_isnan(neginf))
|
||||
{
|
||||
Fail("_isnan() incorrectly identified negative infinity as NaN!\n");
|
||||
}
|
||||
|
||||
if (_isnan(posinf))
|
||||
{
|
||||
Fail("_isnan() incorrectly identified infinity as NaN!\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Try setting the least significant bit of the fraction,
|
||||
* positive and negative
|
||||
*/
|
||||
UINT64 lsnan = UI64(0xfff0000000000001);
|
||||
double snan = TO_DOUBLE(lsnan);
|
||||
|
||||
if (!_isnan(snan))
|
||||
{
|
||||
Fail("_isnan() failed to identify %I64x as NaN!\n", lsnan);
|
||||
}
|
||||
|
||||
UINT64 lqnan = UI64(0x7ff0000000000001);
|
||||
double qnan = TO_DOUBLE(lqnan);
|
||||
|
||||
if (!_isnan(qnan))
|
||||
{
|
||||
Fail("_isnan() failed to identify %I64x as NaN!\n", lqnan);
|
||||
}
|
||||
|
||||
/*
|
||||
* Try setting the most significant bit of the fraction,
|
||||
* positive and negative
|
||||
*/
|
||||
lsnan = UI64(0xfff8000000000000);
|
||||
snan = TO_DOUBLE(lsnan);
|
||||
|
||||
if (!_isnan(snan))
|
||||
{
|
||||
Fail ("_isnan() failed to identify %I64x as NaN!\n", lsnan);
|
||||
}
|
||||
|
||||
lqnan = UI64(0x7ff8000000000000);
|
||||
qnan = TO_DOUBLE(lqnan);
|
||||
|
||||
if (!_isnan(qnan))
|
||||
{
|
||||
Fail ("_isnan() failed to identify %I64x as NaN!\n", lqnan);
|
||||
}
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,114 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose:
|
||||
** Test _isnanf with a number of trivial values, to ensure they indicated that
|
||||
** they are numbers. Then try with Positive/Negative Infinite, which should
|
||||
** also be numbers. Finally set the least and most significant bits of
|
||||
** the fraction to positive and negative, at which point it should return
|
||||
** the true value.
|
||||
**
|
||||
**==========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
#define TO_FLOAT(x) (*((float*)((void*)&x)))
|
||||
#define TO_I32(x) (*((INT32*)((void*)&x)))
|
||||
|
||||
/*
|
||||
* NaN: any float with maximum exponent (0x7f8) and non-zero fraction
|
||||
*/
|
||||
PALTEST(c_runtime__isnanf_test1_paltest_isnanf_test1, "c_runtime/_isnanf/test1/paltest_isnanf_test1")
|
||||
{
|
||||
/*
|
||||
* Initialize the PAL and return FAIL if this fails
|
||||
*/
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Try some trivial values
|
||||
*/
|
||||
if (_isnanf(0.0f))
|
||||
{
|
||||
Fail("_isnanf() incorrectly identified %f as NaN!\n", 0.0f);
|
||||
}
|
||||
|
||||
if (_isnanf(1.234567f))
|
||||
{
|
||||
Fail("_isnanf() incorrectly identified %f as NaN!\n", 1.234567f);
|
||||
}
|
||||
|
||||
if (_isnanf(42.0f))
|
||||
{
|
||||
Fail("_isnanf() incorrectly identified %f as NaN!\n", 42.0f);
|
||||
}
|
||||
|
||||
UINT32 lneginf = 0xff800000u;
|
||||
UINT32 lposinf = 0x7f800000u;
|
||||
|
||||
float neginf = TO_FLOAT(lneginf);
|
||||
float posinf = TO_FLOAT(lposinf);
|
||||
|
||||
/*
|
||||
* Try positive and negative infinity
|
||||
*/
|
||||
if (_isnanf(neginf))
|
||||
{
|
||||
Fail("_isnanf() incorrectly identified negative infinity as NaN!\n");
|
||||
}
|
||||
|
||||
if (_isnanf(posinf))
|
||||
{
|
||||
Fail("_isnanf() incorrectly identified infinity as NaN!\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Try setting the least significant bit of the fraction,
|
||||
* positive and negative
|
||||
*/
|
||||
UINT32 lsnan = 0xff800001u;
|
||||
float snan = TO_FLOAT(lsnan);
|
||||
|
||||
if (!_isnanf(snan))
|
||||
{
|
||||
Fail("_isnanf() failed to identify %I32x as NaN!\n", lsnan);
|
||||
}
|
||||
|
||||
UINT32 lqnan = 0x7f800001u;
|
||||
float qnan = TO_FLOAT(lqnan);
|
||||
|
||||
if (!_isnanf(qnan))
|
||||
{
|
||||
Fail("_isnanf() failed to identify %I32x as NaN!\n", lqnan);
|
||||
}
|
||||
|
||||
/*
|
||||
* Try setting the most significant bit of the fraction,
|
||||
* positive and negative
|
||||
*/
|
||||
lsnan = 0xffc00000u;
|
||||
snan = TO_FLOAT(lsnan);
|
||||
|
||||
if (!_isnanf(snan))
|
||||
{
|
||||
Fail ("_isnanf() failed to identify %I32x as NaN!\n", lsnan);
|
||||
}
|
||||
|
||||
lqnan = 0x7fc00000u;
|
||||
qnan = TO_FLOAT(lqnan);
|
||||
|
||||
if (!_isnanf(qnan))
|
||||
{
|
||||
Fail ("_isnanf() failed to identify %I32x as NaN!\n", lqnan);
|
||||
}
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=====================================================================
|
||||
**
|
||||
** Source: abs.c (test 1)
|
||||
**
|
||||
** Purpose: Tests the PAL implementation of the abs function.
|
||||
**
|
||||
**
|
||||
**===================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
struct TESTS
|
||||
{
|
||||
int nTest;
|
||||
int nResult;
|
||||
};
|
||||
|
||||
PALTEST(c_runtime_abs_test1_paltest_abs_test1, "c_runtime/abs/test1/paltest_abs_test1")
|
||||
{
|
||||
int i = 0;
|
||||
int nRc = 0;
|
||||
struct TESTS testCase[] =
|
||||
{
|
||||
{0, 0},
|
||||
{1, 1},
|
||||
{-1, 1}
|
||||
};
|
||||
|
||||
|
||||
if (0 != PAL_Initialize(argc,argv))
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (i = 0; i < (sizeof(testCase)/sizeof(struct TESTS)); i++)
|
||||
{
|
||||
nRc = abs(testCase[i].nTest);
|
||||
if (nRc != testCase[i].nResult)
|
||||
{
|
||||
Fail("abs: ERROR -> abs(%d) returned %d "
|
||||
"when it was expected to return %d \n",
|
||||
testCase[i].nTest,
|
||||
nRc,
|
||||
testCase[i].nResult);
|
||||
}
|
||||
}
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that acos return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double value; /* value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* acos_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl acos_test1_validate(double value, double expected, double variance)
|
||||
{
|
||||
double result = acos(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("acos(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* acos_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl acos_test1_validate_isnan(double value)
|
||||
{
|
||||
double result = acos(value);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("acos(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_acos_test1_paltest_acos_test1, "c_runtime/acos/test1/paltest_acos_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ -1, 3.1415926535897932, PAL_EPSILON * 10 }, // expected: pi
|
||||
{ -0.91173391478696510, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e
|
||||
{ -0.66820151019031295, 2.3025850929940457, PAL_EPSILON * 10 }, // expected: ln(10)
|
||||
{ 0, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2
|
||||
{ 0.12775121753523991, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e)
|
||||
{ 0.15594369476537447, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2)
|
||||
{ 0.42812514788535792, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi)
|
||||
{ 0.54030230586813972, 1, PAL_EPSILON * 10 },
|
||||
{ 0.70710678118654752, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4, value: 1 / sqrt(2)
|
||||
{ 0.76024459707563015, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2)
|
||||
{ 0.76923890136397213, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2)
|
||||
{ 0.80410982822879171, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi
|
||||
{ 0.90716712923909839, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e)
|
||||
{ 0.94976571538163866, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi
|
||||
{ 1, 0, PAL_EPSILON },
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
acos_test1_validate(tests[i].value, tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
acos_test1_validate_isnan(PAL_NEGINF);
|
||||
acos_test1_validate_isnan(PAL_NAN);
|
||||
acos_test1_validate_isnan(PAL_POSINF);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,128 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that acosf return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrtf(-1.0f)
|
||||
#define PAL_POSINF -logf(0.0f)
|
||||
#define PAL_NEGINF logf(0.0f)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float value; /* value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* acosf_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl acosf_test1_validate(float value, float expected, float variance)
|
||||
{
|
||||
float result = acosf(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("acosf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* acosf_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl acosf_test1_validate_isnan(float value)
|
||||
{
|
||||
float result = acosf(value);
|
||||
|
||||
if (!_isnanf(result))
|
||||
{
|
||||
Fail("acosf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_acosf_test1_paltest_acosf_test1, "c_runtime/acosf/test1/paltest_acosf_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ -1, 3.14159265f, PAL_EPSILON * 10 }, // expected: pi
|
||||
{ -0.911733915f, 2.71828183f, PAL_EPSILON * 10 }, // expected: e
|
||||
{ -0.668201510f, 2.30258509f, PAL_EPSILON * 10 }, // expected: ln(10)
|
||||
{ 0, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2
|
||||
{ 0.127751218f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e)
|
||||
{ 0.155943695f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2)
|
||||
{ 0.428125148f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi)
|
||||
{ 0.540302306f, 1, PAL_EPSILON * 10 },
|
||||
{ 0.707106781f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4, value: 1 / sqrtf(2)
|
||||
{ 0.760244597f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2)
|
||||
{ 0.769238901f, 0.693147181f, PAL_EPSILON }, // expected: ln(2)
|
||||
{ 0.804109828f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi
|
||||
{ 0.907167129f, 0.434294482f, PAL_EPSILON }, // expected: logf10f(e)
|
||||
{ 0.949765715f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi
|
||||
{ 1, 0, PAL_EPSILON },
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
acosf_test1_validate(tests[i].value, tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
acosf_test1_validate_isnan(PAL_NEGINF);
|
||||
acosf_test1_validate_isnan(PAL_NAN);
|
||||
acosf_test1_validate_isnan(PAL_POSINF);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,128 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that acosh return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double value; /* value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* acosh_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl acosh_test1_validate(double value, double expected, double variance)
|
||||
{
|
||||
double result = acosh(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("acosh(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* acosh_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl acosh_test1_validate_isnan(double value)
|
||||
{
|
||||
double result = acosh(value);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("acosh(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_acosh_test1_paltest_acosh_test1, "c_runtime/acosh/test1/paltest_acosh_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 1, 0, PAL_EPSILON },
|
||||
{ 1.0510897883672876, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi
|
||||
{ 1.0957974645564909, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e)
|
||||
{ 1.2095794864199787, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi
|
||||
{ 1.25, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2)
|
||||
{ 1.2605918365213561, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2)
|
||||
{ 1.3246090892520058, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4
|
||||
{ 1.5430806348152438, 1, PAL_EPSILON * 10 },
|
||||
{ 1.7071001431069344, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi)
|
||||
{ 2.1781835566085709, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2)
|
||||
{ 2.2341880974508023, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e)
|
||||
{ 2.5091784786580568, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2
|
||||
{ 5.05, 2.3025850929940457, PAL_EPSILON * 10 }, // expected: ln(10)
|
||||
{ 7.6101251386622884, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e
|
||||
{ 11.591953275521521, 3.1415926535897932, PAL_EPSILON * 10 }, // expected: pi
|
||||
{ PAL_POSINF, PAL_POSINF, 0 },
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
acosh_test1_validate(tests[i].value, tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
acosh_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that acoshf return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrtf(-1.0f)
|
||||
#define PAL_POSINF -logf(0.0f)
|
||||
#define PAL_NEGINF logf(0.0f)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float value; /* value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* acoshf_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl acoshf_test1_validate(float value, float expected, float variance)
|
||||
{
|
||||
float result = acoshf(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("acoshf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* acoshf_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl acoshf_test1_validate_isnan(float value)
|
||||
{
|
||||
float result = acoshf(value);
|
||||
|
||||
if (!_isnanf(result))
|
||||
{
|
||||
Fail("acoshf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_acoshf_test1_paltest_acoshf_test1, "c_runtime/acoshf/test1/paltest_acoshf_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 1, 0, PAL_EPSILON },
|
||||
{ 1.05108979f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi
|
||||
{ 1.09579746f, 0.434294482f, PAL_EPSILON }, // expected: log10f(e)
|
||||
{ 1.20957949f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi
|
||||
{ 1.25f, 0.693147181f, PAL_EPSILON }, // expected: ln(2)
|
||||
{ 1.26059184f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2)
|
||||
{ 1.32460909f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4
|
||||
{ 1.54308063f, 1, PAL_EPSILON * 10 },
|
||||
{ 1.70710014f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi)
|
||||
{ 2.17818356f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2)
|
||||
{ 2.23418810f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e)
|
||||
{ 2.50917848f, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2
|
||||
{ 5.05f, 2.30258509f, PAL_EPSILON * 10 }, // expected: ln(10)
|
||||
{ 7.61012514f, 2.71828183f, PAL_EPSILON * 10 }, // expected: e
|
||||
{ 11.5919533f, 3.14159265f, PAL_EPSILON * 100 }, // expected: pi
|
||||
{ PAL_POSINF, PAL_POSINF, 0 },
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
acoshf_test1_validate(tests[i].value, tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
acoshf_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,145 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that asin return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double value; /* value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* asin_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl asin_test1_validate(double value, double expected, double variance)
|
||||
{
|
||||
double result = asin(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("asin(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* asin_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl asin_test1_validate_isnan(double value)
|
||||
{
|
||||
double result = asin(value);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("asin(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* asin_test1_validate
|
||||
*
|
||||
* test validation function for values returning +INF
|
||||
*/
|
||||
void __cdecl asin_test1_validate_isinf_positive(double value)
|
||||
{
|
||||
double result = asin(value);
|
||||
|
||||
if (result != PAL_POSINF)
|
||||
{
|
||||
Fail("asin(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, PAL_POSINF);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_asin_test1_paltest_asin_test1, "c_runtime/asin/test1/paltest_asin_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, 0, PAL_EPSILON },
|
||||
{ 0.31296179620778659, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi
|
||||
{ 0.41078129050290870, 0.42331082513074800, PAL_EPSILON }, // expected: pi - e
|
||||
{ 0.42077048331375735, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e)
|
||||
{ 0.59448076852482208, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi
|
||||
{ 0.63896127631363480, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2)
|
||||
{ 0.64963693908006244, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2)
|
||||
{ 0.70710678118654752, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4, value: 1 / sqrt(2)
|
||||
{ 0.74398033695749319, 0.83900756059574755, PAL_EPSILON }, // expected: pi - ln(10)
|
||||
{ 0.84147098480789651, 1, PAL_EPSILON * 10 },
|
||||
{ 0.90371945743584630, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi)
|
||||
{ 0.98776594599273553, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2)
|
||||
{ 0.99180624439366372, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e)
|
||||
{ 1, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
asin_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
asin_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
asin_test1_validate_isnan(PAL_NEGINF);
|
||||
asin_test1_validate_isnan(PAL_NAN);
|
||||
asin_test1_validate_isnan(PAL_POSINF);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,144 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that asinf return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrtf(-1.0f)
|
||||
#define PAL_POSINF -logf(0.0f)
|
||||
#define PAL_NEGINF logf(0.0f)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float value; /* value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* asinf_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl asinf_test1_validate(float value, float expected, float variance)
|
||||
{
|
||||
float result = asinf(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("asinf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* asinf_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl asinf_test1_validate_isnan(float value)
|
||||
{
|
||||
float result = asinf(value);
|
||||
|
||||
if (!_isnanf(result))
|
||||
{
|
||||
Fail("asinf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* asinf_test1_validate
|
||||
*
|
||||
* test validation function for values returning +INF
|
||||
*/
|
||||
void __cdecl asinf_test1_validate_isinf_positive(float value)
|
||||
{
|
||||
float result = asinf(value);
|
||||
|
||||
if (result != PAL_POSINF)
|
||||
{
|
||||
Fail("asinf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, PAL_POSINF);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_asinf_test1_paltest_asinf_test1, "c_runtime/asinf/test1/paltest_asinf_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, 0, PAL_EPSILON },
|
||||
{ 0.312961796f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi
|
||||
{ 0.410781291f, 0.423310825f, PAL_EPSILON }, // expected: pi - e
|
||||
{ 0.420770483f, 0.434294482f, PAL_EPSILON }, // expected: logf10f(e)
|
||||
{ 0.594480769f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi
|
||||
{ 0.638961276f, 0.693147181f, PAL_EPSILON }, // expected: ln(2)
|
||||
{ 0.649636939f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2)
|
||||
{ 0.707106781f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4, value: 1 / sqrtf(2)
|
||||
{ 0.743980337f, 0.839007561f, PAL_EPSILON }, // expected: pi - ln(10)
|
||||
{ 0.841470985f, 1, PAL_EPSILON * 10 },
|
||||
{ 0.903719457f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi)
|
||||
{ 0.987765946f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2)
|
||||
{ 0.991806244f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e)
|
||||
{ 1, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
asinf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
asinf_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
asinf_test1_validate_isnan(PAL_NEGINF);
|
||||
asinf_test1_validate_isnan(PAL_NAN);
|
||||
asinf_test1_validate_isnan(PAL_POSINF);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,145 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that asinh return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double value; /* value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* asinh_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl asinh_test1_validate(double value, double expected, double variance)
|
||||
{
|
||||
double result = asinh(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("asinh(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* asinh_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl asinh_test1_validate_isnan(double value)
|
||||
{
|
||||
double result = asinh(value);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("asinh(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* asinh_test1_validate
|
||||
*
|
||||
* test validation function for values returning +INF
|
||||
*/
|
||||
void __cdecl asinh_test1_validate_isinf_positive(double value)
|
||||
{
|
||||
double result = asinh(value);
|
||||
|
||||
if (result != PAL_POSINF)
|
||||
{
|
||||
Fail("asinh(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, PAL_POSINF);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_asinh_test1_paltest_asinh_test1, "c_runtime/asinh/test1/paltest_asinh_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, 0, PAL_EPSILON },
|
||||
{ 0.32371243907207108, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi
|
||||
{ 0.44807597941469025, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e)
|
||||
{ 0.68050167815224332, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi
|
||||
{ 0.75, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2)
|
||||
{ 0.76752314512611633, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2)
|
||||
{ 0.86867096148600961, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4
|
||||
{ 1.1752011936438015, 1, PAL_EPSILON * 10 },
|
||||
{ 1.3835428792038633, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi)
|
||||
{ 1.9350668221743567, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2)
|
||||
{ 1.9978980091062796, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e)
|
||||
{ 2.3012989023072949, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2
|
||||
{ 4.95, 2.3025850929940457, PAL_EPSILON * 10 }, // expected: ln(10)
|
||||
{ 7.5441371028169758, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e
|
||||
{ 11.548739357257748, 3.1415926535897932, PAL_EPSILON * 10 }, // expected: pi
|
||||
{ PAL_POSINF, PAL_POSINF, 0 },
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
asinh_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
asinh_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
asinh_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,144 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that asinhf return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrtf(-1.0f)
|
||||
#define PAL_POSINF -logf(0.0f)
|
||||
#define PAL_NEGINF logf(0.0f)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float value; /* value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* asinhf_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl asinhf_test1_validate(float value, float expected, float variance)
|
||||
{
|
||||
float result = asinhf(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("asinhf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* asinhf_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl asinhf_test1_validate_isnan(float value)
|
||||
{
|
||||
float result = asinhf(value);
|
||||
|
||||
if (!_isnanf(result))
|
||||
{
|
||||
Fail("asinhf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* asinhf_test1_validate
|
||||
*
|
||||
* test validation function for values returning +INF
|
||||
*/
|
||||
void __cdecl asinhf_test1_validate_isinf_positive(float value)
|
||||
{
|
||||
float result = asinhf(value);
|
||||
|
||||
if (result != PAL_POSINF)
|
||||
{
|
||||
Fail("asinhf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, PAL_POSINF);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_asinhf_test1_paltest_asinhf_test1, "c_runtime/asinhf/test1/paltest_asinhf_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, 0, PAL_EPSILON },
|
||||
{ 0.323712439f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi
|
||||
{ 0.448075979f, 0.434294482f, PAL_EPSILON }, // expected: log10f(e)
|
||||
{ 0.680501678f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi
|
||||
{ 0.75, 0.693147181f, PAL_EPSILON }, // expected: ln(2)
|
||||
{ 0.767523145f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2)
|
||||
{ 0.868670961f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4
|
||||
{ 1.17520119f, 1, PAL_EPSILON * 10 },
|
||||
{ 1.38354288f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi)
|
||||
{ 1.93506682f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2)
|
||||
{ 1.99789801f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e)
|
||||
{ 2.30129890f, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2
|
||||
{ 4.95f, 2.30258509f, PAL_EPSILON * 10 }, // expected: ln(10)
|
||||
{ 7.54413710f, 2.71828183f, PAL_EPSILON * 10 }, // expected: e
|
||||
{ 11.5487394f, 3.14159265f, PAL_EPSILON * 10 }, // expected: pi
|
||||
{ PAL_POSINF, PAL_POSINF, 0 },
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
asinhf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
asinhf_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
asinhf_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that atan return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double value; /* value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* atan_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl atan_test1_validate(double value, double expected, double variance)
|
||||
{
|
||||
double result = atan(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("atan(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* atan_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl atan_test1_validate_isnan(double value)
|
||||
{
|
||||
double result = atan(value);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("atan(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_atan_test1_paltest_atan_test1, "c_runtime/atan/test1/paltest_atan_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, 0, PAL_EPSILON },
|
||||
{ 0.32951473309607836, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi
|
||||
{ 0.45054953406980750, 0.42331082513074800, PAL_EPSILON }, // expected: pi - e
|
||||
{ 0.46382906716062964, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e)
|
||||
{ 0.73930295048660405, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi
|
||||
{ 0.83064087786078395, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2)
|
||||
{ 0.85451043200960189, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2)
|
||||
{ 1, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4
|
||||
{ 1.1134071468135374, 0.83900756059574755, PAL_EPSILON }, // expected: pi - ln(10)
|
||||
{ 1.5574077246549022, 1, PAL_EPSILON * 10 },
|
||||
{ 2.1108768356626451, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi)
|
||||
{ 6.3341191670421916, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2)
|
||||
{ 7.7635756709721848, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e)
|
||||
{ PAL_POSINF, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
atan_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
atan_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
atan_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,147 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=====================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Tests that atan2 returns correct values for a subset of values.
|
||||
** Tests with positive and negative values of x and y to ensure
|
||||
** atan2 is returning results from the correct quadrant.
|
||||
**
|
||||
**===================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
struct test
|
||||
{
|
||||
double y; /* second component of the value to test the function with */
|
||||
double x; /* first component of the value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* atan2_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl atan2_test1_validate(double y, double x, double expected, double variance)
|
||||
{
|
||||
double result = atan2(y, x);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("atan2(%g, %g) returned %20.17g when it should have returned %20.17g",
|
||||
y, x, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* atan2_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl atan2_test1_validate_isnan(double y, double x)
|
||||
{
|
||||
double result = atan2(y, x);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("atan2(%g, %g) returned %20.17g when it should have returned %20.17g",
|
||||
y, x, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_atan2_test1_paltest_atan2_test1, "c_runtime/atan2/test1/paltest_atan2_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* y x expected variance */
|
||||
{ 0, PAL_POSINF, 0, PAL_EPSILON },
|
||||
{ 0, 0, 0, PAL_EPSILON },
|
||||
{ 0.31296179620778659, 0.94976571538163866, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi
|
||||
{ 0.42077048331375735, 0.90716712923909839, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e)
|
||||
{ 0.59448076852482208, 0.80410982822879171, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi
|
||||
{ 0.63896127631363480, 0.76923890136397213, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2)
|
||||
{ 0.64963693908006244, 0.76024459707563015, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2)
|
||||
{ 0.70710678118654752, 0.70710678118654752, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4, value: 1 / sqrt(2)
|
||||
{ 1, 1, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4
|
||||
{ PAL_POSINF, PAL_POSINF, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4
|
||||
{ 0.84147098480789651, 0.54030230586813972, 1, PAL_EPSILON * 10 },
|
||||
{ 0.90371945743584630, 0.42812514788535792, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi)
|
||||
{ 0.98776594599273553, 0.15594369476537447, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2)
|
||||
{ 0.99180624439366372, 0.12775121753523991, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e)
|
||||
{ 1, 0, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2
|
||||
{ PAL_POSINF, 0, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2
|
||||
{ PAL_POSINF, 1, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2
|
||||
{ 0.74398033695749319, -0.66820151019031295, 2.3025850929940457, PAL_EPSILON * 10 }, // expected: ln(10)
|
||||
{ 0.41078129050290870, -0.91173391478696510, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e
|
||||
{ 0, -1, 3.1415926535897932, PAL_EPSILON * 10 }, // expected: pi
|
||||
{ 1, PAL_POSINF, 0, PAL_EPSILON },
|
||||
};
|
||||
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
const double pi = 3.1415926535897932;
|
||||
|
||||
atan2_test1_validate( tests[i].y, tests[i].x, tests[i].expected, tests[i].variance);
|
||||
atan2_test1_validate(-tests[i].y, tests[i].x, -tests[i].expected, tests[i].variance);
|
||||
atan2_test1_validate( tests[i].y, -tests[i].x, pi - tests[i].expected, tests[i].variance);
|
||||
atan2_test1_validate(-tests[i].y, -tests[i].x, tests[i].expected - pi, tests[i].variance);
|
||||
}
|
||||
|
||||
atan2_test1_validate_isnan(PAL_NEGINF, PAL_NAN);
|
||||
atan2_test1_validate_isnan(PAL_NAN, PAL_NEGINF);
|
||||
atan2_test1_validate_isnan(PAL_NAN, PAL_POSINF);
|
||||
atan2_test1_validate_isnan(PAL_POSINF, PAL_NAN);
|
||||
|
||||
atan2_test1_validate_isnan(PAL_NAN, -1);
|
||||
atan2_test1_validate_isnan(PAL_NAN, -0.0);
|
||||
atan2_test1_validate_isnan(PAL_NAN, 0);
|
||||
atan2_test1_validate_isnan(PAL_NAN, 1);
|
||||
|
||||
atan2_test1_validate_isnan(-1, PAL_NAN);
|
||||
atan2_test1_validate_isnan(-0.0, PAL_NAN);
|
||||
atan2_test1_validate_isnan( 0, PAL_NAN);
|
||||
atan2_test1_validate_isnan( 1, PAL_NAN);
|
||||
|
||||
atan2_test1_validate_isnan(PAL_NAN, PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,146 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=====================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Tests that atan2f returns correct values for a subset of values.
|
||||
** Tests with positive and negative values of x and y to ensure
|
||||
** atan2f is returning results from the correct quadrant.
|
||||
**
|
||||
**===================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrtf(-1.0f)
|
||||
#define PAL_POSINF -logf(0.0f)
|
||||
#define PAL_NEGINF logf(0.0f)
|
||||
|
||||
struct test
|
||||
{
|
||||
float y; /* second component of the value to test the function with */
|
||||
float x; /* first component of the value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* atan2f_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl atan2f_test1_validate(float y, float x, float expected, float variance)
|
||||
{
|
||||
float result = atan2f(y, x);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("atan2f(%g, %g) returned %10.9g when it should have returned %10.9g",
|
||||
y, x, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* atan2f_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl atan2f_test1_validate_isnan(float y, float x)
|
||||
{
|
||||
float result = atan2f(y, x);
|
||||
|
||||
if (!_isnanf(result))
|
||||
{
|
||||
Fail("atan2f(%g, %g) returned %10.9g when it should have returned %10.9g",
|
||||
y, x, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_atan2f_test1_paltest_atan2f_test1, "c_runtime/atan2f/test1/paltest_atan2f_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* y x expected variance */
|
||||
{ 0, PAL_POSINF, 0, PAL_EPSILON },
|
||||
{ 0, 0, 0, PAL_EPSILON },
|
||||
{ 0.312961796f, 0.949765715f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi
|
||||
{ 0.420770483f, 0.907167129f, 0.434294482f, PAL_EPSILON }, // expected: logf10f(e)
|
||||
{ 0.594480769f, 0.804109828f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi
|
||||
{ 0.638961276f, 0.769238901f, 0.693147181f, PAL_EPSILON }, // expected: ln(2)
|
||||
{ 0.649636939f, 0.760244597f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2)
|
||||
{ 0.707106781f, 0.707106781f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4, value: 1 / sqrtf(2)
|
||||
{ 1, 1, 0.785398163f, PAL_EPSILON }, // expected: pi / 4
|
||||
{ PAL_POSINF, PAL_POSINF, 0.785398163f, PAL_EPSILON }, // expected: pi / 4
|
||||
{ 0.841470985f, 0.540302306f, 1, PAL_EPSILON * 10 },
|
||||
{ 0.903719457f, 0.428125148f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi)
|
||||
{ 0.987765946f, 0.155943695f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2)
|
||||
{ 0.991806244f, 0.127751218f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e)
|
||||
{ 1, 0, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2
|
||||
{ PAL_POSINF, 0, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2
|
||||
{ PAL_POSINF, 1, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2
|
||||
{ 0.743980337f, -0.668201510f, 2.30258509f, PAL_EPSILON * 10 }, // expected: ln(10)
|
||||
{ 0.410781291f, -0.911733915f, 2.71828183f, PAL_EPSILON * 10 }, // expected: e
|
||||
{ 0, -1, 3.14159265f, PAL_EPSILON * 10 }, // expected: pi
|
||||
{ 1, PAL_POSINF, 0, PAL_EPSILON },
|
||||
};
|
||||
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
const float pi = 3.14159265f;
|
||||
|
||||
atan2f_test1_validate( tests[i].y, tests[i].x, tests[i].expected, tests[i].variance);
|
||||
atan2f_test1_validate(-tests[i].y, tests[i].x, -tests[i].expected, tests[i].variance);
|
||||
atan2f_test1_validate( tests[i].y, -tests[i].x, pi - tests[i].expected, tests[i].variance);
|
||||
atan2f_test1_validate(-tests[i].y, -tests[i].x, tests[i].expected - pi, tests[i].variance);
|
||||
}
|
||||
|
||||
atan2f_test1_validate_isnan(PAL_NEGINF, PAL_NAN);
|
||||
atan2f_test1_validate_isnan(PAL_NAN, PAL_NEGINF);
|
||||
atan2f_test1_validate_isnan(PAL_NAN, PAL_POSINF);
|
||||
atan2f_test1_validate_isnan(PAL_POSINF, PAL_NAN);
|
||||
|
||||
atan2f_test1_validate_isnan(PAL_NAN, -1);
|
||||
atan2f_test1_validate_isnan(PAL_NAN, -0.0f);
|
||||
atan2f_test1_validate_isnan(PAL_NAN, 0);
|
||||
atan2f_test1_validate_isnan(PAL_NAN, 1);
|
||||
|
||||
atan2f_test1_validate_isnan(-1, PAL_NAN);
|
||||
atan2f_test1_validate_isnan(-0.0f, PAL_NAN);
|
||||
atan2f_test1_validate_isnan( 0, PAL_NAN);
|
||||
atan2f_test1_validate_isnan( 1, PAL_NAN);
|
||||
|
||||
atan2f_test1_validate_isnan(PAL_NAN, PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,126 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that atanf return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrtf(-1.0f)
|
||||
#define PAL_POSINF -logf(0.0f)
|
||||
#define PAL_NEGINF logf(0.0f)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float value; /* value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* atanf_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl atanf_test1_validate(float value, float expected, float variance)
|
||||
{
|
||||
float result = atanf(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("atanf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* atanf_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl atanf_test1_validate_isnan(float value)
|
||||
{
|
||||
float result = atanf(value);
|
||||
|
||||
if (!_isnanf(result))
|
||||
{
|
||||
Fail("atanf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_atanf_test1_paltest_atanf_test1, "c_runtime/atanf/test1/paltest_atanf_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, 0, PAL_EPSILON },
|
||||
{ 0.329514733f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi
|
||||
{ 0.450549534f, 0.423310825f, PAL_EPSILON }, // expected: pi - e
|
||||
{ 0.463829067f, 0.434294482f, PAL_EPSILON }, // expected: logf10f(e)
|
||||
{ 0.739302950f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi
|
||||
{ 0.830640878f, 0.693147181f, PAL_EPSILON }, // expected: ln(2)
|
||||
{ 0.854510432f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2)
|
||||
{ 1, 0.785398163f, PAL_EPSILON }, // expected: pi / 4
|
||||
{ 1.11340715f, 0.839007561f, PAL_EPSILON }, // expected: pi - ln(10)
|
||||
{ 1.55740772f, 1, PAL_EPSILON * 10 },
|
||||
{ 2.11087684f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi)
|
||||
{ 6.33411917f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2)
|
||||
{ 7.76357567f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e)
|
||||
{ PAL_POSINF, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
atanf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
atanf_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
atanf_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that atanh return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double value; /* value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* atanh_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl atanh_test1_validate(double value, double expected, double variance)
|
||||
{
|
||||
double result = atanh(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("atanh(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* atanh_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl atanh_test1_validate_isnan(double value)
|
||||
{
|
||||
double result = atanh(value);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("atanh(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_atanh_test1_paltest_atanh_test1, "c_runtime/atanh/test1/paltest_atanh_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, 0, PAL_EPSILON },
|
||||
{ 0.30797791269089433, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi
|
||||
{ 0.40890401183401433, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e)
|
||||
{ 0.56259360033158334, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi
|
||||
{ 0.6, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2)
|
||||
{ 0.60885936501391381, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2)
|
||||
{ 0.65579420263267244, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4
|
||||
{ 0.76159415595576489, 1, PAL_EPSILON * 10 },
|
||||
{ 0.81046380599898809, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi)
|
||||
{ 0.88838556158566054, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2)
|
||||
{ 0.89423894585503855, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e)
|
||||
{ 0.91715233566727435, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2
|
||||
{ 0.98019801980198020, 2.3025850929940457, PAL_EPSILON * 10 }, // expected: ln(10)
|
||||
{ 0.99132891580059984, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e
|
||||
{ 0.99627207622074994, 3.1415926535897932, PAL_EPSILON * 10 }, // expected: pi
|
||||
{ 1, PAL_POSINF, PAL_EPSILON * 10 }
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
atanh_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
atanh_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
atanh_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,128 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that atanhf return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrtf(-1.0f)
|
||||
#define PAL_POSINF -logf(0.0f)
|
||||
#define PAL_NEGINF logf(0.0f)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float value; /* value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* atanhf_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl atanhf_test1_validate(float value, float expected, float variance)
|
||||
{
|
||||
float result = atanhf(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("atanhf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* atanhf_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl atanhf_test1_validate_isnan(float value)
|
||||
{
|
||||
float result = atanhf(value);
|
||||
|
||||
if (!_isnanf(result))
|
||||
{
|
||||
Fail("atanhf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_atanhf_test1_paltest_atanhf_test1, "c_runtime/atanhf/test1/paltest_atanhf_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, 0, PAL_EPSILON },
|
||||
{ 0.307977913f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi
|
||||
{ 0.408904012f, 0.434294482f, PAL_EPSILON }, // expected: log10f(e)
|
||||
{ 0.562593600f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi
|
||||
{ 0.6f, 0.693147181f, PAL_EPSILON }, // expected: ln(2)
|
||||
{ 0.608859365f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2)
|
||||
{ 0.655794203f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4
|
||||
{ 0.761594156f, 1, PAL_EPSILON * 10 },
|
||||
{ 0.810463806f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi)
|
||||
{ 0.888385562f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2)
|
||||
{ 0.894238946f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e)
|
||||
{ 0.917152336f, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2
|
||||
{ 0.980198020f, 2.30258509f, PAL_EPSILON * 10 }, // expected: ln(10)
|
||||
{ 0.991328916f, 2.71828183f, PAL_EPSILON * 10 }, // expected: e
|
||||
{ 0.996272076f, 3.14159265f, PAL_EPSILON * 10 }, // expected: pi
|
||||
{ 1, PAL_POSINF, PAL_EPSILON * 10 }
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
atanhf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
atanhf_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
atanhf_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,122 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=====================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Call the cbrt function on a positive value, a positive value
|
||||
** with a decimal and on the maximum possible double value.
|
||||
**
|
||||
**
|
||||
**===================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double value; /* value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* cbrt_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl cbrt_test1_validate(double value, double expected, double variance)
|
||||
{
|
||||
double result = cbrt(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("cbrt(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* cbrt_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl cbrt_test1_validate_isnan(double value)
|
||||
{
|
||||
double result = cbrt(value);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("cbrt(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
PALTEST(c_runtime_cbrt_test1_paltest_cbrt_test1, "c_runtime/cbrt/test1/paltest_cbrt_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0.31830988618379067, 0.68278406325529568, PAL_EPSILON }, // value: 1 / pi
|
||||
{ 0.43429448190325183, 0.75728863133090766, PAL_EPSILON }, // value: log10(e)
|
||||
{ 0.63661977236758134, 0.86025401382809963, PAL_EPSILON }, // value: 2 / pi
|
||||
{ 0.69314718055994531, 0.88499704450051772, PAL_EPSILON }, // value: ln(2)
|
||||
{ 0.70710678118654752, 0.89089871814033930, PAL_EPSILON }, // value: 1 / sqrt(2)
|
||||
{ 0.78539816339744831, 0.92263507432201421, PAL_EPSILON }, // value: pi / 4
|
||||
{ 1, 1, PAL_EPSILON * 10 },
|
||||
{ 1.1283791670955126, 1.0410821966965807, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi)
|
||||
{ 1.4142135623730950, 1.1224620483093730, PAL_EPSILON * 10 }, // value: sqrt(2)
|
||||
{ 1.4426950408889634, 1.1299472763373901, PAL_EPSILON * 10 }, // value: log2(e)
|
||||
{ 1.5707963267948966, 1.1624473515096265, PAL_EPSILON * 10 }, // value: pi / 2
|
||||
{ 2.3025850929940457, 1.3205004784536852, PAL_EPSILON * 10 }, // value: ln(10)
|
||||
{ 2.7182818284590452, 1.3956124250860895, PAL_EPSILON * 10 }, // value: e
|
||||
{ 3.1415926535897932, 1.4645918875615233, PAL_EPSILON * 10 }, // value: pi
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
cbrt_test1_validate(-0.0, -0.0, PAL_EPSILON);
|
||||
cbrt_test1_validate( 0.0, 0.0, PAL_EPSILON);
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
cbrt_test1_validate(tests[i].value, tests[i].expected, tests[i].variance);
|
||||
cbrt_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
cbrt_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,121 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=====================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Call the cbrtf function on a positive value, a positive value
|
||||
** with a decimal and on the maximum possible float value.
|
||||
**
|
||||
**
|
||||
**===================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrtf(-1.0f)
|
||||
#define PAL_POSINF -logf(0.0f)
|
||||
#define PAL_NEGINF logf(0.0f)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float value; /* value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* cbrtf_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl cbrtf_test1_validate(float value, float expected, float variance)
|
||||
{
|
||||
float result = cbrtf(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("cbrtf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* cbrtf_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl cbrtf_test1_validate_isnan(float value)
|
||||
{
|
||||
float result = cbrtf(value);
|
||||
|
||||
if (!_isnanf(result))
|
||||
{
|
||||
Fail("cbrtf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
PALTEST(c_runtime_cbrtf_test1_paltest_cbrtf_test1, "c_runtime/cbrtf/test1/paltest_cbrtf_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0.318309886f, 0.682784063f, PAL_EPSILON }, // value: 1 / pi
|
||||
{ 0.434294482f, 0.757288631f, PAL_EPSILON }, // value: log10f(e)
|
||||
{ 0.636619772f, 0.860254014f, PAL_EPSILON }, // value: 2 / pi
|
||||
{ 0.693147181f, 0.884997045f, PAL_EPSILON }, // value: ln(2)
|
||||
{ 0.707106781f, 0.890898718f, PAL_EPSILON }, // value: 1 / sqrtf(2)
|
||||
{ 0.785398163f, 0.922635074f, PAL_EPSILON }, // value: pi / 4
|
||||
{ 1, 1, PAL_EPSILON * 10 },
|
||||
{ 1.12837917f, 1.04108220f, PAL_EPSILON * 10 }, // value: 2 / sqrtf(pi)
|
||||
{ 1.41421356f, 1.12246205f, PAL_EPSILON * 10 }, // value: sqrtf(2)
|
||||
{ 1.44269504f, 1.12994728f, PAL_EPSILON * 10 }, // value: logf2(e)
|
||||
{ 1.57079633f, 1.16244735f, PAL_EPSILON * 10 }, // value: pi / 2
|
||||
{ 2.30258509f, 1.32050048f, PAL_EPSILON * 10 }, // value: ln(10)
|
||||
{ 2.71828183f, 1.39561243f, PAL_EPSILON * 10 }, // value: e
|
||||
{ 3.14159265f, 1.46459189f, PAL_EPSILON * 10 }, // value: pi
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
cbrtf_test1_validate(-0.0f, -0.0f, PAL_EPSILON);
|
||||
cbrtf_test1_validate( 0.0f, 0.0f, PAL_EPSILON);
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
cbrtf_test1_validate(tests[i].value, tests[i].expected, tests[i].variance);
|
||||
cbrtf_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
cbrtf_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,131 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Tests ceil with simple positive and negative values. Also tests
|
||||
** extreme cases like extremely small values and positive and
|
||||
** negative infinity. Makes sure that calling ceil on NaN returns
|
||||
** NaN
|
||||
**
|
||||
**==========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double value; /* value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* ceil_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl ceil_test1_validate(double value, double expected, double variance)
|
||||
{
|
||||
double result = ceil(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("ceil(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ceil_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl ceil_test1_validate_isnan(double value)
|
||||
{
|
||||
double result = ceil(value);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("ceil(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_ceil_test1_paltest_ceil_test1, "c_runtime/ceil/test1/paltest_ceil_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0.31830988618379067, 1, PAL_EPSILON * 10 }, // value: 1 / pi
|
||||
{ 0.43429448190325183, 1, PAL_EPSILON * 10 }, // value: log10(e)
|
||||
{ 0.63661977236758134, 1, PAL_EPSILON * 10 }, // value: 2 / pi
|
||||
{ 0.69314718055994531, 1, PAL_EPSILON * 10 }, // value: ln(2)
|
||||
{ 0.70710678118654752, 1, PAL_EPSILON * 10 }, // value: 1 / sqrt(2)
|
||||
{ 0.78539816339744831, 1, PAL_EPSILON * 10 }, // value: pi / 4
|
||||
{ 1.1283791670955126, 2, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi)
|
||||
{ 1.4142135623730950, 2, PAL_EPSILON * 10 }, // value: sqrt(2)
|
||||
{ 1.4426950408889634, 2, PAL_EPSILON * 10 }, // value: log2(e)
|
||||
{ 1.5707963267948966, 2, PAL_EPSILON * 10 }, // value: pi / 2
|
||||
{ 2.3025850929940457, 3, PAL_EPSILON * 10 }, // value: ln(10)
|
||||
{ 2.7182818284590452, 3, PAL_EPSILON * 10 }, // value: e
|
||||
{ 3.1415926535897932, 4, PAL_EPSILON * 10 }, // value: pi
|
||||
{ PAL_POSINF, PAL_POSINF, 0 }
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
ceil_test1_validate( 0, 0, PAL_EPSILON);
|
||||
ceil_test1_validate(-0.0, 0, PAL_EPSILON);
|
||||
|
||||
ceil_test1_validate( 1, 1, PAL_EPSILON * 10);
|
||||
ceil_test1_validate(-1.0, -1, PAL_EPSILON * 10);
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
ceil_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
ceil_test1_validate(-tests[i].value, 1 - tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
ceil_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,130 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Tests ceilf with simple positive and negative values. Also tests
|
||||
** extreme cases like extremely small values and positive and
|
||||
** negative infinity. Makes sure that calling ceilf on NaN returns
|
||||
** NaN
|
||||
**
|
||||
**==========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrtf(-1.0f)
|
||||
#define PAL_POSINF -logf(0.0f)
|
||||
#define PAL_NEGINF logf(0.0f)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float value; /* value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* ceilf_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl ceilf_test1_validate(float value, float expected, float variance)
|
||||
{
|
||||
float result = ceilf(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("ceilf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ceilf_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl ceilf_test1_validate_isnan(float value)
|
||||
{
|
||||
float result = ceilf(value);
|
||||
|
||||
if (!_isnanf(result))
|
||||
{
|
||||
Fail("ceilf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_ceilf_test1_paltest_ceilf_test1, "c_runtime/ceilf/test1/paltest_ceilf_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0.318309886f, 1, PAL_EPSILON * 10 }, // value: 1 / pi
|
||||
{ 0.434294482f, 1, PAL_EPSILON * 10 }, // value: log10f(e)
|
||||
{ 0.636619772f, 1, PAL_EPSILON * 10 }, // value: 2 / pi
|
||||
{ 0.693147181f, 1, PAL_EPSILON * 10 }, // value: ln(2)
|
||||
{ 0.707106781f, 1, PAL_EPSILON * 10 }, // value: 1 / sqrtf(2)
|
||||
{ 0.785398163f, 1, PAL_EPSILON * 10 }, // value: pi / 4
|
||||
{ 1.12837917f, 2, PAL_EPSILON * 10 }, // value: 2 / sqrtf(pi)
|
||||
{ 1.41421356f, 2, PAL_EPSILON * 10 }, // value: sqrtf(2)
|
||||
{ 1.44269504f, 2, PAL_EPSILON * 10 }, // value: logf2(e)
|
||||
{ 1.57079633f, 2, PAL_EPSILON * 10 }, // value: pi / 2
|
||||
{ 2.30258509f, 3, PAL_EPSILON * 10 }, // value: ln(10)
|
||||
{ 2.71828183f, 3, PAL_EPSILON * 10 }, // value: e
|
||||
{ 3.14159265f, 4, PAL_EPSILON * 10 }, // value: pi
|
||||
{ PAL_POSINF, PAL_POSINF, 0 }
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
ceilf_test1_validate( 0, 0, PAL_EPSILON);
|
||||
ceilf_test1_validate(-0.0f, 0, PAL_EPSILON);
|
||||
|
||||
ceilf_test1_validate( 1, 1, PAL_EPSILON * 10);
|
||||
ceilf_test1_validate(-1.0f, -1, PAL_EPSILON * 10);
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
ceilf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
ceilf_test1_validate(-tests[i].value, 1 - tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
ceilf_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,130 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that cos return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double value; /* value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* cos_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl cos_test1_validate(double value, double expected, double variance)
|
||||
{
|
||||
double result = cos(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("cos(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* cos_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl cos_test1_validate_isnan(double value)
|
||||
{
|
||||
double result = cos(value);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("cos(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_cos_test1_paltest_cos_test1, "c_runtime/cos/test1/paltest_cos_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, 1, PAL_EPSILON * 10 },
|
||||
{ 0.31830988618379067, 0.94976571538163866, PAL_EPSILON }, // value: 1 / pi
|
||||
{ 0.43429448190325183, 0.90716712923909839, PAL_EPSILON }, // value: log10(e)
|
||||
{ 0.63661977236758134, 0.80410982822879171, PAL_EPSILON }, // value: 2 / pi
|
||||
{ 0.69314718055994531, 0.76923890136397213, PAL_EPSILON }, // value: ln(2)
|
||||
{ 0.70710678118654752, 0.76024459707563015, PAL_EPSILON }, // value: 1 / sqrt(2)
|
||||
{ 0.78539816339744831, 0.70710678118654752, PAL_EPSILON }, // value: pi / 4, expected: 1 / sqrt(2)
|
||||
{ 1, 0.54030230586813972, PAL_EPSILON },
|
||||
{ 1.1283791670955126, 0.42812514788535792, PAL_EPSILON }, // value: 2 / sqrt(pi)
|
||||
{ 1.4142135623730950, 0.15594369476537447, PAL_EPSILON }, // value: sqrt(2)
|
||||
{ 1.4426950408889634, 0.12775121753523991, PAL_EPSILON }, // value: log2(e)
|
||||
{ 1.5707963267948966, 0, PAL_EPSILON }, // value: pi / 2
|
||||
{ 2.3025850929940457, -0.66820151019031295, PAL_EPSILON }, // value: ln(10)
|
||||
{ 2.7182818284590452, -0.91173391478696510, PAL_EPSILON }, // value: e
|
||||
{ 3.1415926535897932, -1, PAL_EPSILON * 10 }, // value: pi
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
cos_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
cos_test1_validate(-tests[i].value, tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
cos_test1_validate_isnan(PAL_NEGINF);
|
||||
cos_test1_validate_isnan(PAL_NAN);
|
||||
cos_test1_validate_isnan(PAL_POSINF);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that cosf return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrtf(-1.0f)
|
||||
#define PAL_POSINF -logf(0.0f)
|
||||
#define PAL_NEGINF logf(0.0f)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float value; /* value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* cosf_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl cosf_test1_validate(float value, float expected, float variance)
|
||||
{
|
||||
float result = cosf(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("cosf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* cosf_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl cosf_test1_validate_isnan(float value)
|
||||
{
|
||||
float result = cosf(value);
|
||||
|
||||
if (!_isnanf(result))
|
||||
{
|
||||
Fail("cosf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_cosf_test1_paltest_cosf_test1, "c_runtime/cosf/test1/paltest_cosf_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, 1, PAL_EPSILON * 10 },
|
||||
{ 0.318309886f, 0.949765715f, PAL_EPSILON }, // value: 1 / pi
|
||||
{ 0.434294482f, 0.907167129f, PAL_EPSILON }, // value: log10f(e)
|
||||
{ 0.636619772f, 0.804109828f, PAL_EPSILON }, // value: 2 / pi
|
||||
{ 0.693147181f, 0.769238901f, PAL_EPSILON }, // value: ln(2)
|
||||
{ 0.707106781f, 0.760244597f, PAL_EPSILON }, // value: 1 / sqrtf(2)
|
||||
{ 0.785398163f, 0.707106781f, PAL_EPSILON }, // value: pi / 4, expected: 1 / sqrtf(2)
|
||||
{ 1, 0.540302306f, PAL_EPSILON },
|
||||
{ 1.12837917f, 0.428125148f, PAL_EPSILON }, // value: 2 / sqrtf(pi)
|
||||
{ 1.41421356f, 0.155943695f, PAL_EPSILON }, // value: sqrtf(2)
|
||||
{ 1.44269504f, 0.127751218f, PAL_EPSILON }, // value: logf2(e)
|
||||
{ 1.57079633f, 0, PAL_EPSILON }, // value: pi / 2
|
||||
{ 2.30258509f, -0.668201510f, PAL_EPSILON }, // value: ln(10)
|
||||
{ 2.71828183f, -0.911733918f, PAL_EPSILON }, // value: e
|
||||
{ 3.14159265f, -1, PAL_EPSILON * 10 }, // value: pi
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
cosf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
cosf_test1_validate(-tests[i].value, tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
cosf_test1_validate_isnan(PAL_NEGINF);
|
||||
cosf_test1_validate_isnan(PAL_NAN);
|
||||
cosf_test1_validate_isnan(PAL_POSINF);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that cosh return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double value; /* value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* cosh_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl cosh_test1_validate(double value, double expected, double variance)
|
||||
{
|
||||
double result = cosh(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("cosh(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* cosh_test1_validate
|
||||
*
|
||||
* test validation function for values returning PAL_NAN
|
||||
*/
|
||||
void __cdecl cosh_test1_validate_isnan(double value)
|
||||
{
|
||||
double result = cosh(value);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("cosh(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_cosh_test1_paltest_cosh_test1, "c_runtime/cosh/test1/paltest_cosh_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, 1, PAL_EPSILON * 10 },
|
||||
{ 0.31830988618379067, 1.0510897883672876, PAL_EPSILON * 10 }, // value: 1 / pi
|
||||
{ 0.43429448190325183, 1.0957974645564909, PAL_EPSILON * 10 }, // value: log10(e)
|
||||
{ 0.63661977236758134, 1.2095794864199787, PAL_EPSILON * 10 }, // value: 2 / pi
|
||||
{ 0.69314718055994531, 1.25, PAL_EPSILON * 10 }, // value: ln(2)
|
||||
{ 0.70710678118654752, 1.2605918365213561, PAL_EPSILON * 10 }, // value: 1 / sqrt(2)
|
||||
{ 0.78539816339744831, 1.3246090892520058, PAL_EPSILON * 10 }, // value: pi / 4
|
||||
{ 1, 1.5430806348152438, PAL_EPSILON * 10 },
|
||||
{ 1.1283791670955126, 1.7071001431069344, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi)
|
||||
{ 1.4142135623730950, 2.1781835566085709, PAL_EPSILON * 10 }, // value: sqrt(2)
|
||||
{ 1.4426950408889634, 2.2341880974508023, PAL_EPSILON * 10 }, // value: log2(e)
|
||||
{ 1.5707963267948966, 2.5091784786580568, PAL_EPSILON * 10 }, // value: pi / 2
|
||||
{ 2.3025850929940457, 5.05, PAL_EPSILON * 10 }, // value: ln(10)
|
||||
{ 2.7182818284590452, 7.6101251386622884, PAL_EPSILON * 10 }, // value: e
|
||||
{ 3.1415926535897932, 11.591953275521521, PAL_EPSILON * 100 }, // value: pi
|
||||
{ PAL_POSINF, PAL_POSINF, 0 },
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
cosh_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
cosh_test1_validate(-tests[i].value, tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
cosh_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,128 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that coshf return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrtf(-1.0f)
|
||||
#define PAL_POSINF -logf(0.0f)
|
||||
#define PAL_NEGINF logf(0.0f)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float value; /* value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* coshf_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl coshf_test1_validate(float value, float expected, float variance)
|
||||
{
|
||||
float result = coshf(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("coshf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* coshf_test1_validate
|
||||
*
|
||||
* test validation function for values returning PAL_NAN
|
||||
*/
|
||||
void __cdecl coshf_test1_validate_isnan(float value)
|
||||
{
|
||||
float result = coshf(value);
|
||||
|
||||
if (!_isnanf(result))
|
||||
{
|
||||
Fail("coshf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_coshf_test1_paltest_coshf_test1, "c_runtime/coshf/test1/paltest_coshf_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, 1, PAL_EPSILON * 10 },
|
||||
{ 0.318309886f, 1.05108979f, PAL_EPSILON * 10 }, // value: 1 / pi
|
||||
{ 0.434294482f, 1.09579746f, PAL_EPSILON * 10 }, // value: log10f(e)
|
||||
{ 0.636619772f, 1.20957949f, PAL_EPSILON * 10 }, // value: 2 / pi
|
||||
{ 0.693147181f, 1.25f, PAL_EPSILON * 10 }, // value: ln(2)
|
||||
{ 0.707106781f, 1.26059184f, PAL_EPSILON * 10 }, // value: 1 / sqrtf(2)
|
||||
{ 0.785398163f, 1.32460909f, PAL_EPSILON * 10 }, // value: pi / 4
|
||||
{ 1, 1.54308063f, PAL_EPSILON * 10 },
|
||||
{ 1.12837917f, 1.70710014f, PAL_EPSILON * 10 }, // value: 2 / sqrtf(pi)
|
||||
{ 1.41421356f, 2.17818356f, PAL_EPSILON * 10 }, // value: sqrtf(2)
|
||||
{ 1.44269504f, 2.23418810f, PAL_EPSILON * 10 }, // value: logf2(e)
|
||||
{ 1.57079633f, 2.50917848f, PAL_EPSILON * 10 }, // value: pi / 2
|
||||
{ 2.30258509f, 5.05f, PAL_EPSILON * 10 }, // value: ln(10)
|
||||
{ 2.71828183f, 7.61012514f, PAL_EPSILON * 10 }, // value: e
|
||||
{ 3.14159265f, 11.5919533f, PAL_EPSILON * 100 }, // value: pi
|
||||
{ PAL_POSINF, PAL_POSINF, 0 },
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
coshf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
coshf_test1_validate(-tests[i].value, tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
coshf_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,137 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=====================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Tests exp with a normal set of values.
|
||||
**
|
||||
**===================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double value; /* value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* exp_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl exp_test1_validate(double value, double expected, double variance)
|
||||
{
|
||||
double result = exp(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("exp(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* exp_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl exp_test1_validate_isnan(double value)
|
||||
{
|
||||
double result = exp(value);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("exp(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_exp_test1_paltest_exp_test1, "c_runtime/exp/test1/paltest_exp_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ PAL_NEGINF, 0, PAL_EPSILON },
|
||||
{ -3.1415926535897932, 0.043213918263772250, PAL_EPSILON / 10 }, // value: -(pi)
|
||||
{ -2.7182818284590452, 0.065988035845312537, PAL_EPSILON / 10 }, // value: -(e)
|
||||
{ -2.3025850929940457, 0.1, PAL_EPSILON }, // value: -(ln(10))
|
||||
{ -1.5707963267948966, 0.20787957635076191, PAL_EPSILON }, // value: -(pi / 2)
|
||||
{ -1.4426950408889634, 0.23629008834452270, PAL_EPSILON }, // value: -(log2(e))
|
||||
{ -1.4142135623730950, 0.24311673443421421, PAL_EPSILON }, // value: -(sqrt(2))
|
||||
{ -1.1283791670955126, 0.32355726390307110, PAL_EPSILON }, // value: -(2 / sqrt(pi))
|
||||
{ -1, 0.36787944117144232, PAL_EPSILON }, // value: -(1)
|
||||
{ -0.78539816339744831, 0.45593812776599624, PAL_EPSILON }, // value: -(pi / 4)
|
||||
{ -0.70710678118654752, 0.49306869139523979, PAL_EPSILON }, // value: -(1 / sqrt(2))
|
||||
{ -0.69314718055994531, 0.5, PAL_EPSILON }, // value: -(ln(2))
|
||||
{ -0.63661977236758134, 0.52907780826773535, PAL_EPSILON }, // value: -(2 / pi)
|
||||
{ -0.43429448190325183, 0.64772148514180065, PAL_EPSILON }, // value: -(log10(e))
|
||||
{ -0.31830988618379067, 0.72737734929521647, PAL_EPSILON }, // value: -(1 / pi)
|
||||
{ 0, 1, PAL_EPSILON * 10 },
|
||||
{ 0.31830988618379067, 1.3748022274393586, PAL_EPSILON * 10 }, // value: 1 / pi
|
||||
{ 0.43429448190325183, 1.5438734439711811, PAL_EPSILON * 10 }, // value: log10(e)
|
||||
{ 0.63661977236758134, 1.8900811645722220, PAL_EPSILON * 10 }, // value: 2 / pi
|
||||
{ 0.69314718055994531, 2, PAL_EPSILON * 10 }, // value: ln(2)
|
||||
{ 0.70710678118654752, 2.0281149816474725, PAL_EPSILON * 10 }, // value: 1 / sqrt(2)
|
||||
{ 0.78539816339744831, 2.1932800507380155, PAL_EPSILON * 10 }, // value: pi / 4
|
||||
{ 1, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e
|
||||
{ 1.1283791670955126, 3.0906430223107976, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi)
|
||||
{ 1.4142135623730950, 4.1132503787829275, PAL_EPSILON * 10 }, // value: sqrt(2)
|
||||
{ 1.4426950408889634, 4.2320861065570819, PAL_EPSILON * 10 }, // value: log2(e)
|
||||
{ 1.5707963267948966, 4.8104773809653517, PAL_EPSILON * 10 }, // value: pi / 2
|
||||
{ 2.3025850929940457, 10, PAL_EPSILON * 100 }, // value: ln(10)
|
||||
{ 2.7182818284590452, 15.154262241479264, PAL_EPSILON * 100 }, // value: e
|
||||
{ 3.1415926535897932, 23.140692632779269, PAL_EPSILON * 100 }, // value: pi
|
||||
{ PAL_POSINF, PAL_POSINF, 0 },
|
||||
};
|
||||
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
exp_test1_validate(tests[i].value, tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
exp_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,136 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=====================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Tests expf with a normal set of values.
|
||||
**
|
||||
**===================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrtf(-1.0f)
|
||||
#define PAL_POSINF -logf(0.0f)
|
||||
#define PAL_NEGINF logf(0.0f)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float value; /* value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* expf_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl expf_test1_validate(float value, float expected, float variance)
|
||||
{
|
||||
float result = expf(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("expf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* expf_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl expf_test1_validate_isnan(float value)
|
||||
{
|
||||
float result = expf(value);
|
||||
|
||||
if (!_isnanf(result))
|
||||
{
|
||||
Fail("expf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_expf_test1_paltest_expf_test1, "c_runtime/expf/test1/paltest_expf_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ PAL_NEGINF, 0, PAL_EPSILON },
|
||||
{ -3.14159265f, 0.0432139183f, PAL_EPSILON / 10 }, // value: -(pi)
|
||||
{ -2.71828183f, 0.0659880358f, PAL_EPSILON / 10 }, // value: -(e)
|
||||
{ -2.30258509f, 0.1f, PAL_EPSILON }, // value: -(ln(10))
|
||||
{ -1.57079633f, 0.207879576f, PAL_EPSILON }, // value: -(pi / 2)
|
||||
{ -1.44269504f, 0.236290088f, PAL_EPSILON }, // value: -(logf2(e))
|
||||
{ -1.41421356f, 0.243116734f, PAL_EPSILON }, // value: -(sqrtf(2))
|
||||
{ -1.12837917f, 0.323557264f, PAL_EPSILON }, // value: -(2 / sqrtf(pi))
|
||||
{ -1, 0.367879441f, PAL_EPSILON }, // value: -(1)
|
||||
{ -0.785398163f, 0.455938128f, PAL_EPSILON }, // value: -(pi / 4)
|
||||
{ -0.707106781f, 0.493068691f, PAL_EPSILON }, // value: -(1 / sqrtf(2))
|
||||
{ -0.693147181f, 0.5f, PAL_EPSILON }, // value: -(ln(2))
|
||||
{ -0.636619772f, 0.529077808f, PAL_EPSILON }, // value: -(2 / pi)
|
||||
{ -0.434294482f, 0.647721485f, PAL_EPSILON }, // value: -(log10f(e))
|
||||
{ -0.318309886f, 0.727377349f, PAL_EPSILON }, // value: -(1 / pi)
|
||||
{ 0, 1, PAL_EPSILON * 10 },
|
||||
{ 0.318309886f, 1.37480223f, PAL_EPSILON * 10 }, // value: 1 / pi
|
||||
{ 0.434294482f, 1.54387344f, PAL_EPSILON * 10 }, // value: log10f(e)
|
||||
{ 0.636619772f, 1.89008116f, PAL_EPSILON * 10 }, // value: 2 / pi
|
||||
{ 0.693147181f, 2, PAL_EPSILON * 10 }, // value: ln(2)
|
||||
{ 0.707106781f, 2.02811498f, PAL_EPSILON * 10 }, // value: 1 / sqrtf(2)
|
||||
{ 0.785398163f, 2.19328005f, PAL_EPSILON * 10 }, // value: pi / 4
|
||||
{ 1, 2.71828183f, PAL_EPSILON * 10 }, // expected: e
|
||||
{ 1.12837917f, 3.09064302f, PAL_EPSILON * 10 }, // value: 2 / sqrtf(pi)
|
||||
{ 1.41421356f, 4.11325038f, PAL_EPSILON * 10 }, // value: sqrtf(2)
|
||||
{ 1.44269504f, 4.23208611f, PAL_EPSILON * 10 }, // value: logf2(e)
|
||||
{ 1.57079633f, 4.81047738f, PAL_EPSILON * 10 }, // value: pi / 2
|
||||
{ 2.30258509f, 10, PAL_EPSILON * 100 }, // value: ln(10)
|
||||
{ 2.71828183f, 15.1542622f, PAL_EPSILON * 100 }, // value: e
|
||||
{ 3.14159265f, 23.1406926f, PAL_EPSILON * 100 }, // value: pi
|
||||
{ PAL_POSINF, PAL_POSINF, 0 },
|
||||
};
|
||||
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
expf_test1_validate(tests[i].value, tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
expf_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that fabs return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double value; /* value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* fabs_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl fabs_test1_validate(double value, double expected, double variance)
|
||||
{
|
||||
double result = fabs(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("fabs(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* fabs_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl fabs_test1_validate_isnan(double value)
|
||||
{
|
||||
double result = fabs(value);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("fabs(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_fabs_test1_paltest_fabs_test1, "c_runtime/fabs/test1/paltest_fabs_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ PAL_NEGINF, PAL_POSINF, 0 },
|
||||
{ -3.1415926535897932, 3.1415926535897932, PAL_EPSILON * 10 }, // value: -(pi) expected: pi
|
||||
{ -2.7182818284590452, 2.7182818284590452, PAL_EPSILON * 10 }, // value: -(e) expected: e
|
||||
{ -2.3025850929940457, 2.3025850929940457, PAL_EPSILON * 10 }, // value: -(ln(10)) expected: ln(10)
|
||||
{ -1.5707963267948966, 1.5707963267948966, PAL_EPSILON * 10 }, // value: -(pi / 2) expected: pi / 2
|
||||
{ -1.4426950408889634, 1.4426950408889634, PAL_EPSILON * 10 }, // value: -(log2(e)) expected: log2(e)
|
||||
{ -1.4142135623730950, 1.4142135623730950, PAL_EPSILON * 10 }, // value: -(sqrt(2)) expected: sqrt(2)
|
||||
{ -1.1283791670955126, 1.1283791670955126, PAL_EPSILON * 10 }, // value: -(2 / sqrt(pi)) expected: 2 / sqrt(pi)
|
||||
{ -1, 1, PAL_EPSILON * 10 },
|
||||
{ -0.78539816339744831, 0.78539816339744831, PAL_EPSILON }, // value: -(pi / 4) expected: pi / 4
|
||||
{ -0.70710678118654752, 0.70710678118654752, PAL_EPSILON }, // value: -(1 / sqrt(2)) expected: 1 / sqrt(2)
|
||||
{ -0.69314718055994531, 0.69314718055994531, PAL_EPSILON }, // value: -(ln(2)) expected: ln(2)
|
||||
{ -0.63661977236758134, 0.63661977236758134, PAL_EPSILON }, // value: -(2 / pi) expected: 2 / pi
|
||||
{ -0.43429448190325183, 0.43429448190325183, PAL_EPSILON }, // value: -(log10(e)) expected: log10(e)
|
||||
{ -0.31830988618379067, 0.31830988618379067, PAL_EPSILON }, // value: -(1 / pi) expected: 1 / pi
|
||||
{ -0.0, 0, PAL_EPSILON },
|
||||
};
|
||||
|
||||
|
||||
// PAL initialization
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
fabs_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
fabs_test1_validate(-tests[i].value, tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
fabs_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that fabsf return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float value; /* value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* fabsf_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl fabsf_test1_validate(float value, float expected, float variance)
|
||||
{
|
||||
float result = fabsf(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("fabsf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* fabsf_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl fabsf_test1_validate_isnan(float value)
|
||||
{
|
||||
float result = fabsf(value);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("fabsf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_fabsf_test1_paltest_fabsf_test1, "c_runtime/fabsf/test1/paltest_fabsf_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ PAL_NEGINF, PAL_POSINF, 0 },
|
||||
{ -3.14159265f, 3.14159265f, PAL_EPSILON * 10 }, // value: -(pi) expected: pi
|
||||
{ -2.71828183f, 2.71828183f, PAL_EPSILON * 10 }, // value: -(e) expected: e
|
||||
{ -2.30258509f, 2.30258509f, PAL_EPSILON * 10 }, // value: -(ln(10)) expected: ln(10)
|
||||
{ -1.57079633f, 1.57079633f, PAL_EPSILON * 10 }, // value: -(pi / 2) expected: pi / 2
|
||||
{ -1.44269504f, 1.44269504f, PAL_EPSILON * 10 }, // value: -(log2(e)) expected: log2(e)
|
||||
{ -1.41421356f, 1.41421356f, PAL_EPSILON * 10 }, // value: -(sqrt(2)) expected: sqrt(2)
|
||||
{ -1.12837917f, 1.12837917f, PAL_EPSILON * 10 }, // value: -(2 / sqrt(pi)) expected: 2 / sqrt(pi)
|
||||
{ -1, 1, PAL_EPSILON * 10 },
|
||||
{ -0.785398163f, 0.785398163f, PAL_EPSILON }, // value: -(pi / 4) expected: pi / 4
|
||||
{ -0.707106781f, 0.707106781f, PAL_EPSILON }, // value: -(1 / sqrt(2)) expected: 1 / sqrt(2)
|
||||
{ -0.693147181f, 0.693147181f, PAL_EPSILON }, // value: -(ln(2)) expected: ln(2)
|
||||
{ -0.636619772f, 0.636619772f, PAL_EPSILON }, // value: -(2 / pi) expected: 2 / pi
|
||||
{ -0.434294482f, 0.434294482f, PAL_EPSILON }, // value: -(log10(e)) expected: log10(e)
|
||||
{ -0.318309886f, 0.318309886f, PAL_EPSILON }, // value: -(1 / pi) expected: 1 / pi
|
||||
{ -0.0f, 0, PAL_EPSILON },
|
||||
};
|
||||
|
||||
|
||||
// PAL initialization
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
fabsf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
fabsf_test1_validate(-tests[i].value, tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
fabsf_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,131 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Tests floor with simple positive and negative values. Also tests
|
||||
** extreme cases like extremely small values and positive and
|
||||
** negative infinity. Makes sure that calling floor on NaN returns
|
||||
** NaN
|
||||
**
|
||||
**==========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double value; /* value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* floor_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl floor_test1_validate(double value, double expected, double variance)
|
||||
{
|
||||
double result = floor(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("floor(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* floor_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl floor_test1_validate_isnan(double value)
|
||||
{
|
||||
double result = floor(value);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("floor(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_floor_test1_paltest_floor_test1, "c_runtime/floor/test1/paltest_floor_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0.31830988618379067, 0, PAL_EPSILON }, // value: 1 / pi
|
||||
{ 0.43429448190325183, 0, PAL_EPSILON }, // value: log10(e)
|
||||
{ 0.63661977236758134, 0, PAL_EPSILON }, // value: 2 / pi
|
||||
{ 0.69314718055994531, 0, PAL_EPSILON }, // value: ln(2)
|
||||
{ 0.70710678118654752, 0, PAL_EPSILON }, // value: 1 / sqrt(2)
|
||||
{ 0.78539816339744831, 0, PAL_EPSILON }, // value: pi / 4
|
||||
{ 1.1283791670955126, 1, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi)
|
||||
{ 1.4142135623730950, 1, PAL_EPSILON * 10 }, // value: sqrt(2)
|
||||
{ 1.4426950408889634, 1, PAL_EPSILON * 10 }, // value: log2(e)
|
||||
{ 1.5707963267948966, 1, PAL_EPSILON * 10 }, // value: pi / 2
|
||||
{ 2.3025850929940457, 2, PAL_EPSILON * 10 }, // value: ln(10)
|
||||
{ 2.7182818284590452, 2, PAL_EPSILON * 10 }, // value: e
|
||||
{ 3.1415926535897932, 3, PAL_EPSILON * 10 }, // value: pi
|
||||
{ PAL_POSINF, PAL_POSINF, 0 }
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
floor_test1_validate( 0, 0, PAL_EPSILON);
|
||||
floor_test1_validate(-0.0, 0, PAL_EPSILON);
|
||||
|
||||
floor_test1_validate( 1, 1, PAL_EPSILON * 10);
|
||||
floor_test1_validate(-1.0, -1, PAL_EPSILON * 10);
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
floor_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
floor_test1_validate(-tests[i].value, -(tests[i].expected + 1), tests[i].variance);
|
||||
}
|
||||
|
||||
floor_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,130 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Tests floorf with simple positive and negative values. Also tests
|
||||
** extreme cases like extremely small values and positive and
|
||||
** negative infinity. Makes sure that calling floorf on NaN returns
|
||||
** NaN
|
||||
**
|
||||
**==========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrtf(-1.0f)
|
||||
#define PAL_POSINF -logf(0.0f)
|
||||
#define PAL_NEGINF logf(0.0f)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float value; /* value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* floorf_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl floorf_test1_validate(float value, float expected, float variance)
|
||||
{
|
||||
float result = floorf(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("floorf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* floorf_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl floorf_test1_validate_isnan(float value)
|
||||
{
|
||||
float result = floorf(value);
|
||||
|
||||
if (!_isnanf(result))
|
||||
{
|
||||
Fail("floorf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_floorf_test1_paltest_floorf_test1, "c_runtime/floorf/test1/paltest_floorf_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0.318309886f, 0, PAL_EPSILON }, // value: 1 / pi
|
||||
{ 0.434294482f, 0, PAL_EPSILON }, // value: log10f(e)
|
||||
{ 0.636619772f, 0, PAL_EPSILON }, // value: 2 / pi
|
||||
{ 0.693147181f, 0, PAL_EPSILON }, // value: ln(2)
|
||||
{ 0.707106781f, 0, PAL_EPSILON }, // value: 1 / sqrtf(2)
|
||||
{ 0.785398163f, 0, PAL_EPSILON }, // value: pi / 4
|
||||
{ 1.12837917f, 1, PAL_EPSILON * 10 }, // value: 2 / sqrtf(pi)
|
||||
{ 1.41421356f, 1, PAL_EPSILON * 10 }, // value: sqrtf(2)
|
||||
{ 1.44269504f, 1, PAL_EPSILON * 10 }, // value: logf2(e)
|
||||
{ 1.57079633f, 1, PAL_EPSILON * 10 }, // value: pi / 2
|
||||
{ 2.30258509f, 2, PAL_EPSILON * 10 }, // value: ln(10)
|
||||
{ 2.71828183f, 2, PAL_EPSILON * 10 }, // value: e
|
||||
{ 3.14159265f, 3, PAL_EPSILON * 10 }, // value: pi
|
||||
{ PAL_POSINF, PAL_POSINF, 0 }
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
floorf_test1_validate( 0, 0, PAL_EPSILON);
|
||||
floorf_test1_validate(-0.0f, 0, PAL_EPSILON);
|
||||
|
||||
floorf_test1_validate( 1, 1, PAL_EPSILON * 10);
|
||||
floorf_test1_validate(-1.0f, -1, PAL_EPSILON * 10);
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
floorf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
floorf_test1_validate(-tests[i].value, -(tests[i].expected + 1), tests[i].variance);
|
||||
}
|
||||
|
||||
floorf_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,145 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=====================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Tests that fma returns correct values for a subset of values.
|
||||
** Tests with positive and negative values of x, y, and z to ensure
|
||||
** fmaf is returning correct results.
|
||||
**
|
||||
**===================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double x; /* first component of the value to test the function with */
|
||||
double y; /* second component of the value to test the function with */
|
||||
double z; /* third component of the value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* fma_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl fma_test1_validate(double x, double y, double z, double expected, double variance)
|
||||
{
|
||||
double result = fma(x, y, z);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("fma(%g, %g, %g) returned %20.17g when it should have returned %20.17g",
|
||||
x, y, z, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* fma_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl fma_test1_validate_isnan(double x, double y, double z)
|
||||
{
|
||||
double result = fma(x, y, z);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("fma(%g, %g, %g) returned %20.17g when it should have returned %20.17g",
|
||||
x, y, z, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_fma_test1_paltest_fma_test1, "c_runtime/fma/test1/paltest_fma_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* x y z expected variance */
|
||||
{ PAL_NEGINF, PAL_NEGINF, PAL_NEGINF, PAL_NEGINF, 0 },
|
||||
{ -1e308, 2, 1e308, -1e308, 0 },
|
||||
{ 1e308, 2, -1e308, 1e308, 0 },
|
||||
{ PAL_POSINF, PAL_POSINF, PAL_POSINF, PAL_POSINF, 0 },
|
||||
};
|
||||
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
fma_test1_validate(tests[i].x, tests[i].y, tests[i].z, tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
// Returns NaN if x or y is infinite, the other is zero, and z is NaN
|
||||
fma_test1_validate_isnan(PAL_NEGINF, 0, PAL_NAN);
|
||||
fma_test1_validate_isnan(PAL_POSINF, 0, PAL_NAN);
|
||||
fma_test1_validate_isnan(0, PAL_NEGINF, PAL_NAN);
|
||||
fma_test1_validate_isnan(0, PAL_POSINF, PAL_NAN);
|
||||
|
||||
// Returns NaN if x or y is infinite, the other is zero, and z is not-NaN
|
||||
fma_test1_validate_isnan(PAL_POSINF, 0, PAL_NEGINF);
|
||||
fma_test1_validate_isnan(PAL_NEGINF, 0, PAL_NEGINF);
|
||||
fma_test1_validate_isnan(0, PAL_POSINF, PAL_NEGINF);
|
||||
fma_test1_validate_isnan(0, PAL_NEGINF, PAL_NEGINF);
|
||||
|
||||
fma_test1_validate_isnan(PAL_POSINF, 0, 0);
|
||||
fma_test1_validate_isnan(PAL_NEGINF, 0, 0);
|
||||
fma_test1_validate_isnan(0, PAL_POSINF, 0);
|
||||
fma_test1_validate_isnan(0, PAL_NEGINF, 0);
|
||||
|
||||
fma_test1_validate_isnan(PAL_POSINF, 0, PAL_POSINF);
|
||||
fma_test1_validate_isnan(PAL_NEGINF, 0, PAL_POSINF);
|
||||
fma_test1_validate_isnan(0, PAL_POSINF, PAL_POSINF);
|
||||
fma_test1_validate_isnan(0, PAL_NEGINF, PAL_POSINF);
|
||||
|
||||
// Returns NaN if (x * y) is infinite, and z is an infinite of the opposite sign
|
||||
fma_test1_validate_isnan(PAL_POSINF, PAL_POSINF, PAL_NEGINF);
|
||||
fma_test1_validate_isnan(PAL_NEGINF, PAL_NEGINF, PAL_NEGINF);
|
||||
fma_test1_validate_isnan(PAL_POSINF, PAL_NEGINF, PAL_POSINF);
|
||||
fma_test1_validate_isnan(PAL_NEGINF, PAL_POSINF, PAL_POSINF);
|
||||
|
||||
fma_test1_validate_isnan(PAL_POSINF, 1, PAL_NEGINF);
|
||||
fma_test1_validate_isnan(PAL_NEGINF, 1, PAL_POSINF);
|
||||
fma_test1_validate_isnan(1, PAL_POSINF, PAL_NEGINF);
|
||||
fma_test1_validate_isnan(1, PAL_NEGINF, PAL_POSINF);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,144 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=====================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Tests that fmaf returns correct values for a subset of values.
|
||||
** Tests with positive and negative values of x, y, and z to ensure
|
||||
** fmaf is returning correct results.
|
||||
**
|
||||
**===================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrtf(-1.0f)
|
||||
#define PAL_POSINF -logf(0.0f)
|
||||
#define PAL_NEGINF logf(0.0f)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float x; /* first component of the value to test the function with */
|
||||
float y; /* second component of the value to test the function with */
|
||||
float z; /* third component of the value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* fmaf_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl fmaf_test1_validate(float x, float y, float z, float expected, float variance)
|
||||
{
|
||||
float result = fmaf(x, y, z);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("fmaf(%g, %g, %g) returned %10.9g when it should have returned %10.9g",
|
||||
x, y, z, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* fmaf_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl fmaf_test1_validate_isnan(float x, float y, float z)
|
||||
{
|
||||
float result = fmaf(x, y, z);
|
||||
|
||||
if (!_isnanf(result))
|
||||
{
|
||||
Fail("fmaf(%g, %g, %g) returned %10.9g when it should have returned %10.9g",
|
||||
x, y, z, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_fmaf_test1_paltest_fmaf_test1, "c_runtime/fmaf/test1/paltest_fmaf_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* x y z expected variance */
|
||||
{ PAL_NEGINF, PAL_NEGINF, PAL_NEGINF, PAL_NEGINF, 0 },
|
||||
{ -1e38, 2, 1e38, -1e38, 0 },
|
||||
{ 1e38, 2, -1e38, 1e38, 0 },
|
||||
{ PAL_POSINF, PAL_POSINF, PAL_POSINF, PAL_POSINF, 0 },
|
||||
};
|
||||
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
fmaf_test1_validate(tests[i].x, tests[i].y, tests[i].z, tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
// Returns NaN if x or y is infinite, the other is zero, and z is NaN
|
||||
fmaf_test1_validate_isnan(PAL_NEGINF, 0, PAL_NAN);
|
||||
fmaf_test1_validate_isnan(PAL_POSINF, 0, PAL_NAN);
|
||||
fmaf_test1_validate_isnan(0, PAL_NEGINF, PAL_NAN);
|
||||
fmaf_test1_validate_isnan(0, PAL_POSINF, PAL_NAN);
|
||||
|
||||
// Returns NaN if x or y is infinite, the other is zero, and z is not-NaN
|
||||
fmaf_test1_validate_isnan(PAL_POSINF, 0, PAL_NEGINF);
|
||||
fmaf_test1_validate_isnan(PAL_NEGINF, 0, PAL_NEGINF);
|
||||
fmaf_test1_validate_isnan(0, PAL_POSINF, PAL_NEGINF);
|
||||
fmaf_test1_validate_isnan(0, PAL_NEGINF, PAL_NEGINF);
|
||||
|
||||
fmaf_test1_validate_isnan(PAL_POSINF, 0, 0);
|
||||
fmaf_test1_validate_isnan(PAL_NEGINF, 0, 0);
|
||||
fmaf_test1_validate_isnan(0, PAL_POSINF, 0);
|
||||
fmaf_test1_validate_isnan(0, PAL_NEGINF, 0);
|
||||
|
||||
fmaf_test1_validate_isnan(PAL_POSINF, 0, PAL_POSINF);
|
||||
fmaf_test1_validate_isnan(PAL_NEGINF, 0, PAL_POSINF);
|
||||
fmaf_test1_validate_isnan(0, PAL_POSINF, PAL_POSINF);
|
||||
fmaf_test1_validate_isnan(0, PAL_NEGINF, PAL_POSINF);
|
||||
|
||||
// Returns NaN if (x * y) is infinite, and z is an infinite of the opposite sign
|
||||
fmaf_test1_validate_isnan(PAL_POSINF, PAL_POSINF, PAL_NEGINF);
|
||||
fmaf_test1_validate_isnan(PAL_NEGINF, PAL_NEGINF, PAL_NEGINF);
|
||||
fmaf_test1_validate_isnan(PAL_POSINF, PAL_NEGINF, PAL_POSINF);
|
||||
fmaf_test1_validate_isnan(PAL_NEGINF, PAL_POSINF, PAL_POSINF);
|
||||
|
||||
fmaf_test1_validate_isnan(PAL_POSINF, 1, PAL_NEGINF);
|
||||
fmaf_test1_validate_isnan(PAL_NEGINF, 1, PAL_POSINF);
|
||||
fmaf_test1_validate_isnan(1, PAL_POSINF, PAL_NEGINF);
|
||||
fmaf_test1_validate_isnan(1, PAL_NEGINF, PAL_POSINF);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,156 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that fmod return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double numerator; /* second component of the value to test the function with */
|
||||
double denominator; /* first component of the value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* fmod_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl fmod_test1_validate(double numerator, double denominator, double expected, double variance)
|
||||
{
|
||||
double result = fmod(numerator, denominator);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("fmod(%g, %g) returned %20.17g when it should have returned %20.17g",
|
||||
numerator, denominator, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* fmod_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl fmod_test1_validate_isnan(double numerator, double denominator)
|
||||
{
|
||||
double result = fmod(numerator, denominator);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("fmod(%g, %g) returned %20.17g when it should have returned %20.17g",
|
||||
numerator, denominator, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_fmod_test1_paltest_fmod_test1, "c_runtime/fmod/test1/paltest_fmod_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* numerator denominator expected variance */
|
||||
{ 0, PAL_POSINF, 0, PAL_EPSILON },
|
||||
{ 0.31296179620778659, 0.94976571538163866, 0.31296179620778658, PAL_EPSILON },
|
||||
{ 0.42077048331375735, 0.90716712923909839, 0.42077048331375733, PAL_EPSILON },
|
||||
{ 0.59448076852482208, 0.80410982822879171, 0.59448076852482212, PAL_EPSILON },
|
||||
{ 0.63896127631363480, 0.76923890136397213, 0.63896127631363475, PAL_EPSILON },
|
||||
{ 0.64963693908006244, 0.76024459707563015, 0.64963693908006248, PAL_EPSILON },
|
||||
{ 0.70710678118654752, 0.70710678118654752, 0, PAL_EPSILON },
|
||||
{ 1, 1, 0, PAL_EPSILON },
|
||||
{ 0.84147098480789651, 0.54030230586813972, 0.30116867893975674, PAL_EPSILON },
|
||||
{ 0.90371945743584630, 0.42812514788535792, 0.047469161665130377, PAL_EPSILON / 10 },
|
||||
{ 0.98776594599273553, 0.15594369476537447, 0.052103777400488605, PAL_EPSILON / 10 },
|
||||
{ 0.99180624439366372, 0.12775121753523991, 0.097547721646984359, PAL_EPSILON / 10 },
|
||||
{ 0.74398033695749319, -0.66820151019031295, 0.075778826767180285, PAL_EPSILON / 10 },
|
||||
{ 0.41078129050290870, -0.91173391478696510, 0.41078129050290868, PAL_EPSILON },
|
||||
{ 0, -1, 0, PAL_EPSILON },
|
||||
{ 1, PAL_POSINF, 1, PAL_EPSILON * 10 },
|
||||
};
|
||||
|
||||
|
||||
// PAL initialization
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
fmod_test1_validate( tests[i].numerator, tests[i].denominator, tests[i].expected, tests[i].variance);
|
||||
fmod_test1_validate(-tests[i].numerator, tests[i].denominator, -tests[i].expected, tests[i].variance);
|
||||
fmod_test1_validate( tests[i].numerator, -tests[i].denominator, tests[i].expected, tests[i].variance);
|
||||
fmod_test1_validate(-tests[i].numerator, -tests[i].denominator, -tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
fmod_test1_validate_isnan( 0, 0);
|
||||
fmod_test1_validate_isnan(-0.0, 0);
|
||||
fmod_test1_validate_isnan( 0, -0.0);
|
||||
fmod_test1_validate_isnan(-0.0, -0.0);
|
||||
|
||||
fmod_test1_validate_isnan( 1, 0);
|
||||
fmod_test1_validate_isnan(-1.0, 0);
|
||||
fmod_test1_validate_isnan( 1, -0.0);
|
||||
fmod_test1_validate_isnan(-1.0, -0.0);
|
||||
|
||||
fmod_test1_validate_isnan(PAL_POSINF, PAL_POSINF);
|
||||
fmod_test1_validate_isnan(PAL_NEGINF, PAL_POSINF);
|
||||
fmod_test1_validate_isnan(PAL_POSINF, PAL_NEGINF);
|
||||
fmod_test1_validate_isnan(PAL_NEGINF, PAL_NEGINF);
|
||||
|
||||
fmod_test1_validate_isnan(PAL_POSINF, 0);
|
||||
fmod_test1_validate_isnan(PAL_NEGINF, 0);
|
||||
fmod_test1_validate_isnan(PAL_POSINF, -0.0);
|
||||
fmod_test1_validate_isnan(PAL_NEGINF, -0.0);
|
||||
|
||||
fmod_test1_validate_isnan(PAL_POSINF, 1);
|
||||
fmod_test1_validate_isnan(PAL_NEGINF, 1);
|
||||
fmod_test1_validate_isnan(PAL_POSINF, -1.0);
|
||||
fmod_test1_validate_isnan(PAL_NEGINF, -1.0);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,155 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that fmodf return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabsf
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float numerator; /* second component of the value to test the function with */
|
||||
float denominator; /* first component of the value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* fmodf_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl fmodf_test1_validate(float numerator, float denominator, float expected, float variance)
|
||||
{
|
||||
float result = fmodf(numerator, denominator);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("fmodf(%g, %g) returned %10.9g when it should have returned %10.9g",
|
||||
numerator, denominator, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* fmodf_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl fmodf_test1_validate_isnan(float numerator, float denominator)
|
||||
{
|
||||
float result = fmodf(numerator, denominator);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("fmodf(%g, %g) returned %10.9g when it should have returned %10.9g",
|
||||
numerator, denominator, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_fmodf_test1_paltest_fmodf_test1, "c_runtime/fmodf/test1/paltest_fmodf_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* numerator denominator expected variance */
|
||||
{ 0, PAL_POSINF, 0, PAL_EPSILON },
|
||||
{ 0.312961796f, 0.949765715f, 0.312961796f, PAL_EPSILON },
|
||||
{ 0.420770483f, 0.907167129f, 0.420770483f, PAL_EPSILON },
|
||||
{ 0.594480769f, 0.804109828f, 0.594480769f, PAL_EPSILON },
|
||||
{ 0.638961276f, 0.769238901f, 0.638961276f, PAL_EPSILON },
|
||||
{ 0.649636939f, 0.760244597f, 0.649636939f, PAL_EPSILON },
|
||||
{ 0.707106781f, 0.707106781f, 0, PAL_EPSILON },
|
||||
{ 1, 1, 0, PAL_EPSILON },
|
||||
{ 0.841470985f, 0.540302306f, 0.301168679f, PAL_EPSILON },
|
||||
{ 0.903719457f, 0.428125148f, 0.0474691617f, PAL_EPSILON / 10 },
|
||||
{ 0.987765946f, 0.155943695f, 0.0521037774f, PAL_EPSILON / 10 },
|
||||
{ 0.991806244f, 0.127751218f, 0.0975477216f, PAL_EPSILON / 10 },
|
||||
{ 0.743980337f, -0.668201510f, 0.0757788268f, PAL_EPSILON / 10 },
|
||||
{ 0.410781291f, -0.911733915f, 0.410781291f, PAL_EPSILON },
|
||||
{ 0, -1, 0, PAL_EPSILON },
|
||||
{ 1, PAL_POSINF, 1, PAL_EPSILON * 10 },
|
||||
};
|
||||
|
||||
|
||||
// PAL initialization
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
fmodf_test1_validate( tests[i].numerator, tests[i].denominator, tests[i].expected, tests[i].variance);
|
||||
fmodf_test1_validate(-tests[i].numerator, tests[i].denominator, -tests[i].expected, tests[i].variance);
|
||||
fmodf_test1_validate( tests[i].numerator, -tests[i].denominator, tests[i].expected, tests[i].variance);
|
||||
fmodf_test1_validate(-tests[i].numerator, -tests[i].denominator, -tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
fmodf_test1_validate_isnan( 0, 0);
|
||||
fmodf_test1_validate_isnan(-0.0f, 0);
|
||||
fmodf_test1_validate_isnan( 0, -0.0f);
|
||||
fmodf_test1_validate_isnan(-0.0f, -0.0f);
|
||||
|
||||
fmodf_test1_validate_isnan( 1, 0);
|
||||
fmodf_test1_validate_isnan(-1, 0);
|
||||
fmodf_test1_validate_isnan( 1, -0.0f);
|
||||
fmodf_test1_validate_isnan(-1, -0.0f);
|
||||
|
||||
fmodf_test1_validate_isnan(PAL_POSINF, PAL_POSINF);
|
||||
fmodf_test1_validate_isnan(PAL_NEGINF, PAL_POSINF);
|
||||
fmodf_test1_validate_isnan(PAL_POSINF, PAL_NEGINF);
|
||||
fmodf_test1_validate_isnan(PAL_NEGINF, PAL_NEGINF);
|
||||
|
||||
fmodf_test1_validate_isnan(PAL_POSINF, 0);
|
||||
fmodf_test1_validate_isnan(PAL_NEGINF, 0);
|
||||
fmodf_test1_validate_isnan(PAL_POSINF, -0.0f);
|
||||
fmodf_test1_validate_isnan(PAL_NEGINF, -0.0f);
|
||||
|
||||
fmodf_test1_validate_isnan(PAL_POSINF, 1);
|
||||
fmodf_test1_validate_isnan(PAL_NEGINF, 1);
|
||||
fmodf_test1_validate_isnan(PAL_POSINF, -1);
|
||||
fmodf_test1_validate_isnan(PAL_NEGINF, -1);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=====================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Tests that ilogb returns correct values.
|
||||
**
|
||||
**===================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double value; /* value to test the function with */
|
||||
int expected; /* expected result */
|
||||
};
|
||||
|
||||
/**
|
||||
* ilogb_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl ilogb_test1_validate(double value, int expected)
|
||||
{
|
||||
int result = ilogb(value);
|
||||
|
||||
if (result != expected)
|
||||
{
|
||||
Fail("ilogb(%g) returned %d when it should have returned %d",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_ilogb_test1_paltest_ilogb_test1, "c_runtime/ilogb/test1/paltest_ilogb_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected */
|
||||
{ PAL_NEGINF, 2147483647 },
|
||||
{ 0, -2147483648 },
|
||||
{ PAL_POSINF, 2147483647 },
|
||||
{ 0.11331473229676087, -4 }, // expected: -(pi)
|
||||
{ 0.15195522325791297, -3 }, // expected: -(e)
|
||||
{ 0.20269956628651730, -3 }, // expected: -(ln(10))
|
||||
{ 0.33662253682241906, -2 }, // expected: -(pi / 2)
|
||||
{ 0.36787944117144232, -2 }, // expected: -(log2(e))
|
||||
{ 0.37521422724648177, -2 }, // expected: -(sqrt(2))
|
||||
{ 0.45742934732229695, -2 }, // expected: -(2 / sqrt(pi))
|
||||
{ 0.5, -1 }, // expected: -(1)
|
||||
{ 0.58019181037172444, -1 }, // expected: -(pi / 4)
|
||||
{ 0.61254732653606592, -1 }, // expected: -(1 / sqrt(2))
|
||||
{ 0.61850313780157598, -1 }, // expected: -(ln(2))
|
||||
{ 0.64321824193300488, -1 }, // expected: -(2 / pi)
|
||||
{ 0.74005557395545179, -1 }, // expected: -(log10(e))
|
||||
{ 0.80200887896145195, -1 }, // expected: -(1 / pi)
|
||||
{ 1, 0 },
|
||||
{ 1.2468689889006383, 0 }, // expected: 1 / pi
|
||||
{ 1.3512498725672678, 0 }, // expected: log10(e)
|
||||
{ 1.5546822754821001, 0 }, // expected: 2 / pi
|
||||
{ 1.6168066722416747, 0 }, // expected: ln(2)
|
||||
{ 1.6325269194381528, 0 }, // expected: 1 / sqrt(2)
|
||||
{ 1.7235679341273495, 0 }, // expected: pi / 4
|
||||
{ 2, 1 },
|
||||
{ 2.1861299583286618, 1 }, // expected: 2 / sqrt(pi)
|
||||
{ 2.6651441426902252, 1 }, // expected: sqrt(2)
|
||||
{ 2.7182818284590452, 1 }, // expected: log2(e) value: e
|
||||
{ 2.9706864235520193, 1 }, // expected: pi / 2
|
||||
{ 4.9334096679145963, 2 }, // expected: ln(10)
|
||||
{ 6.5808859910179210, 2 }, // expected: e
|
||||
{ 8.8249778270762876, 3 }, // expected: pi
|
||||
{ PAL_NAN, 2147483647 },
|
||||
};
|
||||
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
ilogb_test1_validate(tests[i].value, tests[i].expected);
|
||||
}
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=====================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Tests that ilogbf returns correct values.
|
||||
**
|
||||
**===================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
#define PAL_NAN sqrtf(-1.0f)
|
||||
#define PAL_POSINF -logf(0.0f)
|
||||
#define PAL_NEGINF logf(0.0f)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float value; /* value to test the function with */
|
||||
int expected; /* expected result */
|
||||
};
|
||||
|
||||
/**
|
||||
* ilogbf_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl ilogbf_test1_validate(float value, int expected)
|
||||
{
|
||||
int result = ilogbf(value);
|
||||
|
||||
if (result != expected)
|
||||
{
|
||||
Fail("ilogbf(%g) returned %d when it should have returned %d",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_ilogbf_test1_paltest_ilogbf_test1, "c_runtime/ilogbf/test1/paltest_ilogbf_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected */
|
||||
{ PAL_NEGINF, 2147483647 },
|
||||
{ 0, -2147483648 },
|
||||
{ PAL_POSINF, 2147483647 },
|
||||
{ 0.113314732f, -4 }, // expected: -(pi)
|
||||
{ 0.151955223f, -3 }, // expected: -(e)
|
||||
{ 0.202699566f, -3 }, // expected: -(ln(10))
|
||||
{ 0.336622537f, -2 }, // expected: -(pi / 2)
|
||||
{ 0.367879441f, -2 }, // expected: -(log2(e))
|
||||
{ 0.375214227f, -2 }, // expected: -(sqrt(2))
|
||||
{ 0.457429347f, -2 }, // expected: -(2 / sqrt(pi))
|
||||
{ 0.5f, -1 }, // expected: -(1)
|
||||
{ 0.580191810f, -1 }, // expected: -(pi / 4)
|
||||
{ 0.612547327f, -1 }, // expected: -(1 / sqrt(2))
|
||||
{ 0.618503138f, -1 }, // expected: -(ln(2))
|
||||
{ 0.643218242f, -1 }, // expected: -(2 / pi)
|
||||
{ 0.740055574f, -1 }, // expected: -(log10(e))
|
||||
{ 0.802008879f, -1 }, // expected: -(1 / pi)
|
||||
{ 1, 0 },
|
||||
{ 1.24686899f, 0 }, // expected: 1 / pi
|
||||
{ 1.35124987f, 0 }, // expected: log10(e)
|
||||
{ 1.55468228f, 0 }, // expected: 2 / pi
|
||||
{ 1.61680667f, 0 }, // expected: ln(2)
|
||||
{ 1.63252692f, 0 }, // expected: 1 / sqrt(2)
|
||||
{ 1.72356793f, 0 }, // expected: pi / 4
|
||||
{ 2, 1 },
|
||||
{ 2.18612996f, 1 }, // expected: 2 / sqrt(pi)
|
||||
{ 2.66514414f, 1 }, // expected: sqrt(2)
|
||||
{ 2.71828183f, 1 }, // expected: log2(e) value: e
|
||||
{ 2.97068642f, 1 }, // expected: pi / 2
|
||||
{ 4.93340967f, 2 }, // expected: ln(10)
|
||||
{ 6.58088599f, 2 }, // expected: e
|
||||
{ 8.82497783f, 3 }, // expected: pi
|
||||
{ PAL_NAN, 2147483647 },
|
||||
};
|
||||
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
ilogbf_test1_validate(tests[i].value, tests[i].expected);
|
||||
}
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,139 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=====================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Tests log with a normal set of values.
|
||||
**
|
||||
**===================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double value; /* value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* log_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl log_test1_validate(double value, double expected, double variance)
|
||||
{
|
||||
double result = log(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("log(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* log_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl log_test1_validate_isnan(double value)
|
||||
{
|
||||
double result = log(value);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("log(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_log_test1_paltest_log_test1, "c_runtime/log/test1/paltest_log_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, PAL_NEGINF, 0 },
|
||||
{ 0.043213918263772250, -3.1415926535897932, PAL_EPSILON * 10 }, // expected: -(pi)
|
||||
{ 0.065988035845312537, -2.7182818284590452, PAL_EPSILON * 10 }, // expected: -(e)
|
||||
{ 0.1, -2.3025850929940457, PAL_EPSILON * 10 }, // expected: -(ln(10))
|
||||
{ 0.20787957635076191, -1.5707963267948966, PAL_EPSILON * 10 }, // expected: -(pi / 2)
|
||||
{ 0.23629008834452270, -1.4426950408889634, PAL_EPSILON * 10 }, // expected: -(log2(e))
|
||||
{ 0.24311673443421421, -1.4142135623730950, PAL_EPSILON * 10 }, // expected: -(sqrt(2))
|
||||
{ 0.32355726390307110, -1.1283791670955126, PAL_EPSILON * 10 }, // expected: -(2 / sqrt(pi))
|
||||
{ 0.36787944117144232, -1, PAL_EPSILON * 10 }, // expected: -(1)
|
||||
{ 0.45593812776599624, -0.78539816339744831, PAL_EPSILON }, // expected: -(pi / 4)
|
||||
{ 0.49306869139523979, -0.70710678118654752, PAL_EPSILON }, // expected: -(1 / sqrt(2))
|
||||
{ 0.5, -0.69314718055994531, PAL_EPSILON }, // expected: -(ln(2))
|
||||
{ 0.52907780826773535, -0.63661977236758134, PAL_EPSILON }, // expected: -(2 / pi)
|
||||
{ 0.64772148514180065, -0.43429448190325183, PAL_EPSILON }, // expected: -(log10(e))
|
||||
{ 0.72737734929521647, -0.31830988618379067, PAL_EPSILON }, // expected: -(1 / pi)
|
||||
{ 1, 0, PAL_EPSILON },
|
||||
{ 1.3748022274393586, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi
|
||||
{ 1.5438734439711811, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e)
|
||||
{ 1.8900811645722220, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi
|
||||
{ 2, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2)
|
||||
{ 2.0281149816474725, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2)
|
||||
{ 2.1932800507380155, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4
|
||||
{ 2.7182818284590452, 1, PAL_EPSILON * 10 }, // value: e
|
||||
{ 3.0906430223107976, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi)
|
||||
{ 4.1132503787829275, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2)
|
||||
{ 4.2320861065570819, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e)
|
||||
{ 4.8104773809653517, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2
|
||||
{ 10, 2.3025850929940457, PAL_EPSILON * 10 }, // expected: ln(10)
|
||||
{ 15.154262241479264, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e
|
||||
{ 23.140692632779269, 3.1415926535897932, PAL_EPSILON * 10 }, // expected: pi
|
||||
{ PAL_POSINF, PAL_POSINF, 0 },
|
||||
};
|
||||
|
||||
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
log_test1_validate(tests[i].value, tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
log_test1_validate_isnan(PAL_NEGINF);
|
||||
log_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,145 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that log10 returns correct values.
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
** _isnan
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double value; /* value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* log10_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl log10_test1_validate(double value, double expected, double variance)
|
||||
{
|
||||
double result = log10(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("log10(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* log10_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl log10_test1_validate_isnan(double value)
|
||||
{
|
||||
double result = log10(value);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("log10(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_log10_test1_paltest_log10_test1, "c_runtime/log10/test1/paltest_log10_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, PAL_NEGINF, 0 },
|
||||
{ 0.00072178415907472774, -3.1415926535897932, PAL_EPSILON * 10 }, // expected: -(pi)
|
||||
{ 0.0019130141022243176, -2.7182818284590452, PAL_EPSILON * 10 }, // expected: -(e)
|
||||
{ 0.0049821282964407206, -2.3025850929940457, PAL_EPSILON * 10 }, // expected: -(ln(10))
|
||||
{ 0.026866041001136132, -1.5707963267948966, PAL_EPSILON * 10 }, // expected: -(pi / 2)
|
||||
{ 0.036083192820787210, -1.4426950408889634, PAL_EPSILON * 10 }, // expected: -(log2(e))
|
||||
{ 0.038528884700322026, -1.4142135623730950, PAL_EPSILON * 10 }, // expected: -(sqrt(2))
|
||||
{ 0.074408205860642723, -1.1283791670955126, PAL_EPSILON * 10 }, // expected: -(2 / sqrt(pi))
|
||||
{ 0.1, -1, PAL_EPSILON * 10 }, // expected: -(1)
|
||||
{ 0.16390863613957665, -0.78539816339744831, PAL_EPSILON }, // expected: -(pi / 4)
|
||||
{ 0.19628775993505562, -0.70710678118654752, PAL_EPSILON }, // expected: -(1 / sqrt(2))
|
||||
{ 0.20269956628651730, -0.69314718055994531, PAL_EPSILON }, // expected: -(ln(2))
|
||||
{ 0.23087676451600055, -0.63661977236758134, PAL_EPSILON }, // expected: -(2 / pi)
|
||||
{ 0.36787944117144232, -0.43429448190325183, PAL_EPSILON }, // expected: -(log10(e))
|
||||
{ 0.48049637305186868, -0.31830988618379067, PAL_EPSILON }, // expected: -(1 / pi)
|
||||
{ 1, 0, PAL_EPSILON },
|
||||
{ 2.0811811619898573, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi
|
||||
{ 2.7182818284590452, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e) value: e
|
||||
{ 4.3313150290214525, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi
|
||||
{ 4.9334096679145963, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2)
|
||||
{ 5.0945611704512962, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2)
|
||||
{ 6.1009598002416937, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4
|
||||
{ 10, 1, PAL_EPSILON * 10 },
|
||||
{ 13.439377934644400, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi)
|
||||
{ 25.954553519470081, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2)
|
||||
{ 27.713733786437790, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e)
|
||||
{ 37.221710484165167, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2
|
||||
{ 200.71743249053009, 2.3025850929940457, PAL_EPSILON * 10 }, // expected: ln(10)
|
||||
{ 522.73529967043665, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e
|
||||
{ 1385.4557313670111, 3.1415926535897932, PAL_EPSILON * 10 }, // expected: pi
|
||||
{ PAL_POSINF, PAL_POSINF, 0 },
|
||||
};
|
||||
|
||||
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
log10_test1_validate(tests[i].value, tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
log10_test1_validate_isnan(PAL_NEGINF);
|
||||
log10_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,143 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that log10f returns correct values.
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
** _isnanf
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrtf(-1.0f)
|
||||
#define PAL_POSINF -logf(0.0f)
|
||||
#define PAL_NEGINF logf(0.0f)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float value; /* value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* log10f_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl log10f_test1_validate(float value, float expected, float variance)
|
||||
{
|
||||
float result = log10f(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("log10f(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* log10f_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl log10f_test1_validate_isnan(float value)
|
||||
{
|
||||
float result = log10f(value);
|
||||
|
||||
if (!_isnanf(result))
|
||||
{
|
||||
Fail("log10f(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_log10f_test1_paltest_log10f_test1, "c_runtime/log10f/test1/paltest_log10f_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, PAL_NEGINF, 0 },
|
||||
{ 0.000721784159f, -3.14159265f, PAL_EPSILON * 10 }, // expected: -(pi)
|
||||
{ 0.00191301410f, -2.71828183f, PAL_EPSILON * 10 }, // expected: -(e)
|
||||
{ 0.00498212830f, -2.30258509f, PAL_EPSILON * 10 }, // expected: -(ln(10))
|
||||
{ 0.0268660410f, -1.57079633f, PAL_EPSILON * 10 }, // expected: -(pi / 2)
|
||||
{ 0.0360831928f, -1.44269504f, PAL_EPSILON * 10 }, // expected: -(logf2(e))
|
||||
{ 0.0385288847f, -1.41421356f, PAL_EPSILON * 10 }, // expected: -(sqrtf(2))
|
||||
{ 0.0744082059f, -1.12837917f, PAL_EPSILON * 10 }, // expected: -(2 / sqrtf(pi))
|
||||
{ 0.1f, -1, PAL_EPSILON * 10 }, // expected: -(1)
|
||||
{ 0.163908636f, -0.785398163f, PAL_EPSILON }, // expected: -(pi / 4)
|
||||
{ 0.196287760f, -0.707106781f, PAL_EPSILON }, // expected: -(1 / sqrtf(2))
|
||||
{ 0.202699566f, -0.693147181f, PAL_EPSILON }, // expected: -(ln(2))
|
||||
{ 0.230876765f, -0.636619772f, PAL_EPSILON }, // expected: -(2 / pi)
|
||||
{ 0.367879441f, -0.434294482f, PAL_EPSILON }, // expected: -(log10f(e))
|
||||
{ 0.480496373f, -0.318309886f, PAL_EPSILON }, // expected: -(1 / pi)
|
||||
{ 1, 0, PAL_EPSILON },
|
||||
{ 2.08118116f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi
|
||||
{ 2.71828183f, 0.434294482f, PAL_EPSILON }, // expected: log10f(e) value: e
|
||||
{ 4.33131503f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi
|
||||
{ 4.93340967f, 0.693147181f, PAL_EPSILON }, // expected: ln(2)
|
||||
{ 5.09456117f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2)
|
||||
{ 6.10095980f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4
|
||||
{ 10, 1, PAL_EPSILON * 10 },
|
||||
{ 13.4393779f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi)
|
||||
{ 25.9545535f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2)
|
||||
{ 27.7137338f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e)
|
||||
{ 37.2217105f, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2
|
||||
{ 200.717432f, 2.30258509f, PAL_EPSILON * 10 }, // expected: ln(10)
|
||||
{ 522.735300f, 2.71828183f, PAL_EPSILON * 10 }, // expected: e
|
||||
{ 1385.45573f, 3.14159265f, PAL_EPSILON * 10 }, // expected: pi
|
||||
{ PAL_POSINF, PAL_POSINF, 0 },
|
||||
};
|
||||
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
log10f_test1_validate(tests[i].value, tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
log10f_test1_validate_isnan(PAL_NEGINF);
|
||||
log10f_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,138 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=====================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Tests that log2 returns correct values.
|
||||
**
|
||||
**===================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double value; /* value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* log2_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl log2_test1_validate(double value, double expected, double variance)
|
||||
{
|
||||
double result = log2(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("log2(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* log2_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl log2_test1_validate_isnan(double value)
|
||||
{
|
||||
double result = log2(value);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("log2(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_log2_test1_paltest_log2_test1, "c_runtime/log2/test1/paltest_log2_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, PAL_NEGINF, 0 },
|
||||
{ 0.11331473229676087, -3.1415926535897932, PAL_EPSILON * 10 }, // expected: -(pi)
|
||||
{ 0.15195522325791297, -2.7182818284590452, PAL_EPSILON * 10 }, // expected: -(e)
|
||||
{ 0.20269956628651730, -2.3025850929940457, PAL_EPSILON * 10 }, // expected: -(ln(10))
|
||||
{ 0.33662253682241906, -1.5707963267948966, PAL_EPSILON * 10 }, // expected: -(pi / 2)
|
||||
{ 0.36787944117144232, -1.4426950408889634, PAL_EPSILON * 10 }, // expected: -(log2(e))
|
||||
{ 0.37521422724648177, -1.4142135623730950, PAL_EPSILON * 10 }, // expected: -(sqrt(2))
|
||||
{ 0.45742934732229695, -1.1283791670955126, PAL_EPSILON * 10 }, // expected: -(2 / sqrt(pi))
|
||||
{ 0.5, -1, PAL_EPSILON * 10 }, // expected: -(1)
|
||||
{ 0.58019181037172444, -0.78539816339744831, PAL_EPSILON }, // expected: -(pi / 4)
|
||||
{ 0.61254732653606592, -0.70710678118654752, PAL_EPSILON }, // expected: -(1 / sqrt(2))
|
||||
{ 0.61850313780157598, -0.69314718055994531, PAL_EPSILON }, // expected: -(ln(2))
|
||||
{ 0.64321824193300488, -0.63661977236758134, PAL_EPSILON }, // expected: -(2 / pi)
|
||||
{ 0.74005557395545179, -0.43429448190325183, PAL_EPSILON }, // expected: -(log10(e))
|
||||
{ 0.80200887896145195, -0.31830988618379067, PAL_EPSILON }, // expected: -(1 / pi)
|
||||
{ 1, 0, PAL_EPSILON },
|
||||
{ 1.2468689889006383, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi
|
||||
{ 1.3512498725672678, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e)
|
||||
{ 1.5546822754821001, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi
|
||||
{ 1.6168066722416747, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2)
|
||||
{ 1.6325269194381528, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2)
|
||||
{ 1.7235679341273495, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4
|
||||
{ 2, 1, PAL_EPSILON * 10 },
|
||||
{ 2.1861299583286618, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi)
|
||||
{ 2.6651441426902252, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2)
|
||||
{ 2.7182818284590452, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e) value: e
|
||||
{ 2.9706864235520193, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2
|
||||
{ 4.9334096679145963, 2.3025850929940457, PAL_EPSILON * 10 }, // expected: ln(10)
|
||||
{ 6.5808859910179210, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e
|
||||
{ 8.8249778270762876, 3.1415926535897932, PAL_EPSILON * 10 }, // expected: pi
|
||||
{ PAL_POSINF, PAL_POSINF, 0 },
|
||||
};
|
||||
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
log2_test1_validate(tests[i].value, tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
log2_test1_validate_isnan(PAL_NEGINF);
|
||||
log2_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,137 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=====================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Tests that log2f returns correct values.
|
||||
**
|
||||
**===================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrtf(-1.0f)
|
||||
#define PAL_POSINF -logf(0.0f)
|
||||
#define PAL_NEGINF logf(0.0f)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float value; /* value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* log2f_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl log2f_test1_validate(float value, float expected, float variance)
|
||||
{
|
||||
float result = log2f(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("log2f(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* log2f_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl log2f_test1_validate_isnan(float value)
|
||||
{
|
||||
float result = log2f(value);
|
||||
|
||||
if (!_isnanf(result))
|
||||
{
|
||||
Fail("log2f(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_log2f_test1_paltest_log2f_test1, "c_runtime/log2f/test1/paltest_log2f_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, PAL_NEGINF, 0 },
|
||||
{ 0.113314732f, -3.14159265f, PAL_EPSILON * 10 }, // expected: -(pi)
|
||||
{ 0.151955223f, -2.71828183f, PAL_EPSILON * 10 }, // expected: -(e)
|
||||
{ 0.202699566f, -2.30258509f, PAL_EPSILON * 10 }, // expected: -(ln(10))
|
||||
{ 0.336622537f, -1.57079633f, PAL_EPSILON * 10 }, // expected: -(pi / 2)
|
||||
{ 0.367879441f, -1.44269504f, PAL_EPSILON * 10 }, // expected: -(logf2(e))
|
||||
{ 0.375214227f, -1.41421356f, PAL_EPSILON * 10 }, // expected: -(sqrtf(2))
|
||||
{ 0.457429347f, -1.12837917f, PAL_EPSILON * 10 }, // expected: -(2 / sqrtf(pi))
|
||||
{ 0.5f, -1, PAL_EPSILON * 10 }, // expected: -(1)
|
||||
{ 0.580191810f, -0.785398163f, PAL_EPSILON }, // expected: -(pi / 4)
|
||||
{ 0.612547327f, -0.707106781f, PAL_EPSILON }, // expected: -(1 / sqrtf(2))
|
||||
{ 0.618503138f, -0.693147181f, PAL_EPSILON }, // expected: -(ln(2))
|
||||
{ 0.643218242f, -0.636619772f, PAL_EPSILON }, // expected: -(2 / pi)
|
||||
{ 0.740055574f, -0.434294482f, PAL_EPSILON }, // expected: -(log10f(e))
|
||||
{ 0.802008879f, -0.318309886f, PAL_EPSILON }, // expected: -(1 / pi)
|
||||
{ 1, 0, PAL_EPSILON },
|
||||
{ 1.24686899f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi
|
||||
{ 1.35124987f, 0.434294482f, PAL_EPSILON }, // expected: log10f(e) value: e
|
||||
{ 1.55468228f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi
|
||||
{ 1.61680667f, 0.693147181f, PAL_EPSILON }, // expected: ln(2)
|
||||
{ 1.63252692f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2)
|
||||
{ 1.72356793f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4
|
||||
{ 2, 1, PAL_EPSILON * 10 },
|
||||
{ 2.18612996f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi)
|
||||
{ 2.66514414f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2)
|
||||
{ 2.71828183f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e)
|
||||
{ 2.97068642f, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2
|
||||
{ 4.93340967f, 2.30258509f, PAL_EPSILON * 10 }, // expected: ln(10)
|
||||
{ 6.58088599f, 2.71828183f, PAL_EPSILON * 10 }, // expected: e
|
||||
{ 8.82497783f, 3.14159265f, PAL_EPSILON * 10 }, // expected: pi
|
||||
{ PAL_POSINF, PAL_POSINF, 0 },
|
||||
};
|
||||
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
log2f_test1_validate(tests[i].value, tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
log2f_test1_validate_isnan(PAL_NEGINF);
|
||||
log2f_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,138 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=====================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Tests logf with a normal set of values.
|
||||
**
|
||||
**===================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrtf(-1.0f)
|
||||
#define PAL_POSINF -logf(0.0f)
|
||||
#define PAL_NEGINF logf(0.0f)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float value; /* value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* logf_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl logf_test1_validate(float value, float expected, float variance)
|
||||
{
|
||||
float result = logf(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("logf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* logf_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl logf_test1_validate_isnan(float value)
|
||||
{
|
||||
float result = logf(value);
|
||||
|
||||
if (!_isnanf(result))
|
||||
{
|
||||
Fail("logf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_logf_test1_paltest_logf_test1, "c_runtime/logf/test1/paltest_logf_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, PAL_NEGINF, 0 },
|
||||
{ 0.0432139183f, -3.14159265f, PAL_EPSILON * 10 }, // expected: -(pi)
|
||||
{ 0.0659880358f, -2.71828183f, PAL_EPSILON * 10 }, // expected: -(e)
|
||||
{ 0.1f, -2.30258509f, PAL_EPSILON * 10 }, // expected: -(ln(10))
|
||||
{ 0.207879576f, -1.57079633f, PAL_EPSILON * 10 }, // expected: -(pi / 2)
|
||||
{ 0.236290088f, -1.44269504f, PAL_EPSILON * 10 }, // expected: -(logf2(e))
|
||||
{ 0.243116734f, -1.41421356f, PAL_EPSILON * 10 }, // expected: -(sqrtf(2))
|
||||
{ 0.323557264f, -1.12837917f, PAL_EPSILON * 10 }, // expected: -(2 / sqrtf(pi))
|
||||
{ 0.367879441f, -1, PAL_EPSILON * 10 }, // expected: -(1)
|
||||
{ 0.455938128f, -0.785398163f, PAL_EPSILON }, // expected: -(pi / 4)
|
||||
{ 0.493068691f, -0.707106781f, PAL_EPSILON }, // expected: -(1 / sqrtf(2))
|
||||
{ 0.5f, -0.693147181f, PAL_EPSILON }, // expected: -(ln(2))
|
||||
{ 0.529077808f, -0.636619772f, PAL_EPSILON }, // expected: -(2 / pi)
|
||||
{ 0.647721485f, -0.434294482f, PAL_EPSILON }, // expected: -(log10f(e))
|
||||
{ 0.727377349f, -0.318309886f, PAL_EPSILON }, // expected: -(1 / pi)
|
||||
{ 1, 0, PAL_EPSILON },
|
||||
{ 1.37480223f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi
|
||||
{ 1.54387344f, 0.434294482f, PAL_EPSILON }, // expected: log10f(e)
|
||||
{ 1.89008116f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi
|
||||
{ 2, 0.693147181f, PAL_EPSILON }, // expected: ln(2)
|
||||
{ 2.02811498f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2)
|
||||
{ 2.19328005f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4
|
||||
{ 2.71828183f, 1, PAL_EPSILON * 10 }, // value: e
|
||||
{ 3.09064302f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi)
|
||||
{ 4.11325038f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2)
|
||||
{ 4.23208611f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e)
|
||||
{ 4.81047738f, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2
|
||||
{ 10, 2.30258509f, PAL_EPSILON * 10 }, // expected: ln(10)
|
||||
{ 15.1542622f, 2.71828183f, PAL_EPSILON * 10 }, // expected: e
|
||||
{ 23.1406926f, 3.14159265f, PAL_EPSILON * 10 }, // expected: pi
|
||||
{ PAL_POSINF, PAL_POSINF, 0 },
|
||||
};
|
||||
|
||||
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
logf_test1_validate(tests[i].value, tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
logf_test1_validate_isnan(PAL_NEGINF);
|
||||
logf_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,135 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c (modf)
|
||||
**
|
||||
** Purpose: Test to ensure that modf return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double value; /* value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
double expected_intpart; /* expected result */
|
||||
double variance_intpart; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* modf_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl modf_test1_validate(double value, double expected, double variance, double expected_intpart, double variance_intpart)
|
||||
{
|
||||
double result_intpart;
|
||||
double result = modf(value, &result_intpart);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
double delta_intpart = fabs(result_intpart - expected_intpart);
|
||||
|
||||
if ((delta > variance) || (delta_intpart > variance_intpart))
|
||||
{
|
||||
Fail("modf(%g) returned %20.17g with an intpart of %20.17g when it should have returned %20.17g with an intpart of %20.17g",
|
||||
value, result, result_intpart, expected, expected_intpart);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* modf_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl modf_test1_validate_isnan(double value)
|
||||
{
|
||||
double result_intpart;
|
||||
double result = modf(value, &result_intpart);
|
||||
|
||||
if (!_isnan(result) || !_isnan(result_intpart))
|
||||
{
|
||||
Fail("modf(%g) returned %20.17g with an intpart of %20.17g when it should have returned %20.17g with an intpart of %20.17g",
|
||||
value, result, result_intpart, PAL_NAN, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_modf_test1_paltest_modf_test1, "c_runtime/modf/test1/paltest_modf_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance expected_intpart variance_intpart */
|
||||
{ 0, 0, PAL_EPSILON, 0, PAL_EPSILON },
|
||||
{ 0.31830988618379067, 0.31830988618379067, PAL_EPSILON, 0, PAL_EPSILON }, // value: 1 / pi
|
||||
{ 0.43429448190325183, 0.43429448190325183, PAL_EPSILON, 0, PAL_EPSILON }, // value: log10(e)
|
||||
{ 0.63661977236758134, 0.63661977236758134, PAL_EPSILON, 0, PAL_EPSILON }, // value: 2 / pi
|
||||
{ 0.69314718055994531, 0.69314718055994531, PAL_EPSILON, 0, PAL_EPSILON }, // value: ln(2)
|
||||
{ 0.70710678118654752, 0.70710678118654752, PAL_EPSILON, 0, PAL_EPSILON }, // value: 1 / sqrt(2)
|
||||
{ 0.78539816339744831, 0.78539816339744831, PAL_EPSILON, 0, PAL_EPSILON }, // value: pi / 4
|
||||
{ 1, 0, PAL_EPSILON, 1, PAL_EPSILON * 10 },
|
||||
{ 1.1283791670955126, 0.1283791670955126, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi)
|
||||
{ 1.4142135623730950, 0.4142135623730950, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: sqrt(2)
|
||||
{ 1.4426950408889634, 0.4426950408889634, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: log2(e)
|
||||
{ 1.5707963267948966, 0.5707963267948966, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: pi / 2
|
||||
{ 2.3025850929940457, 0.3025850929940457, PAL_EPSILON, 2, PAL_EPSILON * 10 }, // value: ln(10)
|
||||
{ 2.7182818284590452, 0.7182818284590452, PAL_EPSILON, 2, PAL_EPSILON * 10 }, // value: e
|
||||
{ 3.1415926535897932, 0.1415926535897932, PAL_EPSILON, 3, PAL_EPSILON * 10 }, // value: pi
|
||||
{ PAL_POSINF, 0, PAL_EPSILON, PAL_POSINF, 0 }
|
||||
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
modf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance, tests[i].expected_intpart, tests[i].variance_intpart);
|
||||
modf_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance, -tests[i].expected_intpart, tests[i].variance_intpart);
|
||||
}
|
||||
|
||||
modf_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,134 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c (modf)
|
||||
**
|
||||
** Purpose: Test to ensure that modf return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float value; /* value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
float expected_intpart; /* expected result */
|
||||
float variance_intpart; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* modff_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl modff_test1_validate(float value, float expected, float variance, float expected_intpart, float variance_intpart)
|
||||
{
|
||||
float result_intpart;
|
||||
float result = modff(value, &result_intpart);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
float delta_intpart = fabsf(result_intpart - expected_intpart);
|
||||
|
||||
if ((delta > variance) || (delta_intpart > variance_intpart))
|
||||
{
|
||||
Fail("modff(%g) returned %10.9g with an intpart of %10.9g when it should have returned %10.9g with an intpart of %10.9g",
|
||||
value, result, result_intpart, expected, expected_intpart);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* modff_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl modff_test1_validate_isnan(float value)
|
||||
{
|
||||
float result_intpart;
|
||||
float result = modff(value, &result_intpart);
|
||||
|
||||
if (!_isnan(result) || !_isnan(result_intpart))
|
||||
{
|
||||
Fail("modff(%g) returned %10.9g with an intpart of %10.9g when it should have returned %10.9g with an intpart of %10.9g",
|
||||
value, result, result_intpart, PAL_NAN, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_modff_test1_paltest_modff_test1, "c_runtime/modff/test1/paltest_modff_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance expected_intpart variance_intpart */
|
||||
{ 0, 0, PAL_EPSILON, 0, PAL_EPSILON },
|
||||
{ 0.318309886f, 0.318309886f, PAL_EPSILON, 0, PAL_EPSILON }, // value: 1 / pi
|
||||
{ 0.434294482f, 0.434294482f, PAL_EPSILON, 0, PAL_EPSILON }, // value: log10(e)
|
||||
{ 0.636619772f, 0.636619772f, PAL_EPSILON, 0, PAL_EPSILON }, // value: 2 / pi
|
||||
{ 0.693147181f, 0.693147181f, PAL_EPSILON, 0, PAL_EPSILON }, // value: ln(2)
|
||||
{ 0.707106781f, 0.707106781f, PAL_EPSILON, 0, PAL_EPSILON }, // value: 1 / sqrt(2)
|
||||
{ 0.785398163f, 0.785398163f, PAL_EPSILON, 0, PAL_EPSILON }, // value: pi / 4
|
||||
{ 1, 0, PAL_EPSILON, 1, PAL_EPSILON * 10 },
|
||||
{ 1.12837917f, 0.128379167f, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi)
|
||||
{ 1.41421356f, 0.414213562f, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: sqrt(2)
|
||||
{ 1.44269504f, 0.442695041f, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: log2(e)
|
||||
{ 1.57079633f, 0.570796327f, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: pi / 2
|
||||
{ 2.30258509f, 0.302585093f, PAL_EPSILON, 2, PAL_EPSILON * 10 }, // value: ln(10)
|
||||
{ 2.71828183f, 0.718281828f, PAL_EPSILON, 2, PAL_EPSILON * 10 }, // value: e
|
||||
{ 3.14159265f, 0.141592654f, PAL_EPSILON, 3, PAL_EPSILON * 10 }, // value: pi
|
||||
{ PAL_POSINF, 0, PAL_EPSILON, PAL_POSINF, 0 }
|
||||
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
modff_test1_validate( tests[i].value, tests[i].expected, tests[i].variance, tests[i].expected_intpart, tests[i].variance_intpart);
|
||||
modff_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance, -tests[i].expected_intpart, tests[i].variance_intpart);
|
||||
}
|
||||
|
||||
modff_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,229 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=====================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Tests that atan2 returns correct values for a subset of values.
|
||||
** Tests with positive and negative values of x and y to ensure
|
||||
** atan2 is returning results from the correct quadrant.
|
||||
**
|
||||
**===================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double x; /* first component of the value to test the function with */
|
||||
double y; /* second component of the value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* pow_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl pow_test1_validate(double x, double y, double expected, double variance)
|
||||
{
|
||||
double result = pow(x, y);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("pow(%g, %g) returned %20.17g when it should have returned %20.17g",
|
||||
x, y, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* pow_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl pow_test1_validate_isnan(double x, double y)
|
||||
{
|
||||
double result = pow(x, y);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("pow(%g, %g) returned %20.17g when it should have returned %20.17g",
|
||||
x, y, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_pow_test1_paltest_pow_test1, "c_runtime/pow/test1/paltest_pow_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* x y expected variance */
|
||||
{ PAL_NEGINF, PAL_NEGINF, 0, PAL_EPSILON },
|
||||
{ PAL_NEGINF, PAL_POSINF, PAL_POSINF, 0 },
|
||||
|
||||
{ -10, PAL_NEGINF, 0, PAL_EPSILON },
|
||||
{ -10, -1, -0.1, PAL_EPSILON },
|
||||
{ -10, 0, 1, PAL_EPSILON * 10 },
|
||||
{ -10, 1, -10, PAL_EPSILON * 100 },
|
||||
{ -10, PAL_POSINF, PAL_POSINF, 0 },
|
||||
|
||||
{ -2.7182818284590452, PAL_NEGINF, 0, PAL_EPSILON }, // x: -(e)
|
||||
{ -2.7182818284590452, -1, -0.36787944117144232, PAL_EPSILON }, // x: -(e)
|
||||
{ -2.7182818284590452, 0, 1, PAL_EPSILON * 10 }, // x: -(e)
|
||||
{ -2.7182818284590452, 1, -2.7182818284590452, PAL_EPSILON * 10 }, // x: -(e) expected: e
|
||||
{ -2.7182818284590452, PAL_POSINF, PAL_POSINF, 0 }, // x: -(e)
|
||||
|
||||
{ -1.0, PAL_NEGINF, 1.0, PAL_EPSILON * 10 },
|
||||
{ -1.0, PAL_POSINF, 1.0, PAL_EPSILON * 10 },
|
||||
|
||||
{ -0.0, PAL_NEGINF, PAL_POSINF, 0 },
|
||||
{ -0.0, -1, PAL_NEGINF, 0 },
|
||||
{ -0.0, -0.0, 1, PAL_EPSILON * 10 },
|
||||
{ -0.0, 0, 1, PAL_EPSILON * 10 },
|
||||
{ -0.0, 1, -0.0, PAL_EPSILON },
|
||||
{ -0.0, PAL_POSINF, 0, PAL_EPSILON },
|
||||
|
||||
{ PAL_NAN, -0.0, 1.0, PAL_EPSILON * 10 },
|
||||
{ PAL_NAN, 0, 1.0, PAL_EPSILON * 10 },
|
||||
|
||||
{ 0.0, PAL_NEGINF, PAL_POSINF, 0 },
|
||||
{ 0.0, -1, PAL_POSINF, 0 },
|
||||
{ 0, -0.0, 1, PAL_EPSILON * 10 },
|
||||
{ 0, 0, 1, PAL_EPSILON * 10 },
|
||||
{ 0.0, 1, 0, PAL_EPSILON },
|
||||
{ 0.0, PAL_POSINF, 0, PAL_EPSILON },
|
||||
|
||||
{ 1, PAL_NEGINF, 1, PAL_EPSILON * 10 },
|
||||
{ 1, PAL_POSINF, 1, PAL_EPSILON * 10 },
|
||||
|
||||
{ 2.7182818284590452, PAL_NEGINF, 0, PAL_EPSILON },
|
||||
{ 2.7182818284590452, -3.1415926535897932, 0.043213918263772250, PAL_EPSILON / 10 }, // x: e y: -(pi)
|
||||
{ 2.7182818284590452, -2.7182818284590452, 0.065988035845312537, PAL_EPSILON / 10 }, // x: e y: -(e)
|
||||
{ 2.7182818284590452, -2.3025850929940457, 0.1, PAL_EPSILON }, // x: e y: -(ln(10))
|
||||
{ 2.7182818284590452, -1.5707963267948966, 0.20787957635076191, PAL_EPSILON }, // x: e y: -(pi / 2)
|
||||
{ 2.7182818284590452, -1.4426950408889634, 0.23629008834452270, PAL_EPSILON }, // x: e y: -(log2(e))
|
||||
{ 2.7182818284590452, -1.4142135623730950, 0.24311673443421421, PAL_EPSILON }, // x: e y: -(sqrt(2))
|
||||
{ 2.7182818284590452, -1.1283791670955126, 0.32355726390307110, PAL_EPSILON }, // x: e y: -(2 / sqrt(pi))
|
||||
{ 2.7182818284590452, -1, 0.36787944117144232, PAL_EPSILON }, // x: e y: -(1)
|
||||
{ 2.7182818284590452, -0.78539816339744831, 0.45593812776599624, PAL_EPSILON }, // x: e y: -(pi / 4)
|
||||
{ 2.7182818284590452, -0.70710678118654752, 0.49306869139523979, PAL_EPSILON }, // x: e y: -(1 / sqrt(2))
|
||||
{ 2.7182818284590452, -0.69314718055994531, 0.5, PAL_EPSILON }, // x: e y: -(ln(2))
|
||||
{ 2.7182818284590452, -0.63661977236758134, 0.52907780826773535, PAL_EPSILON }, // x: e y: -(2 / pi)
|
||||
{ 2.7182818284590452, -0.43429448190325183, 0.64772148514180065, PAL_EPSILON }, // x: e y: -(log10(e))
|
||||
{ 2.7182818284590452, -0.31830988618379067, 0.72737734929521647, PAL_EPSILON }, // x: e y: -(1 / pi)
|
||||
{ 2.7182818284590452, 0, 1, PAL_EPSILON * 10 }, // x: e
|
||||
{ 2.7182818284590452, 0.31830988618379067, 1.3748022274393586, PAL_EPSILON * 10 }, // x: e y: 1 / pi
|
||||
{ 2.7182818284590452, 0.43429448190325183, 1.5438734439711811, PAL_EPSILON * 10 }, // x: e y: log10(e)
|
||||
{ 2.7182818284590452, 0.63661977236758134, 1.8900811645722220, PAL_EPSILON * 10 }, // x: e y: 2 / pi
|
||||
{ 2.7182818284590452, 0.69314718055994531, 2, PAL_EPSILON * 10 }, // x: e y: ln(2)
|
||||
{ 2.7182818284590452, 0.70710678118654752, 2.0281149816474725, PAL_EPSILON * 10 }, // x: e y: 1 / sqrt(2)
|
||||
{ 2.7182818284590452, 0.78539816339744831, 2.1932800507380155, PAL_EPSILON * 10 }, // x: e y: pi / 4
|
||||
{ 2.7182818284590452, 1, 2.7182818284590452, PAL_EPSILON * 10 }, // x: e expected: e
|
||||
{ 2.7182818284590452, 1.1283791670955126, 3.0906430223107976, PAL_EPSILON * 10 }, // x: e y: 2 / sqrt(pi)
|
||||
{ 2.7182818284590452, 1.4142135623730950, 4.1132503787829275, PAL_EPSILON * 10 }, // x: e y: sqrt(2)
|
||||
{ 2.7182818284590452, 1.4426950408889634, 4.2320861065570819, PAL_EPSILON * 10 }, // x: e y: log2(e)
|
||||
{ 2.7182818284590452, 1.5707963267948966, 4.8104773809653517, PAL_EPSILON * 10 }, // x: e y: pi / 2
|
||||
{ 2.7182818284590452, 2.3025850929940457, 10, PAL_EPSILON * 100 }, // x: e y: ln(10)
|
||||
{ 2.7182818284590452, 2.7182818284590452, 15.154262241479264, PAL_EPSILON * 100 }, // x: e y: e
|
||||
{ 2.7182818284590452, 3.1415926535897932, 23.140692632779269, PAL_EPSILON * 100 }, // x: e y: pi
|
||||
{ 2.7182818284590452, PAL_POSINF, PAL_POSINF, 0 }, // x: e
|
||||
|
||||
{ 10, PAL_NEGINF, 0, 0 },
|
||||
{ 10, -3.1415926535897932, 0.00072178415907472774, PAL_EPSILON / 1000 }, // y: -(pi)
|
||||
{ 10, -2.7182818284590452, 0.0019130141022243176, PAL_EPSILON / 100 }, // y: -(e)
|
||||
{ 10, -2.3025850929940457, 0.0049821282964407206, PAL_EPSILON / 100 }, // y: -(ln(10))
|
||||
{ 10, -1.5707963267948966, 0.026866041001136132, PAL_EPSILON / 10 }, // y: -(pi / 2)
|
||||
{ 10, -1.4426950408889634, 0.036083192820787210, PAL_EPSILON / 10 }, // y: -(log2(e))
|
||||
{ 10, -1.4142135623730950, 0.038528884700322026, PAL_EPSILON / 10 }, // y: -(sqrt(2))
|
||||
{ 10, -1.1283791670955126, 0.074408205860642723, PAL_EPSILON / 10 }, // y: -(2 / sqrt(pi))
|
||||
{ 10, -1, 0.1, PAL_EPSILON }, // y: -(1)
|
||||
{ 10, -0.78539816339744831, 0.16390863613957665, PAL_EPSILON }, // y: -(pi / 4)
|
||||
{ 10, -0.70710678118654752, 0.19628775993505562, PAL_EPSILON }, // y: -(1 / sqrt(2))
|
||||
{ 10, -0.69314718055994531, 0.20269956628651730, PAL_EPSILON }, // y: -(ln(2))
|
||||
{ 10, -0.63661977236758134, 0.23087676451600055, PAL_EPSILON }, // y: -(2 / pi)
|
||||
{ 10, -0.43429448190325183, 0.36787944117144232, PAL_EPSILON }, // y: -(log10(e))
|
||||
{ 10, -0.31830988618379067, 0.48049637305186868, PAL_EPSILON }, // y: -(1 / pi)
|
||||
{ 10, 0, 1, PAL_EPSILON * 10 },
|
||||
{ 10, 0.31830988618379067, 2.0811811619898573, PAL_EPSILON * 10 }, // y: 1 / pi
|
||||
{ 10, 0.43429448190325183, 2.7182818284590452, PAL_EPSILON * 10 }, // y: log10(e) expected: e
|
||||
{ 10, 0.63661977236758134, 4.3313150290214525, PAL_EPSILON * 10 }, // y: 2 / pi
|
||||
{ 10, 0.69314718055994531, 4.9334096679145963, PAL_EPSILON * 10 }, // y: ln(2)
|
||||
{ 10, 0.70710678118654752, 5.0945611704512962, PAL_EPSILON * 10 }, // y: 1 / sqrt(2)
|
||||
{ 10, 0.78539816339744831, 6.1009598002416937, PAL_EPSILON * 10 }, // y: pi / 4
|
||||
{ 10, 1, 10, PAL_EPSILON * 100 },
|
||||
{ 10, 1.1283791670955126, 13.439377934644400, PAL_EPSILON * 100 }, // y: 2 / sqrt(pi)
|
||||
{ 10, 1.4142135623730950, 25.954553519470081, PAL_EPSILON * 100 }, // y: sqrt(2)
|
||||
{ 10, 1.4426950408889634, 27.713733786437790, PAL_EPSILON * 100 }, // y: log2(e)
|
||||
{ 10, 1.5707963267948966, 37.221710484165167, PAL_EPSILON * 100 }, // y: pi / 2
|
||||
{ 10, 2.3025850929940457, 200.71743249053009, PAL_EPSILON * 1000 }, // y: ln(10)
|
||||
{ 10, 2.7182818284590452, 522.73529967043665, PAL_EPSILON * 1000 }, // y: e
|
||||
{ 10, 3.1415926535897932, 1385.4557313670111, PAL_EPSILON * 10000 }, // y: pi
|
||||
{ 10, PAL_POSINF, PAL_POSINF, 0 },
|
||||
|
||||
{ PAL_POSINF, PAL_NEGINF, 0, PAL_EPSILON },
|
||||
{ PAL_POSINF, PAL_POSINF, PAL_POSINF, 0 },
|
||||
};
|
||||
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
pow_test1_validate(tests[i].x, tests[i].y, tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
pow_test1_validate_isnan(-10, -1.5707963267948966); // y: -(pi / 2)
|
||||
pow_test1_validate_isnan(-10, -0.78539816339744828); // y: -(pi / 4)
|
||||
pow_test1_validate_isnan(-10, 0.78539816339744828); // y: pi / 4
|
||||
pow_test1_validate_isnan(-10, 1.5707963267948966); // y: pi / 2
|
||||
|
||||
pow_test1_validate_isnan(-2.7182818284590452, -1.5707963267948966); // x: -(e) y: -(pi / 2)
|
||||
pow_test1_validate_isnan(-2.7182818284590452, -0.78539816339744828); // x: -(e) y: -(pi / 4)
|
||||
pow_test1_validate_isnan(-2.7182818284590452, 0.78539816339744828); // x: -(e) y: pi / 4
|
||||
pow_test1_validate_isnan(-2.7182818284590452, 1.5707963267948966); // x: -(e) y: pi / 2
|
||||
|
||||
pow_test1_validate_isnan(PAL_NEGINF, PAL_NAN);
|
||||
pow_test1_validate_isnan(PAL_NAN, PAL_NEGINF);
|
||||
|
||||
pow_test1_validate_isnan(PAL_POSINF, PAL_NAN);
|
||||
pow_test1_validate_isnan(PAL_NAN, PAL_POSINF);
|
||||
|
||||
pow_test1_validate_isnan(PAL_NAN, PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,228 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=====================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Tests that atan2f returns correct values for a subset of values.
|
||||
** Tests with positive and negative values of x and y to ensure
|
||||
** atan2f is returning results from the correct quadrant.
|
||||
**
|
||||
**===================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrtf(-1.0f)
|
||||
#define PAL_POSINF -logf(0.0f)
|
||||
#define PAL_NEGINF logf(0.0f)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float x; /* first component of the value to test the function with */
|
||||
float y; /* second component of the value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* powf_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl powf_test1_validate(float x, float y, float expected, float variance)
|
||||
{
|
||||
float result = powf(x, y);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("powf(%g, %g) returned %10.9g when it should have returned %10.9g",
|
||||
x, y, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* powf_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl powf_test1_validate_isnan(float x, float y)
|
||||
{
|
||||
float result = powf(x, y);
|
||||
|
||||
if (!_isnanf(result))
|
||||
{
|
||||
Fail("powf(%g, %g) returned %10.9g when it should have returned %10.9g",
|
||||
x, y, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_powf_test1_paltest_powf_test1, "c_runtime/powf/test1/paltest_powf_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* x y expected variance */
|
||||
{ PAL_NEGINF, PAL_NEGINF, 0, PAL_EPSILON },
|
||||
{ PAL_NEGINF, PAL_POSINF, PAL_POSINF, 0 },
|
||||
|
||||
{ -10, PAL_NEGINF, 0, PAL_EPSILON },
|
||||
{ -10, -1, -0.1f, PAL_EPSILON },
|
||||
{ -10, 0, 1, PAL_EPSILON * 10 },
|
||||
{ -10, 1, -10, PAL_EPSILON * 100 },
|
||||
{ -10, PAL_POSINF, PAL_POSINF, 0 },
|
||||
|
||||
{ -2.71828183f, PAL_NEGINF, 0, PAL_EPSILON }, // x: -(e)
|
||||
{ -2.71828183f, -1, -0.367879441f, PAL_EPSILON }, // x: -(e)
|
||||
{ -2.71828183f, 0, 1, PAL_EPSILON * 10 }, // x: -(e)
|
||||
{ -2.71828183f, 1, -2.71828183f, PAL_EPSILON * 10 }, // x: -(e) expected: e
|
||||
{ -2.71828183f, PAL_POSINF, PAL_POSINF, 0 }, // x: -(e)
|
||||
|
||||
{ -1.0, PAL_NEGINF, 1.0, PAL_EPSILON * 10 },
|
||||
{ -1.0, PAL_POSINF, 1.0, PAL_EPSILON * 10 },
|
||||
|
||||
{ -0.0, PAL_NEGINF, PAL_POSINF, 0 },
|
||||
{ -0.0, -1, PAL_NEGINF, 0 },
|
||||
{ -0.0f, -0.0f, 1, PAL_EPSILON * 10 },
|
||||
{ -0.0f, 0, 1, PAL_EPSILON * 10 },
|
||||
{ -0.0, 1, -0.0, PAL_EPSILON },
|
||||
{ -0.0, PAL_POSINF, 0, PAL_EPSILON },
|
||||
|
||||
{ PAL_NAN, -0.0, 1.0, PAL_EPSILON * 10 },
|
||||
{ PAL_NAN, 0, 1.0, PAL_EPSILON * 10 },
|
||||
|
||||
{ 0.0, PAL_NEGINF, PAL_POSINF, 0 },
|
||||
{ 0.0, -1, PAL_POSINF, 0 },
|
||||
{ 0, -0.0f, 1, PAL_EPSILON * 10 },
|
||||
{ 0, 0, 1, PAL_EPSILON * 10 },
|
||||
{ 0.0, 1, 0, PAL_EPSILON },
|
||||
{ 0.0, PAL_POSINF, 0, PAL_EPSILON },
|
||||
|
||||
{ 1, PAL_NEGINF, 1, PAL_EPSILON * 10 },
|
||||
{ 1, PAL_POSINF, 1, PAL_EPSILON * 10 },
|
||||
|
||||
{ 2.71828183f, PAL_NEGINF, 0, PAL_EPSILON },
|
||||
{ 2.71828183f, -3.14159265f, 0.0432139183f, PAL_EPSILON / 10 }, // x: e y: -(pi)
|
||||
{ 2.71828183f, -2.71828183f, 0.0659880358f, PAL_EPSILON / 10 }, // x: e y: -(e)
|
||||
{ 2.71828183f, -2.30258509f, 0.1f, PAL_EPSILON }, // x: e y: -(ln(10))
|
||||
{ 2.71828183f, -1.57079633f, 0.207879576f, PAL_EPSILON }, // x: e y: -(pi / 2)
|
||||
{ 2.71828183f, -1.44269504f, 0.236290088f, PAL_EPSILON }, // x: e y: -(logf2(e))
|
||||
{ 2.71828183f, -1.41421356f, 0.243116734f, PAL_EPSILON }, // x: e y: -(sqrtf(2))
|
||||
{ 2.71828183f, -1.12837917f, 0.323557264f, PAL_EPSILON }, // x: e y: -(2 / sqrtf(pi))
|
||||
{ 2.71828183f, -1, 0.367879441f, PAL_EPSILON }, // x: e y: -(1)
|
||||
{ 2.71828183f, -0.785398163f, 0.455938128f, PAL_EPSILON }, // x: e y: -(pi / 4)
|
||||
{ 2.71828183f, -0.707106781f, 0.493068691f, PAL_EPSILON }, // x: e y: -(1 / sqrtf(2))
|
||||
{ 2.71828183f, -0.693147181f, 0.5f, PAL_EPSILON }, // x: e y: -(ln(2))
|
||||
{ 2.71828183f, -0.636619772f, 0.529077808f, PAL_EPSILON }, // x: e y: -(2 / pi)
|
||||
{ 2.71828183f, -0.434294482f, 0.647721485f, PAL_EPSILON }, // x: e y: -(log10f(e))
|
||||
{ 2.71828183f, -0.318309886f, 0.727377349f, PAL_EPSILON }, // x: e y: -(1 / pi)
|
||||
{ 2.71828183f, 0, 1, PAL_EPSILON * 10 }, // x: e
|
||||
{ 2.71828183f, 0.318309886f, 1.37480223f, PAL_EPSILON * 10 }, // x: e y: 1 / pi
|
||||
{ 2.71828183f, 0.434294482f, 1.54387344f, PAL_EPSILON * 10 }, // x: e y: log10f(e)
|
||||
{ 2.71828183f, 0.636619772f, 1.89008116f, PAL_EPSILON * 10 }, // x: e y: 2 / pi
|
||||
{ 2.71828183f, 0.693147181f, 2, PAL_EPSILON * 10 }, // x: e y: ln(2)
|
||||
{ 2.71828183f, 0.707106781f, 2.02811498f, PAL_EPSILON * 10 }, // x: e y: 1 / sqrtf(2)
|
||||
{ 2.71828183f, 0.785398163f, 2.19328005f, PAL_EPSILON * 10 }, // x: e y: pi / 4
|
||||
{ 2.71828183f, 1, 2.71828183f, PAL_EPSILON * 10 }, // x: e expected: e
|
||||
{ 2.71828183f, 1.12837917f, 3.09064302f, PAL_EPSILON * 10 }, // x: e y: 2 / sqrtf(pi)
|
||||
{ 2.71828183f, 1.41421356f, 4.11325038f, PAL_EPSILON * 10 }, // x: e y: sqrtf(2)
|
||||
{ 2.71828183f, 1.44269504f, 4.23208611f, PAL_EPSILON * 10 }, // x: e y: logf2(e)
|
||||
{ 2.71828183f, 1.57079633f, 4.81047738f, PAL_EPSILON * 10 }, // x: e y: pi / 2
|
||||
{ 2.71828183f, 2.30258509f, 10, PAL_EPSILON * 100 }, // x: e y: ln(10)
|
||||
{ 2.71828183f, 2.71828183f, 15.1542622f, PAL_EPSILON * 100 }, // x: e y: e
|
||||
{ 2.71828183f, 3.14159265f, 23.1406926f, PAL_EPSILON * 100 }, // x: e y: pi
|
||||
{ 2.71828183f, PAL_POSINF, PAL_POSINF, 0 }, // x: e
|
||||
|
||||
{ 10, PAL_NEGINF, 0, 0 },
|
||||
{ 10, -3.14159265f, 0.000721784159f, PAL_EPSILON / 1000 }, // y: -(pi)
|
||||
{ 10, -2.71828183f, 0.00191301410f, PAL_EPSILON / 100 }, // y: -(e)
|
||||
{ 10, -2.30258509f, 0.00498212830f, PAL_EPSILON / 100 }, // y: -(ln(10))
|
||||
{ 10, -1.57079633f, 0.0268660410f, PAL_EPSILON / 10 }, // y: -(pi / 2)
|
||||
{ 10, -1.44269504f, 0.0360831928f, PAL_EPSILON / 10 }, // y: -(logf2(e))
|
||||
{ 10, -1.41421356f, 0.0385288847f, PAL_EPSILON / 10 }, // y: -(sqrtf(2))
|
||||
{ 10, -1.12837917f, 0.0744082059f, PAL_EPSILON / 10 }, // y: -(2 / sqrtf(pi))
|
||||
{ 10, -1, 0.1f, PAL_EPSILON }, // y: -(1)
|
||||
{ 10, -0.785398163f, 0.163908636f, PAL_EPSILON }, // y: -(pi / 4)
|
||||
{ 10, -0.707106781f, 0.196287760f, PAL_EPSILON }, // y: -(1 / sqrtf(2))
|
||||
{ 10, -0.693147181f, 0.202699566f, PAL_EPSILON }, // y: -(ln(2))
|
||||
{ 10, -0.636619772f, 0.230876765f, PAL_EPSILON }, // y: -(2 / pi)
|
||||
{ 10, -0.434294482f, 0.367879441f, PAL_EPSILON }, // y: -(log10f(e))
|
||||
{ 10, -0.318309886f, 0.480496373f, PAL_EPSILON }, // y: -(1 / pi)
|
||||
{ 10, 0, 1, PAL_EPSILON * 10 },
|
||||
{ 10, 0.318309886f, 2.08118116f, PAL_EPSILON * 10 }, // y: 1 / pi
|
||||
{ 10, 0.434294482f, 2.71828183f, PAL_EPSILON * 10 }, // y: log10f(e) expected: e
|
||||
{ 10, 0.636619772f, 4.33131503f, PAL_EPSILON * 10 }, // y: 2 / pi
|
||||
{ 10, 0.693147181f, 4.93340967f, PAL_EPSILON * 10 }, // y: ln(2)
|
||||
{ 10, 0.707106781f, 5.09456117f, PAL_EPSILON * 10 }, // y: 1 / sqrtf(2)
|
||||
{ 10, 0.785398163f, 6.10095980f, PAL_EPSILON * 10 }, // y: pi / 4
|
||||
{ 10, 1, 10, PAL_EPSILON * 100 },
|
||||
{ 10, 1.12837917f, 13.4393779f, PAL_EPSILON * 100 }, // y: 2 / sqrtf(pi)
|
||||
{ 10, 1.41421356f, 25.9545535f, PAL_EPSILON * 100 }, // y: sqrtf(2)
|
||||
{ 10, 1.44269504f, 27.7137338f, PAL_EPSILON * 100 }, // y: logf2(e)
|
||||
{ 10, 1.57079633f, 37.2217105f, PAL_EPSILON * 100 }, // y: pi / 2
|
||||
{ 10, 2.30258509f, 200.717432f, PAL_EPSILON * 1000 }, // y: ln(10)
|
||||
{ 10, 2.71828183f, 522.735300f, PAL_EPSILON * 1000 }, // y: e
|
||||
{ 10, 3.14159265f, 1385.45573f, PAL_EPSILON * 10000 }, // y: pi
|
||||
{ 10, PAL_POSINF, PAL_POSINF, 0 },
|
||||
|
||||
{ PAL_POSINF, PAL_NEGINF, 0, PAL_EPSILON },
|
||||
{ PAL_POSINF, PAL_POSINF, PAL_POSINF, 0 },
|
||||
};
|
||||
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
powf_test1_validate(tests[i].x, tests[i].y, tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
powf_test1_validate_isnan(-10, -1.57079633f); // y: -(pi / 2)
|
||||
powf_test1_validate_isnan(-10, -0.785398163f); // y: -(pi / 4)
|
||||
powf_test1_validate_isnan(-10, 0.785398163f); // y: pi / 4
|
||||
powf_test1_validate_isnan(-10, 1.57079633f); // y: pi / 2
|
||||
|
||||
powf_test1_validate_isnan(-2.71828183f, -1.57079633f); // x: -(e) y: -(pi / 2)
|
||||
powf_test1_validate_isnan(-2.71828183f, -0.785398163f); // x: -(e) y: -(pi / 4)
|
||||
powf_test1_validate_isnan(-2.71828183f, 0.785398163f); // x: -(e) y: pi / 4
|
||||
powf_test1_validate_isnan(-2.71828183f, 1.57079633f); // x: -(e) y: pi / 2
|
||||
|
||||
powf_test1_validate_isnan(PAL_NEGINF, PAL_NAN);
|
||||
powf_test1_validate_isnan(PAL_NAN, PAL_NEGINF);
|
||||
|
||||
powf_test1_validate_isnan(PAL_POSINF, PAL_NAN);
|
||||
powf_test1_validate_isnan(PAL_NAN, PAL_POSINF);
|
||||
|
||||
powf_test1_validate_isnan(PAL_NAN, PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,130 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that sin return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double value; /* value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* sin_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl sin_test1_validate(double value, double expected, double variance)
|
||||
{
|
||||
double result = sin(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("sin(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sin_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl sin_test1_validate_isnan(double value)
|
||||
{
|
||||
double result = sin(value);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("sin(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_sin_test1_paltest_sin_test1, "c_runtime/sin/test1/paltest_sin_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, 0, PAL_EPSILON },
|
||||
{ 0.31830988618379067, 0.31296179620778659, PAL_EPSILON }, // value: 1 / pi
|
||||
{ 0.43429448190325183, 0.42077048331375735, PAL_EPSILON }, // value: log10(e)
|
||||
{ 0.63661977236758134, 0.59448076852482208, PAL_EPSILON }, // value: 2 / pi
|
||||
{ 0.69314718055994531, 0.63896127631363480, PAL_EPSILON }, // value: ln(2)
|
||||
{ 0.70710678118654752, 0.64963693908006244, PAL_EPSILON }, // value: 1 / sqrt(2)
|
||||
{ 0.78539816339744831, 0.70710678118654752, PAL_EPSILON }, // value: pi / 4, expected: 1 / sqrt(2)
|
||||
{ 1, 0.84147098480789651, PAL_EPSILON },
|
||||
{ 1.1283791670955126, 0.90371945743584630, PAL_EPSILON }, // value: 2 / sqrt(pi)
|
||||
{ 1.4142135623730950, 0.98776594599273553, PAL_EPSILON }, // value: sqrt(2)
|
||||
{ 1.4426950408889634, 0.99180624439366372, PAL_EPSILON }, // value: log2(e)
|
||||
{ 1.5707963267948966, 1, PAL_EPSILON * 10 }, // value: pi / 2
|
||||
{ 2.3025850929940457, 0.74398033695749319, PAL_EPSILON }, // value: ln(10)
|
||||
{ 2.7182818284590452, 0.41078129050290870, PAL_EPSILON }, // value: e
|
||||
{ 3.1415926535897932, 0, PAL_EPSILON }, // value: pi
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
sin_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
sin_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
sin_test1_validate_isnan(PAL_NEGINF);
|
||||
sin_test1_validate_isnan(PAL_NAN);
|
||||
sin_test1_validate_isnan(PAL_POSINF);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,135 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that sincos return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double value; /* value to test the function with */
|
||||
double expected_sin; /* expected sin result */
|
||||
double expected_cos; /* expected cos result */
|
||||
double variance_sin; /* maximum delta between the expected and actual sin result */
|
||||
double variance_cos; /* maximum delta between the expected and actual cos result */
|
||||
};
|
||||
|
||||
/**
|
||||
* sincos_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl sincos_test1_validate(double value, double expected_sin, double expected_cos, double variance_sin, double variance_cos)
|
||||
{
|
||||
double result_sin, result_cos;
|
||||
sincos(value, &result_sin, &result_cos);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta_sin = fabs(result_sin - expected_sin);
|
||||
double delta_cos = fabs(result_cos - expected_cos);
|
||||
|
||||
if ((delta_sin > variance_sin) || (delta_cos > variance_cos))
|
||||
{
|
||||
Fail("sincos(%g) returned (%20.17g, %20.17g) when it should have returned (%20.17g, %20.17g)",
|
||||
value, result_sin, result_cos, expected_sin, expected_cos);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sincos_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl sincos_test1_validate_isnan(double value)
|
||||
{
|
||||
double result_sin, result_cos;
|
||||
sincos(value, &result_sin, &result_cos);
|
||||
|
||||
if (!_isnan(result_sin) || !_isnan(result_cos))
|
||||
{
|
||||
Fail("sincos(%g) returned (%20.17g, %20.17g) when it should have returned (%20.17g, %20.17g)",
|
||||
value, result_sin, result_cos, PAL_NAN, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_sincos_test1_paltest_sincos_test1, "c_runtime/sincos/test1/paltest_sincos_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected_sin expected_cos variance_sin variance_cos */
|
||||
{ 0, 0, 1, PAL_EPSILON, PAL_EPSILON * 10 },
|
||||
{ 0.31830988618379067, 0.31296179620778659, 0.94976571538163866, PAL_EPSILON, PAL_EPSILON }, // value: 1 / pi
|
||||
{ 0.43429448190325183, 0.42077048331375735, 0.90716712923909839, PAL_EPSILON, PAL_EPSILON }, // value: log10(e)
|
||||
{ 0.63661977236758134, 0.59448076852482208, 0.80410982822879171, PAL_EPSILON, PAL_EPSILON }, // value: 2 / pi
|
||||
{ 0.69314718055994531, 0.63896127631363480, 0.76923890136397213, PAL_EPSILON, PAL_EPSILON }, // value: ln(2)
|
||||
{ 0.70710678118654752, 0.64963693908006244, 0.76024459707563015, PAL_EPSILON, PAL_EPSILON }, // value: 1 / sqrt(2)
|
||||
{ 0.78539816339744831, 0.70710678118654752, 0.70710678118654752, PAL_EPSILON, PAL_EPSILON }, // value: pi / 4, expected_sin: 1 / sqrtf(2), expected_cos: 1
|
||||
{ 1, 0.84147098480789651, 0.54030230586813972, PAL_EPSILON, PAL_EPSILON },
|
||||
{ 1.1283791670955126, 0.90371945743584630, 0.42812514788535792, PAL_EPSILON, PAL_EPSILON }, // value: 2 / sqrt(pi)
|
||||
{ 1.4142135623730950, 0.98776594599273553, 0.15594369476537447, PAL_EPSILON, PAL_EPSILON }, // value: sqrt(2)
|
||||
{ 1.4426950408889634, 0.99180624439366372, 0.12775121753523991, PAL_EPSILON, PAL_EPSILON }, // value: log2(e)
|
||||
{ 1.5707963267948966, 1, 0, PAL_EPSILON * 10, PAL_EPSILON }, // value: pi / 2
|
||||
{ 2.3025850929940457, 0.74398033695749319, -0.66820151019031295, PAL_EPSILON, PAL_EPSILON }, // value: ln(10)
|
||||
{ 2.7182818284590452, 0.41078129050290870, -0.91173391478696510, PAL_EPSILON, PAL_EPSILON }, // value: e
|
||||
{ 3.1415926535897932, 0, -1, PAL_EPSILON, PAL_EPSILON * 10 }, // value: pi
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
sincos_test1_validate( tests[i].value, tests[i].expected_sin, tests[i].expected_cos, tests[i].variance_sin, tests[i].variance_cos);
|
||||
sincos_test1_validate(-tests[i].value, -tests[i].expected_sin, tests[i].expected_cos, tests[i].variance_sin, tests[i].variance_cos);
|
||||
}
|
||||
|
||||
sincos_test1_validate_isnan(PAL_NEGINF);
|
||||
sincos_test1_validate_isnan(PAL_NAN);
|
||||
sincos_test1_validate_isnan(PAL_POSINF);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,134 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that sincosf return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrtf(-1.0f)
|
||||
#define PAL_POSINF -logf(0.0f)
|
||||
#define PAL_NEGINF logf(0.0f)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float value; /* value to test the function with */
|
||||
float expected_sin; /* expected sin result */
|
||||
float expected_cos; /* expected cos result */
|
||||
float variance_sin; /* maximum delta between the expected and actual sin result */
|
||||
float variance_cos; /* maximum delta between the expected and actual cos result */
|
||||
};
|
||||
|
||||
/**
|
||||
* sincosf_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl sincosf_test1_validate(float value, float expected_sin, float expected_cos, float variance_sin, float variance_cos)
|
||||
{
|
||||
float result_sin, result_cos;
|
||||
sincosf(value, &result_sin, &result_cos);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta_sin = fabsf(result_sin - expected_sin);
|
||||
float delta_cos = fabsf(result_cos - expected_cos);
|
||||
|
||||
if ((delta_sin > variance_sin) || (delta_cos > variance_cos))
|
||||
{
|
||||
Fail("sincosf(%g) returned (%10.9g, %10.9g) when it should have returned (%10.9g, %10.9g)",
|
||||
value, result_sin, result_cos, expected_sin, expected_cos);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sincosf_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl sincosf_test1_validate_isnan(float value)
|
||||
{
|
||||
float result_sin, result_cos;
|
||||
sincosf(value, &result_sin, &result_cos);
|
||||
|
||||
if (!_isnanf(result_sin) || !_isnanf(result_cos))
|
||||
{
|
||||
Fail("sincosf(%g) returned (%10.9g, %10.9g) when it should have returned (%10.9g, %10.9g)",
|
||||
value, result_sin, result_cos, PAL_NAN, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_sincosf_test1_paltest_sincosf_test1, "c_runtime/sincosf/test1/paltest_sincosf_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected_sin expected_cos variance_sin variance_cos */
|
||||
{ 0, 0, 1, PAL_EPSILON, PAL_EPSILON * 10 },
|
||||
{ 0.318309886f, 0.312961796f, 0.949765715f, PAL_EPSILON, PAL_EPSILON }, // value: 1 / pi
|
||||
{ 0.434294482f, 0.420770483f, 0.907167129f, PAL_EPSILON, PAL_EPSILON }, // value: log10f(e)
|
||||
{ 0.636619772f, 0.594480769f, 0.804109828f, PAL_EPSILON, PAL_EPSILON }, // value: 2 / pi
|
||||
{ 0.693147181f, 0.638961276f, 0.769238901f, PAL_EPSILON, PAL_EPSILON }, // value: ln(2)
|
||||
{ 0.707106781f, 0.649636939f, 0.760244597f, PAL_EPSILON, PAL_EPSILON }, // value: 1 / sqrtf(2)
|
||||
{ 0.785398163f, 0.707106781f, 0.707106781f, PAL_EPSILON, PAL_EPSILON }, // value: pi / 4, expected_sin: 1 / sqrtf(2), expected_cos: 1
|
||||
{ 1, 0.841470985f, 0.540302306f, PAL_EPSILON, PAL_EPSILON },
|
||||
{ 1.12837917f, 0.903719457f, 0.428125148f, PAL_EPSILON, PAL_EPSILON }, // value: 2 / sqrtf(pi)
|
||||
{ 1.41421356f, 0.987765946f, 0.155943695f, PAL_EPSILON, PAL_EPSILON }, // value: sqrtf(2)
|
||||
{ 1.44269504f, 0.991806244f, 0.127751218f, PAL_EPSILON, PAL_EPSILON }, // value: logf2(e)
|
||||
{ 1.57079633f, 1, 0, PAL_EPSILON * 10, PAL_EPSILON }, // value: pi / 2
|
||||
{ 2.30258509f, 0.743980337f, -0.668201510f, PAL_EPSILON, PAL_EPSILON }, // value: ln(10)
|
||||
{ 2.71828183f, 0.410781291f, -0.911733918f, PAL_EPSILON, PAL_EPSILON }, // value: e
|
||||
{ 3.14159265f, 0, -1, PAL_EPSILON, PAL_EPSILON * 10 }, // value: pi
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
sincosf_test1_validate( tests[i].value, tests[i].expected_sin, tests[i].expected_cos, tests[i].variance_sin, tests[i].variance_cos);
|
||||
sincosf_test1_validate(-tests[i].value, -tests[i].expected_sin, tests[i].expected_cos, tests[i].variance_sin, tests[i].variance_cos);
|
||||
}
|
||||
|
||||
sincosf_test1_validate_isnan(PAL_NEGINF);
|
||||
sincosf_test1_validate_isnan(PAL_NAN);
|
||||
sincosf_test1_validate_isnan(PAL_POSINF);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that sinf return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrtf(-1.0f)
|
||||
#define PAL_POSINF -logf(0.0f)
|
||||
#define PAL_NEGINF logf(0.0f)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float value; /* value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* sinf_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl sinf_test1_validate(float value, float expected, float variance)
|
||||
{
|
||||
float result = sinf(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("sinf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sinf_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl sinf_test1_validate_isnan(float value)
|
||||
{
|
||||
float result = sinf(value);
|
||||
|
||||
if (!_isnanf(result))
|
||||
{
|
||||
Fail("sinf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_sinf_test1_paltest_sinf_test1, "c_runtime/sinf/test1/paltest_sinf_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, 0, PAL_EPSILON },
|
||||
{ 0.318309886f, 0.312961796f, PAL_EPSILON }, // value: 1 / pi
|
||||
{ 0.434294482f, 0.420770483f, PAL_EPSILON }, // value: log10f(e)
|
||||
{ 0.636619772f, 0.594480769f, PAL_EPSILON }, // value: 2 / pi
|
||||
{ 0.693147181f, 0.638961276f, PAL_EPSILON }, // value: ln(2)
|
||||
{ 0.707106781f, 0.649636939f, PAL_EPSILON }, // value: 1 / sqrtf(2)
|
||||
{ 0.785398163f, 0.707106781f, PAL_EPSILON }, // value: pi / 4, expected: 1 / sqrtf(2)
|
||||
{ 1, 0.841470985f, PAL_EPSILON },
|
||||
{ 1.12837917f, 0.903719457f, PAL_EPSILON }, // value: 2 / sqrtf(pi)
|
||||
{ 1.41421356f, 0.987765946f, PAL_EPSILON }, // value: sqrtf(2)
|
||||
{ 1.44269504f, 0.991806244f, PAL_EPSILON }, // value: logf2(e)
|
||||
{ 1.57079633f, 1, PAL_EPSILON * 10 }, // value: pi / 2
|
||||
{ 2.30258509f, 0.743980337f, PAL_EPSILON }, // value: ln(10)
|
||||
{ 2.71828183f, 0.410781291f, PAL_EPSILON }, // value: e
|
||||
{ 3.14159265f, 0, PAL_EPSILON }, // value: pi
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
sinf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
sinf_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
sinf_test1_validate_isnan(PAL_NEGINF);
|
||||
sinf_test1_validate_isnan(PAL_NAN);
|
||||
sinf_test1_validate_isnan(PAL_POSINF);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that sinh return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double value; /* value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* sinh_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl sinh_test1_validate(double value, double expected, double variance)
|
||||
{
|
||||
double result = sinh(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("sinh(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sinh_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl sinh_test1_validate_isnan(double value)
|
||||
{
|
||||
double result = sinh(value);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("sinh(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_sinh_test1_paltest_sinh_test1, "c_runtime/sinh/test1/paltest_sinh_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, 0, PAL_EPSILON },
|
||||
{ 0.31830988618379067, 0.32371243907207108, PAL_EPSILON }, // value: 1 / pi
|
||||
{ 0.43429448190325183, 0.44807597941469025, PAL_EPSILON }, // value: log10(e)
|
||||
{ 0.63661977236758134, 0.68050167815224332, PAL_EPSILON }, // value: 2 / pi
|
||||
{ 0.69314718055994531, 0.75, PAL_EPSILON }, // value: ln(2)
|
||||
{ 0.70710678118654752, 0.76752314512611633, PAL_EPSILON }, // value: 1 / sqrt(2)
|
||||
{ 0.78539816339744831, 0.86867096148600961, PAL_EPSILON }, // value: pi / 4
|
||||
{ 1, 1.1752011936438015, PAL_EPSILON * 10 },
|
||||
{ 1.1283791670955126, 1.3835428792038633, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi)
|
||||
{ 1.4142135623730950, 1.9350668221743567, PAL_EPSILON * 10 }, // value: sqrt(2)
|
||||
{ 1.4426950408889634, 1.9978980091062796, PAL_EPSILON * 10 }, // value: log2(e)
|
||||
{ 1.5707963267948966, 2.3012989023072949, PAL_EPSILON * 10 }, // value: pi / 2
|
||||
{ 2.3025850929940457, 4.95, PAL_EPSILON * 10 }, // value: ln(10)
|
||||
{ 2.7182818284590452, 7.5441371028169758, PAL_EPSILON * 10 }, // value: e
|
||||
{ 3.1415926535897932, 11.548739357257748, PAL_EPSILON * 100 }, // value: pi
|
||||
{ PAL_POSINF, PAL_POSINF, 0 },
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
sinh_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
sinh_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
sinh_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,128 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that sinhf return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrtf(-1.0f)
|
||||
#define PAL_POSINF -logf(0.0f)
|
||||
#define PAL_NEGINF logf(0.0f)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float value; /* value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* sinhf_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl sinhf_test1_validate(float value, float expected, float variance)
|
||||
{
|
||||
float result = sinhf(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("sinhf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sinhf_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl sinhf_test1_validate_isnan(float value)
|
||||
{
|
||||
float result = sinhf(value);
|
||||
|
||||
if (!_isnanf(result))
|
||||
{
|
||||
Fail("sinhf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_sinhf_test1_paltest_sinhf_test1, "c_runtime/sinhf/test1/paltest_sinhf_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, 0, PAL_EPSILON },
|
||||
{ 0.318309886f, 0.323712439f, PAL_EPSILON }, // value: 1 / pi
|
||||
{ 0.434294482f, 0.448075979f, PAL_EPSILON }, // value: log10f(e)
|
||||
{ 0.636619772f, 0.680501678f, PAL_EPSILON }, // value: 2 / pi
|
||||
{ 0.693147181f, 0.75, PAL_EPSILON }, // value: ln(2)
|
||||
{ 0.707106781f, 0.767523145f, PAL_EPSILON }, // value: 1 / sqrtf(2)
|
||||
{ 0.785398163f, 0.868670961f, PAL_EPSILON }, // value: pi / 4
|
||||
{ 1, 1.17520119f, PAL_EPSILON * 10 },
|
||||
{ 1.12837917f, 1.38354288f, PAL_EPSILON * 10 }, // value: 2 / sqrtf(pi)
|
||||
{ 1.41421356f, 1.93506682f, PAL_EPSILON * 10 }, // value: sqrtf(2)
|
||||
{ 1.44269504f, 1.99789801f, PAL_EPSILON * 10 }, // value: logf2(e)
|
||||
{ 1.57079633f, 2.30129890f, PAL_EPSILON * 10 }, // value: pi / 2
|
||||
{ 2.30258509f, 4.95f, PAL_EPSILON * 10 }, // value: ln(10)
|
||||
{ 2.71828183f, 7.54413710f, PAL_EPSILON * 10 }, // value: e
|
||||
{ 3.14159265f, 11.5487394f, PAL_EPSILON * 100 }, // value: pi
|
||||
{ PAL_POSINF, PAL_POSINF, 0 },
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
sinhf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
sinhf_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
sinhf_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,122 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=====================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Call the sqrt function on a positive value, a positive value
|
||||
** with a decimal and on the maximum possible double value.
|
||||
**
|
||||
**
|
||||
**===================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double value; /* value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* sqrt_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl sqrt_test1_validate(double value, double expected, double variance)
|
||||
{
|
||||
double result = sqrt(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("sqrt(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sqrt_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl sqrt_test1_validate_isnan(double value)
|
||||
{
|
||||
double result = sqrt(value);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("sqrt(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
PALTEST(c_runtime_sqrt_test1_paltest_sqrt_test1, "c_runtime/sqrt/test1/paltest_sqrt_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0.31830988618379067, 0.56418958354775629, PAL_EPSILON }, // value: 1 / pi
|
||||
{ 0.43429448190325183, 0.65901022898226081, PAL_EPSILON }, // value: log10(e)
|
||||
{ 0.63661977236758134, 0.79788456080286536, PAL_EPSILON }, // value: 2 / pi
|
||||
{ 0.69314718055994531, 0.83255461115769776, PAL_EPSILON }, // value: ln(2)
|
||||
{ 0.70710678118654752, 0.84089641525371454, PAL_EPSILON }, // value: 1 / sqrt(2)
|
||||
{ 0.78539816339744831, 0.88622692545275801, PAL_EPSILON }, // value: pi / 4
|
||||
{ 1, 1, PAL_EPSILON * 10 },
|
||||
{ 1.1283791670955126, 1.0622519320271969, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi)
|
||||
{ 1.4142135623730950, 1.1892071150027211, PAL_EPSILON * 10 }, // value: sqrt(2)
|
||||
{ 1.4426950408889634, 1.2011224087864498, PAL_EPSILON * 10 }, // value: log2(e)
|
||||
{ 1.5707963267948966, 1.2533141373155003, PAL_EPSILON * 10 }, // value: pi / 2
|
||||
{ 2.3025850929940457, 1.5174271293851464, PAL_EPSILON * 10 }, // value: ln(10)
|
||||
{ 2.7182818284590452, 1.6487212707001281, PAL_EPSILON * 10 }, // value: e
|
||||
{ 3.1415926535897932, 1.7724538509055160, PAL_EPSILON * 10 }, // value: pi
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
sqrt_test1_validate(-0.0, -0.0, PAL_EPSILON);
|
||||
sqrt_test1_validate( 0.0, 0.0, PAL_EPSILON);
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
sqrt_test1_validate(tests[i].value, tests[i].expected, tests[i].variance);
|
||||
sqrt_test1_validate_isnan(-tests[i].value);
|
||||
}
|
||||
|
||||
sqrt_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,121 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=====================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Call the sqrtf function on a positive value, a positive value
|
||||
** with a decimal and on the maximum possible float value.
|
||||
**
|
||||
**
|
||||
**===================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrtf(-1.0f)
|
||||
#define PAL_POSINF -logf(0.0f)
|
||||
#define PAL_NEGINF logf(0.0f)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float value; /* value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* sqrtf_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl sqrtf_test1_validate(float value, float expected, float variance)
|
||||
{
|
||||
float result = sqrtf(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("sqrtf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sqrtf_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl sqrtf_test1_validate_isnan(float value)
|
||||
{
|
||||
float result = sqrtf(value);
|
||||
|
||||
if (!_isnanf(result))
|
||||
{
|
||||
Fail("sqrtf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
PALTEST(c_runtime_sqrtf_test1_paltest_sqrtf_test1, "c_runtime/sqrtf/test1/paltest_sqrtf_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0.318309886f, 0.564189584f, PAL_EPSILON }, // value: 1 / pi
|
||||
{ 0.434294482f, 0.659010229f, PAL_EPSILON }, // value: log10f(e)
|
||||
{ 0.636619772f, 0.797884561f, PAL_EPSILON }, // value: 2 / pi
|
||||
{ 0.693147181f, 0.832554611f, PAL_EPSILON }, // value: ln(2)
|
||||
{ 0.707106781f, 0.840896415f, PAL_EPSILON }, // value: 1 / sqrtf(2)
|
||||
{ 0.785398163f, 0.886226925f, PAL_EPSILON }, // value: pi / 4
|
||||
{ 1, 1, PAL_EPSILON * 10 },
|
||||
{ 1.12837917f, 1.06225193f, PAL_EPSILON * 10 }, // value: 2 / sqrtf(pi)
|
||||
{ 1.41421356f, 1.18920712f, PAL_EPSILON * 10 }, // value: sqrtf(2)
|
||||
{ 1.44269504f, 1.20112241f, PAL_EPSILON * 10 }, // value: logf2(e)
|
||||
{ 1.57079633f, 1.25331414f, PAL_EPSILON * 10 }, // value: pi / 2
|
||||
{ 2.30258509f, 1.51742713f, PAL_EPSILON * 10 }, // value: ln(10)
|
||||
{ 2.71828183f, 1.64872127f, PAL_EPSILON * 10 }, // value: e
|
||||
{ 3.14159265f, 1.77245385F, PAL_EPSILON * 10 }, // value: pi
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
sqrtf_test1_validate(-0.0f, -0.0f, PAL_EPSILON);
|
||||
sqrtf_test1_validate( 0.0f, 0.0f, PAL_EPSILON);
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
sqrtf_test1_validate(tests[i].value, tests[i].expected, tests[i].variance);
|
||||
sqrtf_test1_validate_isnan(-tests[i].value);
|
||||
}
|
||||
|
||||
sqrtf_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,136 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that tan return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double value; /* value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* tan_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl tan_test1_validate(double value, double expected, double variance)
|
||||
{
|
||||
double result = tan(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("tan(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* tan_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl tan_test1_validate_isnan(double value)
|
||||
{
|
||||
double result = tan(value);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("tan(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_tan_test1_paltest_tan_test1, "c_runtime/tan/test1/paltest_tan_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, 0, PAL_EPSILON },
|
||||
{ 0.31830988618379067, 0.32951473309607836, PAL_EPSILON }, // value: 1 / pi
|
||||
{ 0.43429448190325183, 0.46382906716062964, PAL_EPSILON }, // value: log10(e)
|
||||
{ 0.63661977236758134, 0.73930295048660405, PAL_EPSILON }, // value: 2 / pi
|
||||
{ 0.69314718055994531, 0.83064087786078395, PAL_EPSILON }, // value: ln(2)
|
||||
{ 0.70710678118654752, 0.85451043200960189, PAL_EPSILON }, // value: 1 / sqrt(2)
|
||||
{ 0.78539816339744831, 1, PAL_EPSILON * 10 }, // value: pi / 4
|
||||
{ 1, 1.5574077246549022, PAL_EPSILON * 10 },
|
||||
{ 1.1283791670955126, 2.1108768356626451, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi)
|
||||
{ 1.4142135623730950, 6.3341191670421916, PAL_EPSILON * 10 }, // value: sqrt(2)
|
||||
{ 1.4426950408889634, 7.7635756709721848, PAL_EPSILON * 10 }, // value: log2(e)
|
||||
// SEE BELOW -- { 1.5707963267948966, PAL_POSINF, 0 }, // value: pi / 2
|
||||
{ 2.3025850929940457, -1.1134071468135374, PAL_EPSILON * 10 }, // value: ln(10)
|
||||
{ 2.7182818284590452, -0.45054953406980750, PAL_EPSILON }, // value: e
|
||||
{ 3.1415926535897932, 0, PAL_EPSILON }, // value: pi
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
tan_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
tan_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
// -- SPECIAL CASE --
|
||||
// Normally, tan(pi / 2) would return PAL_POSINF (atan2(PAL_POSINF) does return (pi / 2)).
|
||||
// However, it seems instead (on all supported systems), we get a different number entirely.
|
||||
tan_test1_validate( 1.5707963267948966, 16331239353195370.0, 0);
|
||||
tan_test1_validate(-1.5707963267948966, -16331239353195370.0, 0);
|
||||
|
||||
tan_test1_validate_isnan(PAL_NEGINF);
|
||||
tan_test1_validate_isnan(PAL_NAN);
|
||||
tan_test1_validate_isnan(PAL_POSINF);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,135 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that tanf return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrtf(-1.0f)
|
||||
#define PAL_POSINF -logf(0.0f)
|
||||
#define PAL_NEGINF logf(0.0f)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float value; /* value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* tanf_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl tanf_test1_validate(float value, float expected, float variance)
|
||||
{
|
||||
float result = tanf(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("tanf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* tanf_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl tanf_test1_validate_isnan(float value)
|
||||
{
|
||||
float result = tanf(value);
|
||||
|
||||
if (!_isnanf(result))
|
||||
{
|
||||
Fail("tanf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_tanf_test1_paltest_tanf_test1, "c_runtime/tanf/test1/paltest_tanf_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, 0, PAL_EPSILON },
|
||||
{ 0.318309886f, 0.329514733f, PAL_EPSILON }, // value: 1 / pi
|
||||
{ 0.434294482f, 0.463829067f, PAL_EPSILON }, // value: log10f(e)
|
||||
{ 0.636619772f, 0.739302950f, PAL_EPSILON }, // value: 2 / pi
|
||||
{ 0.693147181f, 0.830640878f, PAL_EPSILON }, // value: ln(2)
|
||||
{ 0.707106781f, 0.854510432f, PAL_EPSILON }, // value: 1 / sqrtf(2)
|
||||
{ 0.785398163f, 1, PAL_EPSILON * 10 }, // value: pi / 4
|
||||
{ 1, 1.55740772f, PAL_EPSILON * 10 },
|
||||
{ 1.12837917f, 2.11087684f, PAL_EPSILON * 10 }, // value: 2 / sqrtf(pi)
|
||||
{ 1.41421356f, 6.33411917f, PAL_EPSILON * 10 }, // value: sqrtf(2)
|
||||
{ 1.44269504f, 7.76357567f, PAL_EPSILON * 10 }, // value: logf2(e)
|
||||
// SEE BELOW -- { 1.57079633f, PAL_POSINF, 0 }, // value: pi / 2
|
||||
{ 2.30258509f, -1.11340715f, PAL_EPSILON * 10 }, // value: ln(10)
|
||||
{ 2.71828183f, -0.450549534f, PAL_EPSILON }, // value: e
|
||||
{ 3.14159265f, 0, PAL_EPSILON }, // value: pi
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
tanf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
tanf_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
// -- SPECIAL CASE --
|
||||
// Normally, tanf(pi / 2) would return PAL_POSINF (atan2f(PAL_POSINF) does return (pi / 2)).
|
||||
// However, it seems instead (on all supported systems), we get a different number entirely.
|
||||
tanf_test1_validate( 1.57079633f, -22877332.0, PAL_EPSILON * 100000000);
|
||||
tanf_test1_validate(-1.57079633f, 22877332.0, PAL_EPSILON * 100000000);
|
||||
|
||||
tanf_test1_validate_isnan(PAL_NEGINF);
|
||||
tanf_test1_validate_isnan(PAL_NAN);
|
||||
tanf_test1_validate_isnan(PAL_POSINF);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that tanh return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (15-17 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use
|
||||
// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx
|
||||
// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will
|
||||
// use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 8.8817841970012523e-16
|
||||
|
||||
#define PAL_NAN sqrt(-1.0)
|
||||
#define PAL_POSINF -log(0.0)
|
||||
#define PAL_NEGINF log(0.0)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
double value; /* value to test the function with */
|
||||
double expected; /* expected result */
|
||||
double variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* tanh_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl tanh_test1_validate(double value, double expected, double variance)
|
||||
{
|
||||
double result = tanh(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
double delta = fabs(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("tanh(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* tanh_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl tanh_test1_validate_isnan(double value)
|
||||
{
|
||||
double result = tanh(value);
|
||||
|
||||
if (!_isnan(result))
|
||||
{
|
||||
Fail("tanh(%g) returned %20.17g when it should have returned %20.17g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_tanh_test1_paltest_tanh_test1, "c_runtime/tanh/test1/paltest_tanh_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, 0, PAL_EPSILON },
|
||||
{ 0.31830988618379067, 0.30797791269089433, PAL_EPSILON }, // value: 1 / pi
|
||||
{ 0.43429448190325183, 0.40890401183401433, PAL_EPSILON }, // value: log10(e)
|
||||
{ 0.63661977236758134, 0.56259360033158334, PAL_EPSILON }, // value: 2 / pi
|
||||
{ 0.69314718055994531, 0.6, PAL_EPSILON }, // value: ln(2)
|
||||
{ 0.70710678118654752, 0.60885936501391381, PAL_EPSILON }, // value: 1 / sqrt(2)
|
||||
{ 0.78539816339744831, 0.65579420263267244, PAL_EPSILON }, // value: pi / 4
|
||||
{ 1, 0.76159415595576489, PAL_EPSILON },
|
||||
{ 1.1283791670955126, 0.81046380599898809, PAL_EPSILON }, // value: 2 / sqrt(pi)
|
||||
{ 1.4142135623730950, 0.88838556158566054, PAL_EPSILON }, // value: sqrt(2)
|
||||
{ 1.4426950408889634, 0.89423894585503855, PAL_EPSILON }, // value: log2(e)
|
||||
{ 1.5707963267948966, 0.91715233566727435, PAL_EPSILON }, // value: pi / 2
|
||||
{ 2.3025850929940457, 0.98019801980198020, PAL_EPSILON }, // value: ln(10)
|
||||
{ 2.7182818284590452, 0.99132891580059984, PAL_EPSILON }, // value: e
|
||||
{ 3.1415926535897932, 0.99627207622074994, PAL_EPSILON }, // value: pi
|
||||
{ PAL_POSINF, 1, PAL_EPSILON * 10 }
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
tanh_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
tanh_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
tanh_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,128 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
/*=============================================================================
|
||||
**
|
||||
** Source: test1.c
|
||||
**
|
||||
** Purpose: Test to ensure that tanhf return the correct values
|
||||
**
|
||||
** Dependencies: PAL_Initialize
|
||||
** PAL_Terminate
|
||||
** Fail
|
||||
** fabs
|
||||
**
|
||||
**===========================================================================*/
|
||||
|
||||
#include <palsuite.h>
|
||||
|
||||
// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
|
||||
// is slightly too accurate when writing tests meant to run against libm implementations
|
||||
// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
|
||||
//
|
||||
// The tests themselves will take PAL_EPSILON and adjust it according to the expected result
|
||||
// so that the delta used for comparison will compare the most significant digits and ignore
|
||||
// any digits that are outside the double precision range (6-9 digits).
|
||||
|
||||
// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON
|
||||
// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use
|
||||
// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10.
|
||||
#define PAL_EPSILON 4.76837158e-07
|
||||
|
||||
#define PAL_NAN sqrtf(-1.0f)
|
||||
#define PAL_POSINF -logf(0.0f)
|
||||
#define PAL_NEGINF logf(0.0f)
|
||||
|
||||
/**
|
||||
* Helper test structure
|
||||
*/
|
||||
struct test
|
||||
{
|
||||
float value; /* value to test the function with */
|
||||
float expected; /* expected result */
|
||||
float variance; /* maximum delta between the expected and actual result */
|
||||
};
|
||||
|
||||
/**
|
||||
* tanhf_test1_validate
|
||||
*
|
||||
* test validation function
|
||||
*/
|
||||
void __cdecl tanhf_test1_validate(float value, float expected, float variance)
|
||||
{
|
||||
float result = tanhf(value);
|
||||
|
||||
/*
|
||||
* The test is valid when the difference between result
|
||||
* and expected is less than or equal to variance
|
||||
*/
|
||||
float delta = fabsf(result - expected);
|
||||
|
||||
if (delta > variance)
|
||||
{
|
||||
Fail("tanhf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* tanhf_test1_validate
|
||||
*
|
||||
* test validation function for values returning NaN
|
||||
*/
|
||||
void __cdecl tanhf_test1_validate_isnan(float value)
|
||||
{
|
||||
float result = tanhf(value);
|
||||
|
||||
if (!_isnanf(result))
|
||||
{
|
||||
Fail("tanhf(%g) returned %10.9g when it should have returned %10.9g",
|
||||
value, result, PAL_NAN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* main
|
||||
*
|
||||
* executable entry point
|
||||
*/
|
||||
PALTEST(c_runtime_tanhf_test1_paltest_tanhf_test1, "c_runtime/tanhf/test1/paltest_tanhf_test1")
|
||||
{
|
||||
struct test tests[] =
|
||||
{
|
||||
/* value expected variance */
|
||||
{ 0, 0, PAL_EPSILON },
|
||||
{ 0.318309886f, 0.307977913f, PAL_EPSILON }, // value: 1 / pi
|
||||
{ 0.434294482f, 0.408904012f, PAL_EPSILON }, // value: log10f(e)
|
||||
{ 0.636619772f, 0.562593600f, PAL_EPSILON }, // value: 2 / pi
|
||||
{ 0.693147181f, 0.6f, PAL_EPSILON }, // value: ln(2)
|
||||
{ 0.707106781f, 0.608859365f, PAL_EPSILON }, // value: 1 / sqrtf(2)
|
||||
{ 0.785398163f, 0.655794203f, PAL_EPSILON }, // value: pi / 4
|
||||
{ 1, 0.761594156f, PAL_EPSILON },
|
||||
{ 1.12837917f, 0.810463806f, PAL_EPSILON }, // value: 2 / sqrtf(pi)
|
||||
{ 1.41421356f, 0.888385562f, PAL_EPSILON }, // value: sqrtf(2)
|
||||
{ 1.44269504f, 0.894238946f, PAL_EPSILON }, // value: logf2(e)
|
||||
{ 1.57079633f, 0.917152336f, PAL_EPSILON }, // value: pi / 2
|
||||
{ 2.30258509f, 0.980198020f, PAL_EPSILON }, // value: ln(10)
|
||||
{ 2.71828183f, 0.991328916f, PAL_EPSILON }, // value: e
|
||||
{ 3.14159265f, 0.996272076f, PAL_EPSILON }, // value: pi
|
||||
{ PAL_POSINF, 1, PAL_EPSILON * 10 }
|
||||
};
|
||||
|
||||
/* PAL initialization */
|
||||
if (PAL_Initialize(argc, argv) != 0)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
|
||||
{
|
||||
tanhf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance);
|
||||
tanhf_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance);
|
||||
}
|
||||
|
||||
tanhf_test1_validate_isnan(PAL_NAN);
|
||||
|
||||
PAL_Terminate();
|
||||
return PASS;
|
||||
}
|
|
@ -1,18 +1,3 @@
|
|||
c_runtime/abs/test1/paltest_abs_test1
|
||||
c_runtime/acos/test1/paltest_acos_test1
|
||||
c_runtime/acosf/test1/paltest_acosf_test1
|
||||
c_runtime/acosh/test1/paltest_acosh_test1
|
||||
c_runtime/acoshf/test1/paltest_acoshf_test1
|
||||
c_runtime/asin/test1/paltest_asin_test1
|
||||
c_runtime/asinf/test1/paltest_asinf_test1
|
||||
c_runtime/asinh/test1/paltest_asinh_test1
|
||||
c_runtime/asinhf/test1/paltest_asinhf_test1
|
||||
c_runtime/atan/test1/paltest_atan_test1
|
||||
c_runtime/atan2/test1/paltest_atan2_test1
|
||||
c_runtime/atan2f/test1/paltest_atan2f_test1
|
||||
c_runtime/atanf/test1/paltest_atanf_test1
|
||||
c_runtime/atanh/test1/paltest_atanh_test1
|
||||
c_runtime/atanhf/test1/paltest_atanhf_test1
|
||||
c_runtime/atof/test1/paltest_atof_test1
|
||||
c_runtime/atoi/test1/paltest_atoi_test1
|
||||
c_runtime/bsearch/test1/paltest_bsearch_test1
|
||||
|
@ -29,22 +14,12 @@ c_runtime/errno/test1/paltest_errno_test1
|
|||
c_runtime/errno/test2/paltest_errno_test2
|
||||
c_runtime/exit/test1/paltest_exit_test1
|
||||
c_runtime/exit/test2/paltest_exit_test2
|
||||
c_runtime/exp/test1/paltest_exp_test1
|
||||
c_runtime/expf/test1/paltest_expf_test1
|
||||
c_runtime/fabs/test1/paltest_fabs_test1
|
||||
c_runtime/fabsf/test1/paltest_fabsf_test1
|
||||
c_runtime/ferror/test1/paltest_ferror_test1
|
||||
c_runtime/ferror/test2/paltest_ferror_test2
|
||||
c_runtime/fflush/test1/paltest_fflush_test1
|
||||
c_runtime/fgets/test1/paltest_fgets_test1
|
||||
c_runtime/fgets/test2/paltest_fgets_test2
|
||||
c_runtime/fgets/test3/paltest_fgets_test3
|
||||
c_runtime/floor/test1/paltest_floor_test1
|
||||
c_runtime/floorf/test1/paltest_floorf_test1
|
||||
c_runtime/fma/test1/paltest_fma_test1
|
||||
c_runtime/fmaf/test1/paltest_fmaf_test1
|
||||
c_runtime/fmod/test1/paltest_fmod_test1
|
||||
c_runtime/fmodf/test1/paltest_fmodf_test1
|
||||
c_runtime/fopen/test1/paltest_fopen_test1
|
||||
c_runtime/fopen/test2/paltest_fopen_test2
|
||||
c_runtime/fopen/test3/paltest_fopen_test3
|
||||
|
@ -61,8 +36,6 @@ c_runtime/free/test1/paltest_free_test1
|
|||
c_runtime/fseek/test1/paltest_fseek_test1
|
||||
c_runtime/ftell/test1/paltest_ftell_test1
|
||||
c_runtime/fwrite/test1/paltest_fwrite_test1
|
||||
c_runtime/ilogb/test1/paltest_ilogb_test1
|
||||
c_runtime/ilogbf/test1/paltest_ilogbf_test1
|
||||
c_runtime/isalnum/test1/paltest_isalnum_test1
|
||||
c_runtime/isalpha/test1/paltest_isalpha_test1
|
||||
c_runtime/isdigit/test1/paltest_isdigit_test1
|
||||
|
@ -74,34 +47,16 @@ c_runtime/iswspace/test1/paltest_iswspace_test1
|
|||
c_runtime/iswupper/test1/paltest_iswupper_test1
|
||||
c_runtime/isxdigit/test1/paltest_isxdigit_test1
|
||||
c_runtime/llabs/test1/paltest_llabs_test1
|
||||
c_runtime/log/test1/paltest_log_test1
|
||||
c_runtime/log10/test1/paltest_log10_test1
|
||||
c_runtime/log10f/test1/paltest_log10f_test1
|
||||
c_runtime/log2/test1/paltest_log2_test1
|
||||
c_runtime/log2f/test1/paltest_log2f_test1
|
||||
c_runtime/logf/test1/paltest_logf_test1
|
||||
c_runtime/malloc/test1/paltest_malloc_test1
|
||||
c_runtime/malloc/test2/paltest_malloc_test2
|
||||
c_runtime/memchr/test1/paltest_memchr_test1
|
||||
c_runtime/memcmp/test1/paltest_memcmp_test1
|
||||
c_runtime/memmove/test1/paltest_memmove_test1
|
||||
c_runtime/memset/test1/paltest_memset_test1
|
||||
c_runtime/modf/test1/paltest_modf_test1
|
||||
c_runtime/modff/test1/paltest_modff_test1
|
||||
c_runtime/pow/test1/paltest_pow_test1
|
||||
c_runtime/powf/test1/paltest_powf_test1
|
||||
c_runtime/qsort/test1/paltest_qsort_test1
|
||||
c_runtime/qsort/test2/paltest_qsort_test2
|
||||
c_runtime/rand_srand/test1/paltest_rand_srand_test1
|
||||
c_runtime/realloc/test1/paltest_realloc_test1
|
||||
c_runtime/sin/test1/paltest_sin_test1
|
||||
c_runtime/sincos/test1/paltest_sincos_test1
|
||||
c_runtime/sincosf/test1/paltest_sincosf_test1
|
||||
c_runtime/sinf/test1/paltest_sinf_test1
|
||||
c_runtime/sinh/test1/paltest_sinh_test1
|
||||
c_runtime/sinhf/test1/paltest_sinhf_test1
|
||||
c_runtime/sqrt/test1/paltest_sqrt_test1
|
||||
c_runtime/sqrtf/test1/paltest_sqrtf_test1
|
||||
c_runtime/sscanf_s/test1/paltest_sscanf_test1
|
||||
c_runtime/sscanf_s/test10/paltest_sscanf_test10
|
||||
c_runtime/sscanf_s/test11/paltest_sscanf_test11
|
||||
|
@ -130,10 +85,6 @@ c_runtime/strncpy/test1/paltest_strncpy_test1
|
|||
c_runtime/strpbrk/test1/paltest_strpbrk_test1
|
||||
c_runtime/strrchr/test1/paltest_strrchr_test1
|
||||
c_runtime/strstr/test1/paltest_strstr_test1
|
||||
c_runtime/tan/test1/paltest_tan_test1
|
||||
c_runtime/tanf/test1/paltest_tanf_test1
|
||||
c_runtime/tanh/test1/paltest_tanh_test1
|
||||
c_runtime/tanhf/test1/paltest_tanhf_test1
|
||||
c_runtime/time/test1/paltest_time_test1
|
||||
c_runtime/tolower/test1/paltest_tolower_test1
|
||||
c_runtime/toupper/test1/paltest_toupper_test1
|
||||
|
@ -158,10 +109,6 @@ c_runtime/wcstoul/test4/paltest_wcstoul_test4
|
|||
c_runtime/wcstoul/test5/paltest_wcstoul_test5
|
||||
c_runtime/wcstoul/test6/paltest_wcstoul_test6
|
||||
c_runtime/_alloca/test1/paltest_alloca_test1
|
||||
c_runtime/_finite/test1/paltest_finite_test1
|
||||
c_runtime/_finitef/test1/paltest_finitef_test1
|
||||
c_runtime/_isnan/test1/paltest_isnan_test1
|
||||
c_runtime/_isnanf/test1/paltest_isnanf_test1
|
||||
c_runtime/_itow/test1/paltest_itow_test1
|
||||
c_runtime/_putenv/test1/paltest_putenv_test1
|
||||
c_runtime/_putenv/test2/paltest_putenv_test2
|
||||
|
|
|
@ -1,47 +1,16 @@
|
|||
c_runtime/abs/test1/paltest_abs_test1
|
||||
c_runtime/acos/test1/paltest_acos_test1
|
||||
c_runtime/acosf/test1/paltest_acosf_test1
|
||||
c_runtime/acosh/test1/paltest_acosh_test1
|
||||
c_runtime/acoshf/test1/paltest_acoshf_test1
|
||||
c_runtime/asin/test1/paltest_asin_test1
|
||||
c_runtime/asinf/test1/paltest_asinf_test1
|
||||
c_runtime/asinh/test1/paltest_asinh_test1
|
||||
c_runtime/asinhf/test1/paltest_asinhf_test1
|
||||
c_runtime/atan/test1/paltest_atan_test1
|
||||
c_runtime/atan2/test1/paltest_atan2_test1
|
||||
c_runtime/atan2f/test1/paltest_atan2f_test1
|
||||
c_runtime/atanf/test1/paltest_atanf_test1
|
||||
c_runtime/atanh/test1/paltest_atanh_test1
|
||||
c_runtime/atanhf/test1/paltest_atanhf_test1
|
||||
c_runtime/atof/test1/paltest_atof_test1
|
||||
c_runtime/atoi/test1/paltest_atoi_test1
|
||||
c_runtime/bsearch/test1/paltest_bsearch_test1
|
||||
c_runtime/bsearch/test2/paltest_bsearch_test2
|
||||
c_runtime/cbrt/test1/paltest_cbrt_test1
|
||||
c_runtime/cbrtf/test1/paltest_cbrtf_test1
|
||||
c_runtime/ceil/test1/paltest_ceil_test1
|
||||
c_runtime/ceilf/test1/paltest_ceilf_test1
|
||||
c_runtime/cos/test1/paltest_cos_test1
|
||||
c_runtime/cosf/test1/paltest_cosf_test1
|
||||
c_runtime/cosh/test1/paltest_cosh_test1
|
||||
c_runtime/coshf/test1/paltest_coshf_test1
|
||||
c_runtime/errno/test1/paltest_errno_test1
|
||||
c_runtime/errno/test2/paltest_errno_test2
|
||||
c_runtime/exit/test1/paltest_exit_test1
|
||||
c_runtime/exp/test1/paltest_exp_test1
|
||||
c_runtime/expf/test1/paltest_expf_test1
|
||||
c_runtime/fabs/test1/paltest_fabs_test1
|
||||
c_runtime/fabsf/test1/paltest_fabsf_test1
|
||||
c_runtime/fflush/test1/paltest_fflush_test1
|
||||
c_runtime/fgets/test1/paltest_fgets_test1
|
||||
c_runtime/fgets/test2/paltest_fgets_test2
|
||||
c_runtime/fgets/test3/paltest_fgets_test3
|
||||
c_runtime/floor/test1/paltest_floor_test1
|
||||
c_runtime/floorf/test1/paltest_floorf_test1
|
||||
c_runtime/fma/test1/paltest_fma_test1
|
||||
c_runtime/fmaf/test1/paltest_fmaf_test1
|
||||
c_runtime/fmod/test1/paltest_fmod_test1
|
||||
c_runtime/fmodf/test1/paltest_fmodf_test1
|
||||
c_runtime/fopen/test1/paltest_fopen_test1
|
||||
c_runtime/fopen/test2/paltest_fopen_test2
|
||||
c_runtime/fopen/test3/paltest_fopen_test3
|
||||
|
@ -53,8 +22,6 @@ c_runtime/fputs/test1/paltest_fputs_test1
|
|||
c_runtime/free/test1/paltest_free_test1
|
||||
c_runtime/fseek/test1/paltest_fseek_test1
|
||||
c_runtime/fwrite/test1/paltest_fwrite_test1
|
||||
c_runtime/ilogb/test1/paltest_ilogb_test1
|
||||
c_runtime/ilogbf/test1/paltest_ilogbf_test1
|
||||
c_runtime/isalnum/test1/paltest_isalnum_test1
|
||||
c_runtime/isalpha/test1/paltest_isalpha_test1
|
||||
c_runtime/isdigit/test1/paltest_isdigit_test1
|
||||
|
@ -67,11 +34,6 @@ c_runtime/iswupper/test1/paltest_iswupper_test1
|
|||
c_runtime/isxdigit/test1/paltest_isxdigit_test1
|
||||
c_runtime/llabs/test1/paltest_llabs_test1
|
||||
c_runtime/log/test1/paltest_log_test1
|
||||
c_runtime/log2/test1/paltest_log2_test1
|
||||
c_runtime/log2f/test1/paltest_log2f_test1
|
||||
c_runtime/log10/test1/paltest_log10_test1
|
||||
c_runtime/log10f/test1/paltest_log10f_test1
|
||||
c_runtime/logf/test1/paltest_logf_test1
|
||||
c_runtime/malloc/test1/paltest_malloc_test1
|
||||
c_runtime/malloc/test2/paltest_malloc_test2
|
||||
c_runtime/memchr/test1/paltest_memchr_test1
|
||||
|
@ -80,20 +42,10 @@ c_runtime/memmove/test1/paltest_memmove_test1
|
|||
c_runtime/memset/test1/paltest_memset_test1
|
||||
c_runtime/modf/test1/paltest_modf_test1
|
||||
c_runtime/modff/test1/paltest_modff_test1
|
||||
c_runtime/pow/test1/paltest_pow_test1
|
||||
c_runtime/powf/test1/paltest_powf_test1
|
||||
c_runtime/qsort/test1/paltest_qsort_test1
|
||||
c_runtime/qsort/test2/paltest_qsort_test2
|
||||
c_runtime/rand_srand/test1/paltest_rand_srand_test1
|
||||
c_runtime/realloc/test1/paltest_realloc_test1
|
||||
c_runtime/sin/test1/paltest_sin_test1
|
||||
c_runtime/sincos/test1/paltest_sincos_test1
|
||||
c_runtime/sincosf/test1/paltest_sincosf_test1
|
||||
c_runtime/sinf/test1/paltest_sinf_test1
|
||||
c_runtime/sinh/test1/paltest_sinh_test1
|
||||
c_runtime/sinhf/test1/paltest_sinhf_test1
|
||||
c_runtime/sqrt/test1/paltest_sqrt_test1
|
||||
c_runtime/sqrtf/test1/paltest_sqrtf_test1
|
||||
c_runtime/sscanf_s/test1/paltest_sscanf_test1
|
||||
c_runtime/sscanf_s/test10/paltest_sscanf_test10
|
||||
c_runtime/sscanf_s/test11/paltest_sscanf_test11
|
||||
|
@ -122,10 +74,6 @@ c_runtime/strncpy/test1/paltest_strncpy_test1
|
|||
c_runtime/strpbrk/test1/paltest_strpbrk_test1
|
||||
c_runtime/strrchr/test1/paltest_strrchr_test1
|
||||
c_runtime/strstr/test1/paltest_strstr_test1
|
||||
c_runtime/tan/test1/paltest_tan_test1
|
||||
c_runtime/tanf/test1/paltest_tanf_test1
|
||||
c_runtime/tanh/test1/paltest_tanh_test1
|
||||
c_runtime/tanhf/test1/paltest_tanhf_test1
|
||||
c_runtime/time/test1/paltest_time_test1
|
||||
c_runtime/tolower/test1/paltest_tolower_test1
|
||||
c_runtime/toupper/test1/paltest_toupper_test1
|
||||
|
@ -150,10 +98,6 @@ c_runtime/wcstoul/test4/paltest_wcstoul_test4
|
|||
c_runtime/wcstoul/test5/paltest_wcstoul_test5
|
||||
c_runtime/wcstoul/test6/paltest_wcstoul_test6
|
||||
c_runtime/_alloca/test1/paltest_alloca_test1
|
||||
c_runtime/_finite/test1/paltest_finite_test1
|
||||
c_runtime/_finitef/test1/paltest_finitef_test1
|
||||
c_runtime/_isnan/test1/paltest_isnan_test1
|
||||
c_runtime/_isnanf/test1/paltest_isnanf_test1
|
||||
c_runtime/_itow/test1/paltest_itow_test1
|
||||
c_runtime/_putenv/test1/paltest_putenv_test1
|
||||
c_runtime/_putenv/test2/paltest_putenv_test2
|
||||
|
|
|
@ -6506,7 +6506,7 @@ void Interpreter::CkFinite()
|
|||
break;
|
||||
}
|
||||
|
||||
if (!_finite(val))
|
||||
if (!isfinite(val))
|
||||
ThrowSysArithException();
|
||||
}
|
||||
|
||||
|
@ -6828,6 +6828,16 @@ void Interpreter::SetILInstrCategories()
|
|||
}
|
||||
#endif // INTERP_ILINSTR_PROFILE
|
||||
|
||||
#ifndef TARGET_WINDOWS
|
||||
namespace
|
||||
{
|
||||
bool isnan(float val)
|
||||
{
|
||||
UINT32 bits = *reinterpret_cast<UINT32*>(&val);
|
||||
return (bits & 0x7FFFFFFFU) > 0x7F800000U;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
template<int op>
|
||||
void Interpreter::CompareOp()
|
||||
|
@ -7135,7 +7145,7 @@ INT32 Interpreter::CompareOpRes(unsigned op1idx)
|
|||
else if (op == CO_GT_UN)
|
||||
{
|
||||
// Check for NAN's here: if either is a NAN, they're unordered, so this comparison returns true.
|
||||
if (_isnan(val1) || _isnan(val2)) res = 1;
|
||||
if (isnan(val1) || isnan(val2)) res = 1;
|
||||
else if (val1 > val2) res = 1;
|
||||
}
|
||||
else if (op == CO_LT)
|
||||
|
@ -7146,7 +7156,7 @@ INT32 Interpreter::CompareOpRes(unsigned op1idx)
|
|||
{
|
||||
_ASSERTE(op == CO_LT_UN);
|
||||
// Check for NAN's here: if either is a NAN, they're unordered, so this comparison returns true.
|
||||
if (_isnan(val1) || _isnan(val2)) res = 1;
|
||||
if (isnan(val1) || isnan(val2)) res = 1;
|
||||
else if (val1 < val2) res = 1;
|
||||
}
|
||||
}
|
||||
|
@ -7177,7 +7187,7 @@ INT32 Interpreter::CompareOpRes(unsigned op1idx)
|
|||
else if (op == CO_GT_UN)
|
||||
{
|
||||
// Check for NAN's here: if either is a NAN, they're unordered, so this comparison returns true.
|
||||
if (_isnan(val1) || _isnan(val2)) res = 1;
|
||||
if (isnan(val1) || isnan(val2)) res = 1;
|
||||
else if (val1 > val2) res = 1;
|
||||
}
|
||||
else if (op == CO_LT)
|
||||
|
@ -7188,7 +7198,7 @@ INT32 Interpreter::CompareOpRes(unsigned op1idx)
|
|||
{
|
||||
_ASSERTE(op == CO_LT_UN);
|
||||
// Check for NAN's here: if either is a NAN, they're unordered, so this comparison returns true.
|
||||
if (_isnan(val1) || _isnan(val2)) res = 1;
|
||||
if (isnan(val1) || isnan(val2)) res = 1;
|
||||
else if (val1 < val2) res = 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -533,12 +533,12 @@ ftype BankersRound(ftype value)
|
|||
return integerPart;
|
||||
|
||||
// Else return the nearest even integer
|
||||
return (ftype)_copysign(ceil(fabs(value+0.5)),
|
||||
return (ftype)copysign(ceil(fabs(value+0.5)),
|
||||
value);
|
||||
}
|
||||
|
||||
// Otherwise round to closest
|
||||
return (ftype)_copysign(floor(fabs(value)+0.5),
|
||||
return (ftype)copysign(floor(fabs(value)+0.5),
|
||||
value);
|
||||
}
|
||||
|
||||
|
@ -674,6 +674,32 @@ HCIMPL1_V(INT64, JIT_Dbl2LngOvf, double val)
|
|||
}
|
||||
HCIMPLEND
|
||||
|
||||
#ifndef TARGET_WINDOWS
|
||||
namespace
|
||||
{
|
||||
bool isnan(float val)
|
||||
{
|
||||
UINT32 bits = *reinterpret_cast<UINT32*>(&val);
|
||||
return (bits & 0x7FFFFFFFU) > 0x7F800000U;
|
||||
}
|
||||
bool isnan(double val)
|
||||
{
|
||||
UINT64 bits = *reinterpret_cast<UINT64*>(&val);
|
||||
return (bits & 0x7FFFFFFFFFFFFFFFULL) > 0x7FF0000000000000ULL;
|
||||
}
|
||||
bool isfinite(float val)
|
||||
{
|
||||
UINT32 bits = *reinterpret_cast<UINT32*>(&val);
|
||||
return (~bits & 0x7F800000U) != 0;
|
||||
}
|
||||
bool isfinite(double val)
|
||||
{
|
||||
UINT64 bits = *reinterpret_cast<UINT64*>(&val);
|
||||
return (~bits & 0x7FF0000000000000ULL) != 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
HCIMPL2_VV(float, JIT_FltRem, float dividend, float divisor)
|
||||
{
|
||||
FCALL_CONTRACT;
|
||||
|
@ -689,12 +715,12 @@ HCIMPL2_VV(float, JIT_FltRem, float dividend, float divisor)
|
|||
// ***"negated for -infinity" has been removed from the spec
|
||||
//
|
||||
|
||||
if (divisor==0 || !_finite(dividend))
|
||||
if (divisor==0 || !isfinite(dividend))
|
||||
{
|
||||
UINT32 NaN = CLR_NAN_32;
|
||||
return *(float *)(&NaN);
|
||||
}
|
||||
else if (!_finite(divisor) && !_isnan(divisor))
|
||||
else if (!isfinite(divisor) && !isnan(divisor))
|
||||
{
|
||||
return dividend;
|
||||
}
|
||||
|
@ -722,12 +748,12 @@ HCIMPL2_VV(double, JIT_DblRem, double dividend, double divisor)
|
|||
//
|
||||
// ***"negated for -infinity" has been removed from the spec
|
||||
//
|
||||
if (divisor==0 || !_finite(dividend))
|
||||
if (divisor==0 || !isfinite(dividend))
|
||||
{
|
||||
UINT64 NaN = CLR_NAN_64;
|
||||
return *(double *)(&NaN);
|
||||
}
|
||||
else if (!_finite(divisor) && !_isnan(divisor))
|
||||
else if (!isfinite(divisor) && !isnan(divisor))
|
||||
{
|
||||
return dividend;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue