mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-07 06:43:00 +03:00
Implement C23 rsqrt
C23 adds various <math.h> function families originally defined in TS 18661-4. Add the rsqrt functions (1/sqrt(x)). The test inputs are taken from those for sqrt. Tested for x86_64 and x86, and with build-many-glibcs.py.
This commit is contained in:
58
math/libm-test-rsqrt.inc
Normal file
58
math/libm-test-rsqrt.inc
Normal file
@@ -0,0 +1,58 @@
|
||||
/* Test rsqrt.
|
||||
Copyright (C) 2025 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "libm-test-driver.c"
|
||||
|
||||
static const struct test_f_f_data rsqrt_test_data[] =
|
||||
{
|
||||
TEST_f_f (rsqrt, qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
|
||||
TEST_f_f (rsqrt, -qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
|
||||
TEST_f_f (rsqrt, snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
|
||||
TEST_f_f (rsqrt, -snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
|
||||
TEST_f_f (rsqrt, plus_infty, plus_zero, ERRNO_UNCHANGED),
|
||||
TEST_f_f (rsqrt, plus_zero, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE),
|
||||
TEST_f_f (rsqrt, minus_zero, minus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE),
|
||||
|
||||
/* rsqrt (x) == qNaN plus invalid exception for x < 0. */
|
||||
TEST_f_f (rsqrt, -1, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION|ERRNO_EDOM),
|
||||
TEST_f_f (rsqrt, -1.1L, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION|ERRNO_EDOM),
|
||||
TEST_f_f (rsqrt, -min_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION|ERRNO_EDOM),
|
||||
TEST_f_f (rsqrt, -min_subnorm_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION|ERRNO_EDOM),
|
||||
TEST_f_f (rsqrt, -max_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION|ERRNO_EDOM),
|
||||
TEST_f_f (rsqrt, minus_infty, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION|ERRNO_EDOM),
|
||||
|
||||
AUTO_TESTS_f_f (rsqrt),
|
||||
};
|
||||
|
||||
static void
|
||||
rsqrt_test (void)
|
||||
{
|
||||
ALL_RM_TEST (rsqrt, 0, rsqrt_test_data, RUN_TEST_LOOP_f_f, END);
|
||||
}
|
||||
|
||||
static void
|
||||
do_test (void)
|
||||
{
|
||||
rsqrt_test ();
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
* End:
|
||||
*/
|
Reference in New Issue
Block a user