diff options
author | Erik Schnetter <schnetter@gmail.com> | 2013-08-21 14:06:40 -0400 |
---|---|---|
committer | Erik Schnetter <schnetter@gmail.com> | 2013-08-21 14:06:40 -0400 |
commit | 96bb7ef9a533562cca0c45318d37029c3d939f86 (patch) | |
tree | 41da23e0bb12625e6f197beefdedc13c5080cd4f | |
parent | 733a2dd58afc0a0c81f94316dbbc4955741ec84a (diff) | |
download | vecmathlib-96bb7ef9a533562cca0c45318d37029c3d939f86.zip vecmathlib-96bb7ef9a533562cca0c45318d37029c3d939f86.tar.gz |
Make frexp take a pointer argument instead of a reference
-rw-r--r-- | mathfuncs_base.h | 2 | ||||
-rw-r--r-- | mathfuncs_fabs.h | 5 | ||||
-rw-r--r-- | mathfuncs_rcp.h | 2 | ||||
-rw-r--r-- | test.cc | 4 | ||||
-rw-r--r-- | vec_altivec_float4.h | 2 | ||||
-rw-r--r-- | vec_avx_double4.h | 2 | ||||
-rw-r--r-- | vec_avx_float8.h | 2 | ||||
-rw-r--r-- | vec_base.h | 2 | ||||
-rw-r--r-- | vec_builtin.h | 2 | ||||
-rw-r--r-- | vec_mic_double8.h | 2 | ||||
-rw-r--r-- | vec_neon_float2.h | 2 | ||||
-rw-r--r-- | vec_neon_float4.h | 2 | ||||
-rw-r--r-- | vec_pseudo.h | 6 | ||||
-rw-r--r-- | vec_qpx_double4.h | 2 | ||||
-rw-r--r-- | vec_sse_double1.h | 8 | ||||
-rw-r--r-- | vec_sse_double2.h | 2 | ||||
-rw-r--r-- | vec_sse_float1.h | 10 | ||||
-rw-r--r-- | vec_sse_float4.h | 2 | ||||
-rw-r--r-- | vec_test.h | 4 | ||||
-rw-r--r-- | vec_vsx_double2.h | 2 |
20 files changed, 34 insertions, 31 deletions
diff --git a/mathfuncs_base.h b/mathfuncs_base.h index 06cb590..f413d2d 100644 --- a/mathfuncs_base.h +++ b/mathfuncs_base.h @@ -67,7 +67,7 @@ namespace vecmathlib { static realvec_t vml_fma(realvec_t x, realvec_t y, realvec_t z); static realvec_t vml_fmax(realvec_t x, realvec_t y); static realvec_t vml_fmin(realvec_t x, realvec_t y); - static realvec_t vml_frexp(realvec_t x, intvec_t& r); + static realvec_t vml_frexp(realvec_t x, intvec_t* r); static intvec_t vml_ilogb(realvec_t x); static boolvec_t vml_ieee_isfinite(realvec_t x); static boolvec_t vml_ieee_isinf(realvec_t x); diff --git a/mathfuncs_fabs.h b/mathfuncs_fabs.h index c6830b9..857694f 100644 --- a/mathfuncs_fabs.h +++ b/mathfuncs_fabs.h @@ -52,10 +52,10 @@ namespace vecmathlib { template<typename realvec_t> realvec_t mathfuncs<realvec_t>::vml_frexp(realvec_t x, - typename realvec_t::intvec_t& ir) + typename realvec_t::intvec_t* irp) { intvec_t e = lsr(as_int(x) & IV(FP::exponent_mask), FP::mantissa_bits); - ir = e - IV(FP::exponent_offset - 1); + intvec_t ir = e - IV(FP::exponent_offset - 1); ir = ifthen(convert_bool(e), ir, IV(std::numeric_limits<int_t>::min())); #if defined VML_HAVE_INF ir = ifthen(isinf(x), IV(std::numeric_limits<int_t>::max()), ir); @@ -69,6 +69,7 @@ namespace vecmathlib { boolvec_t iszero = x == RV(0.0); ir = ifthen(iszero, IV(I(0)), ir); r = ifthen(iszero, copysign(RV(R(0.0)), r), r); + *irp = ir; return r; } diff --git a/mathfuncs_rcp.h b/mathfuncs_rcp.h index 0349cc8..6e12b27 100644 --- a/mathfuncs_rcp.h +++ b/mathfuncs_rcp.h @@ -63,7 +63,7 @@ namespace vecmathlib { // Initial guess VML_ASSERT(all(x > RV(0.0))); intvec_t x_exp; - x = frexp(x, x_exp); + x = frexp(x, &x_exp); VML_ASSERT(all(x >= RV(0.5) && x < RV(1.0))); realvec_t r = RV(R(48.0)/R(17.0)) - RV(R(32.0)/R(17.0)) * x; @@ -1092,12 +1092,12 @@ struct vecmathlib_test { static realvec_t local_vfrexp0(realvec_t x) { intvec_t r; - return vecmathlib::frexp(x, r); + return vecmathlib::frexp(x, &r); } static intvec_t local_vfrexp1(realvec_t x) { intvec_t r; - vecmathlib::frexp(x, r); + vecmathlib::frexp(x, &r); return r; } static int_t local_ilogb(real_t x) diff --git a/vec_altivec_float4.h b/vec_altivec_float4.h index 6c14da5..024f15c 100644 --- a/vec_altivec_float4.h +++ b/vec_altivec_float4.h @@ -478,7 +478,7 @@ namespace vecmathlib { realvec fmax(realvec y) const { return vec_max(v, y.v); } realvec fmin(realvec y) const { return vec_min(v, y.v); } realvec fmod(realvec y) const { return MF::vml_fmod(*this, y); } - realvec frexp(intvec_t& r) const { return MF::vml_frexp(*this, r); } + realvec frexp(intvec_t* r) const { return MF::vml_frexp(*this, r); } realvec hypot(realvec y) const { return MF::vml_hypot(*this, y); } intvec_t ilogb() const { return MF::vml_ilogb(*this); } boolvec_t isfinite() const { return MF::vml_isfinite(*this); } diff --git a/vec_avx_double4.h b/vec_avx_double4.h index 6632c71..4117225 100644 --- a/vec_avx_double4.h +++ b/vec_avx_double4.h @@ -611,7 +611,7 @@ namespace vecmathlib { realvec fmax(realvec y) const { return _mm256_max_pd(v, y.v); } realvec fmin(realvec y) const { return _mm256_min_pd(v, y.v); } realvec fmod(realvec y) const { return MF::vml_fmod(*this, y); } - realvec frexp(intvec_t& r) const { return MF::vml_frexp(*this, r); } + realvec frexp(intvec_t* r) const { return MF::vml_frexp(*this, r); } realvec hypot(realvec y) const { return MF::vml_hypot(*this, y); } intvec_t ilogb() const { return MF::vml_ilogb(*this); } boolvec_t isfinite() const { return MF::vml_isfinite(*this); } diff --git a/vec_avx_float8.h b/vec_avx_float8.h index 3ff6197..aeea50b 100644 --- a/vec_avx_float8.h +++ b/vec_avx_float8.h @@ -605,7 +605,7 @@ namespace vecmathlib { realvec fmax(realvec y) const { return _mm256_max_ps(v, y.v); } realvec fmin(realvec y) const { return _mm256_min_ps(v, y.v); } realvec fmod(realvec y) const { return MF::vml_fmod(*this, y); } - realvec frexp(intvec_t& r) const { return MF::vml_frexp(*this, r); } + realvec frexp(intvec_t* r) const { return MF::vml_frexp(*this, r); } realvec hypot(realvec y) const { return MF::vml_hypot(*this, y); } intvec_t ilogb() const { return MF::vml_ilogb(*this); } boolvec_t isfinite() const { return MF::vml_isfinite(*this); } @@ -382,7 +382,7 @@ namespace vecmathlib { template<typename real_t, int size> inline realvec<real_t, size> frexp(realvec<real_t, size> x, - intvec<real_t, size>& r) + intvec<real_t, size>* r) { return x.frexp(r); } diff --git a/vec_builtin.h b/vec_builtin.h index f7db8ca..c09a290 100644 --- a/vec_builtin.h +++ b/vec_builtin.h @@ -532,7 +532,7 @@ namespace vecmathlib { realvec_t fmax(realvec_t y) const { return MF::vml_fmax(*this, y); } realvec_t fmin(realvec_t y) const { return MF::vml_fmin(*this, y); } realvec_t fmod(realvec_t y) const { return MF::vml_fmod(*this, y); } - realvec frexp(intvec_t& r) const { return MF::vml_frexp(*this, r); } + realvec frexp(intvec_t* r) const { return MF::vml_frexp(*this, r); } realvec_t hypot(realvec_t y) const { return MF::vml_hypot(*this, y); } intvec_t ilogb() const { return MF::vml_ilogb(*this); } boolvec_t isfinite() const { return MF::vml_isfinite(*this); } diff --git a/vec_mic_double8.h b/vec_mic_double8.h index b043d8c..b8873c7 100644 --- a/vec_mic_double8.h +++ b/vec_mic_double8.h @@ -550,7 +550,7 @@ namespace vecmathlib { realvec fmax(realvec y) const { return _mm512_gmax_pd(v, y.v); } realvec fmin(realvec y) const { return _mm512_gmin_pd(v, y.v); } realvec fmod(realvec y) const { return MF::vml_fmod(*this, y); } - realvec frexp(intvec_t& r) const { return MF::vml_frexp(*this, r); } + realvec frexp(intvec_t* r) const { return MF::vml_frexp(*this, r); } realvec hypot(realvec y) const { return MF::vml_hypot(*this, y); } intvec_t ilogb() const { return MF::vml_ilogb(*this); } boolvec_t isfinite() const { return MF::vml_isfinite(*this); } diff --git a/vec_neon_float2.h b/vec_neon_float2.h index 65dcd1e..9b48424 100644 --- a/vec_neon_float2.h +++ b/vec_neon_float2.h @@ -488,7 +488,7 @@ namespace vecmathlib { realvec fmax(realvec y) const { return vmax_f32(v, y.v); } realvec fmin(realvec y) const { return vmin_f32(v, y.v); } realvec fmod(realvec y) const { return MF::vml_fmod(*this, y); } - realvec frexp(intvec_t& r) const { return MF::vml_frexp(*this, r); } + realvec frexp(intvec_t* r) const { return MF::vml_frexp(*this, r); } realvec hypot(realvec y) const { return MF::vml_hypot(*this, y); } intvec_t ilogb() const { return MF::vml_ilogb(*this); } boolvec_t isfinite() const { return MF::vml_isfinite(*this); } diff --git a/vec_neon_float4.h b/vec_neon_float4.h index 7bd8f8c..a3f45fe 100644 --- a/vec_neon_float4.h +++ b/vec_neon_float4.h @@ -508,7 +508,7 @@ namespace vecmathlib { realvec fmax(realvec y) const { return vmaxq_f32(v, y.v); } realvec fmin(realvec y) const { return vminq_f32(v, y.v); } realvec fmod(realvec y) const { return MF::vml_fmod(*this, y); } - realvec frexp(intvec_t& r) const { return MF::vml_frexp(*this, r); } + realvec frexp(intvec_t* r) const { return MF::vml_frexp(*this, r); } realvec hypot(realvec y) const { return MF::vml_hypot(*this, y); } intvec_t ilogb() const { return MF::vml_ilogb(*this); } boolvec_t isfinite() const { return MF::vml_isfinite(*this); } diff --git a/vec_pseudo.h b/vec_pseudo.h index 3a66134..f079bdb 100644 --- a/vec_pseudo.h +++ b/vec_pseudo.h @@ -760,7 +760,7 @@ namespace vecmathlib { realpseudovec fmax(realpseudovec y) const { return map(std::fmax, y); } realpseudovec fmin(realpseudovec y) const { return map(std::fmin, y); } realpseudovec fmod(realpseudovec y) const { return map(std::fmod, y); } - realpseudovec frexp(intvec_t& ires) const + realpseudovec frexp(intvec_t* ires) const { realvec_t res; for (int d=0; d<size; ++d) { @@ -774,7 +774,7 @@ namespace vecmathlib { if (std::isnan(v[d])) ir = std::numeric_limits<int_t>::min(); #endif res.v[d] = r; - ires.v[d] = ir; + ires->v[d] = ir; } return res; } @@ -1277,7 +1277,7 @@ namespace vecmathlib { template<typename real_t, int size> inline realpseudovec<real_t, size> frexp(realpseudovec<real_t, size> x, - intpseudovec<real_t, size>& r) + intpseudovec<real_t, size>* r) { return x.frexp(r); } diff --git a/vec_qpx_double4.h b/vec_qpx_double4.h index 0bd5ba5..3bcab2f 100644 --- a/vec_qpx_double4.h +++ b/vec_qpx_double4.h @@ -602,7 +602,7 @@ namespace vecmathlib { realvec fmax(realvec y) const { return MF::vml_fmax(v, y.v); } realvec fmin(realvec y) const { return MF::vml_fmin(v, y.v); } realvec fmod(realvec y) const { return MF::vml_fmod(*this, y); } - realvec frexp(intvec_t& r) const { return MF::vml_frexp(*this, r); } + realvec frexp(intvec_t* r) const { return MF::vml_frexp(*this, r); } realvec hypot(realvec y) const { return hypotd4(v, y.v); } intvec_t ilogb() const { diff --git a/vec_sse_double1.h b/vec_sse_double1.h index 7ab311e..eec59f2 100644 --- a/vec_sse_double1.h +++ b/vec_sse_double1.h @@ -423,13 +423,13 @@ namespace vecmathlib { return to_double(_mm_min_sd(from_double(v), from_double(y.v))); } realvec fmod(realvec y) const { return std::fmod(v, y.v); } - realvec frexp(intvec_t& ir) const + realvec frexp(intvec_t* ir) const { int iri; realvec r = std::frexp(v, &iri); - ir.v = iri; - if (isinf()) ir.v = std::numeric_limits<int_t>::max(); - if (isnan()) ir.v = std::numeric_limits<int_t>::min(); + if (isinf()) iri = std::numeric_limits<int_t>::max(); + if (isnan()) iri = std::numeric_limits<int_t>::min(); + ir->v = iri; return r; } realvec hypot(realvec y) const { return MF::vml_hypot(*this, y); } diff --git a/vec_sse_double2.h b/vec_sse_double2.h index 0660bd9..a5667a5 100644 --- a/vec_sse_double2.h +++ b/vec_sse_double2.h @@ -576,7 +576,7 @@ namespace vecmathlib { realvec fmax(realvec y) const { return _mm_max_pd(v, y.v); } realvec fmin(realvec y) const { return _mm_min_pd(v, y.v); } realvec fmod(realvec y) const { return MF::vml_fmod(*this, y); } - realvec frexp(intvec_t& r) const { return MF::vml_frexp(*this, r); } + realvec frexp(intvec_t* r) const { return MF::vml_frexp(*this, r); } realvec hypot(realvec y) const { return MF::vml_hypot(*this, y); } intvec_t ilogb() const { return MF::vml_ilogb(*this); } boolvec_t isfinite() const { return MF::vml_isfinite(*this); } diff --git a/vec_sse_float1.h b/vec_sse_float1.h index 675f18a..a339cf5 100644 --- a/vec_sse_float1.h +++ b/vec_sse_float1.h @@ -423,11 +423,13 @@ namespace vecmathlib { return to_float(_mm_min_ss(from_float(v), from_float(y.v))); } realvec fmod(realvec y) const { return std::fmod(v, y.v); } - realvec frexp(intvec_t& ir) const + realvec frexp(intvec_t* ir) const { - realvec r = std::frexp(v, &ir.v); - if (isinf()) ir.v = std::numeric_limits<int_t>::max(); - if (isnan()) ir.v = std::numeric_limits<int_t>::min(); + int iri; + realvec r = std::frexp(v, &iri); + if (isinf()) iri = std::numeric_limits<int_t>::max(); + if (isnan()) iri = std::numeric_limits<int_t>::min(); + ir->v = iri; return r; } realvec hypot(realvec y) const { return MF::vml_hypot(*this, y); } diff --git a/vec_sse_float4.h b/vec_sse_float4.h index 796e795..720cbcd 100644 --- a/vec_sse_float4.h +++ b/vec_sse_float4.h @@ -586,7 +586,7 @@ namespace vecmathlib { realvec fmax(realvec y) const { return _mm_max_ps(v, y.v); } realvec fmin(realvec y) const { return _mm_min_ps(v, y.v); } realvec fmod(realvec y) const { return MF::vml_fmod(*this, y); } - realvec frexp(intvec_t& r) const { return MF::vml_frexp(*this, r); } + realvec frexp(intvec_t* r) const { return MF::vml_frexp(*this, r); } realvec hypot(realvec y) const { return MF::vml_hypot(*this, y); } intvec_t ilogb() const { return MF::vml_ilogb(*this); } boolvec_t isfinite() const { return MF::vml_isfinite(*this); } @@ -701,7 +701,7 @@ namespace vecmathlib { realtestvec fmax(realtestvec y) const { return MF::vml_fmax(*this, y); } realtestvec fmin(realtestvec y) const { return MF::vml_fmin(*this, y); } realtestvec fmod(realtestvec y) const { return MF::vml_fmod(*this, y); } - realtestvec frexp(intvec_t& r) const { return MF::vml_frexp(*this, r); } + realtestvec frexp(intvec_t* r) const { return MF::vml_frexp(*this, r); } realtestvec hypot(realtestvec y) const { return MF::vml_hypot(*this, y); } intvec_t ilogb() const { return MF::vml_ilogb(*this); } boolvec_t isfinite() const { return MF::vml_isfinite(*this); } @@ -1164,7 +1164,7 @@ namespace vecmathlib { template<typename real_t, int size> inline realtestvec<real_t, size> frexp(realtestvec<real_t, size> x, - inttestvec<real_t, size>& r) + inttestvec<real_t, size>* r) { return x.frexp(r); } diff --git a/vec_vsx_double2.h b/vec_vsx_double2.h index 84bd257..5931286 100644 --- a/vec_vsx_double2.h +++ b/vec_vsx_double2.h @@ -585,7 +585,7 @@ namespace vecmathlib { realvec fmax(realvec y) const { return vec_max(v, y.v); } realvec fmin(realvec y) const { return vec_min(v, y.v); } realvec fmod(realvec y) const { return MF::vml_fmod(*this, y); } - realvec frexp(intvec_t& r) const { return MF::vml_frexp(*this, r); } + realvec frexp(intvec_t* r) const { return MF::vml_frexp(*this, r); } realvec hypot(realvec y) const { return MF::vml_hypot(*this, y); } intvec_t ilogb() const { return MF::vml_ilogb(*this); } boolvec_t isfinite() const { return MF::vml_isfinite(*this); } |