Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This is the change for single precision functions equivalent to the p… #18

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 85 additions & 20 deletions src/libm-tester/testerutil.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Copyright Naoki Shibata 2010 - 2017.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
Expand Down Expand Up @@ -151,11 +156,26 @@ double countULPdp(double d, mpfr_t c) {
mpfr_inits(fra, frb, frc, frd, NULL);

double c2 = mpfr_get_d(c, GMP_RNDN);
if (c2 == 0 && d != 0) return 10000;
if (isnan(c2) && isnan(d)) return 0;
if (isnan(c2) || isnan(d)) return 10001;
if (c2 == POSITIVE_INFINITY && d == POSITIVE_INFINITY) return 0;
if (c2 == NEGATIVE_INFINITY && d == NEGATIVE_INFINITY) return 0;
if (c2 == 0 && d != 0) {
mpfr_clears(fra, frb, frc, frd, NULL);
return 10000;
}
if (isnan(c2) && isnan(d)) {
mpfr_clears(fra, frb, frc, frd, NULL);
return 0;
}
if (isnan(c2) || isnan(d)) {
mpfr_clears(fra, frb, frc, frd, NULL);
return 10001;
}
if (c2 == POSITIVE_INFINITY && d == POSITIVE_INFINITY) {
mpfr_clears(fra, frb, frc, frd, NULL);
return 0;
}
if (c2 == NEGATIVE_INFINITY && d == NEGATIVE_INFINITY) {
mpfr_clears(fra, frb, frc, frd, NULL);
return 0;
}

double v = 0;
if (isinf(d) && !isinfl(mpfr_get_ld(c, GMP_RNDN))) {
Expand Down Expand Up @@ -184,11 +204,26 @@ double countULP2dp(double d, mpfr_t c) {
mpfr_inits(fra, frb, frc, frd, NULL);

double c2 = mpfr_get_d(c, GMP_RNDN);
if (c2 == 0 && d != 0) return 10000;
if (isnan(c2) && isnan(d)) return 0;
if (isnan(c2) || isnan(d)) return 10001;
if (c2 == POSITIVE_INFINITY && d == POSITIVE_INFINITY) return 0;
if (c2 == NEGATIVE_INFINITY && d == NEGATIVE_INFINITY) return 0;
if (c2 == 0 && d != 0) {
mpfr_clears(fra, frb, frc, frd, NULL);
return 10000;
}
if (isnan(c2) && isnan(d)) {
mpfr_clears(fra, frb, frc, frd, NULL);
return 0;
}
if (isnan(c2) || isnan(d)) {
mpfr_clears(fra, frb, frc, frd, NULL);
return 10001;
}
if (c2 == POSITIVE_INFINITY && d == POSITIVE_INFINITY) {
mpfr_clears(fra, frb, frc, frd, NULL);
return 0;
}
if (c2 == NEGATIVE_INFINITY && d == NEGATIVE_INFINITY) {
mpfr_clears(fra, frb, frc, frd, NULL);
return 0;
}

double v = 0;
if (isinf(d) && !isinfl(mpfr_get_ld(c, GMP_RNDN))) {
Expand Down Expand Up @@ -218,11 +253,26 @@ double countULPsp(float d, mpfr_t c) {

d = flushToZero(d);
float c2 = flushToZero(mpfr_get_d(c, GMP_RNDN));
if (c2 == 0 && d != 0) return 10000;
if (isnan(c2) && isnan(d)) return 0;
if (isnan(c2) || isnan(d)) return 10001;
if (c2 == POSITIVE_INFINITYf && d == POSITIVE_INFINITYf) return 0;
if (c2 == NEGATIVE_INFINITYf && d == NEGATIVE_INFINITYf) return 0;
if (c2 == 0 && d != 0) {
mpfr_clears(fra, frb, frc, frd, NULL);
return 10000;
}
if (isnan(c2) && isnan(d)) {
mpfr_clears(fra, frb, frc, frd, NULL);
return 0;
}
if (isnan(c2) || isnan(d)) {
mpfr_clears(fra, frb, frc, frd, NULL);
return 10001;
}
if (c2 == POSITIVE_INFINITYf && d == POSITIVE_INFINITYf) {
mpfr_clears(fra, frb, frc, frd, NULL);
return 0;
}
if (c2 == NEGATIVE_INFINITYf && d == NEGATIVE_INFINITYf) {
mpfr_clears(fra, frb, frc, frd, NULL);
return 0;
}

double v = 0;
if (isinf(d) && !isinfl(mpfr_get_ld(c, GMP_RNDN))) {
Expand Down Expand Up @@ -252,11 +302,26 @@ double countULP2sp(float d, mpfr_t c) {

d = flushToZero(d);
float c2 = flushToZero(mpfr_get_d(c, GMP_RNDN));
if (c2 == 0 && d != 0) return 10000;
if (isnan(c2) && isnan(d)) return 0;
if (isnan(c2) || isnan(d)) return 10001;
if (c2 == POSITIVE_INFINITYf && d == POSITIVE_INFINITYf) return 0;
if (c2 == NEGATIVE_INFINITYf && d == NEGATIVE_INFINITYf) return 0;
if (c2 == 0 && d != 0) {
mpfr_clears(fra, frb, frc, frd, NULL);
return 10000;
}
if (isnan(c2) && isnan(d)) {
mpfr_clears(fra, frb, frc, frd, NULL);
return 0;
}
if (isnan(c2) || isnan(d)) {
mpfr_clears(fra, frb, frc, frd, NULL);
return 10001;
}
if (c2 == POSITIVE_INFINITYf && d == POSITIVE_INFINITYf) {
mpfr_clears(fra, frb, frc, frd, NULL);
return 0;
}
if (c2 == NEGATIVE_INFINITYf && d == NEGATIVE_INFINITYf) {
mpfr_clears(fra, frb, frc, frd, NULL);
return 0;
}

double v = 0;
if (isinf(d) && !isinfl(mpfr_get_ld(c, GMP_RNDN))) {
Expand Down
14 changes: 14 additions & 0 deletions src/libm/df.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ static INLINE CONST vfloat2 dfadd_vf2_vf2_vf(vfloat2 x, vfloat y) {
return r;
}

static INLINE CONST vfloat2 dfsub_vf2_vf2_vf(vfloat2 x, vfloat y) {
vfloat2 r;

r.x = vsub_vf_vf_vf(x.x, y);
r.y = vadd_vf_vf_vf(vsub_vf_vf_vf(vsub_vf_vf_vf(x.x, r.x), y), x.y);

return r;
}

static INLINE CONST vfloat2 dfadd2_vf2_vf2_vf(vfloat2 x, vfloat y) {
vfloat2 r;

Expand Down Expand Up @@ -425,3 +434,8 @@ static INLINE CONST vfloat2 dfsqrt_vf2_vf2(vfloat2 d) {
return dfscale_vf2_vf2_vf(dfmul_vf2_vf2_vf2(dfadd2_vf2_vf2_vf2(d, dfmul_vf2_vf_vf(t, t)), dfrec_vf2_vf(t)), vcast_vf_f(0.5));
#endif
}

static INLINE CONST vfloat2 dfsqrt_vf2_vf(vfloat d) {
vfloat t = vsqrt_vf_vf(d);
return dfscale_vf2_vf2_vf(dfmul_vf2_vf2_vf2(dfadd2_vf2_vf_vf2(d, dfmul_vf2_vf_vf(t, t)), dfrec_vf2_vf(t)), vcast_vf_f(0.5f));
}
Loading