summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@gmail.com>2013-06-06 12:05:53 -0400
committerErik Schnetter <schnetter@gmail.com>2013-06-06 12:05:53 -0400
commit54c489d1d75b0df4314e94cdc25e283434e72cbc (patch)
tree2b3ad691f40af922a51bd231f3457dcc30a1115a
parent9600cc42c75a8bdf42a078c63a83fd7953cdc903 (diff)
downloadvecmathlib-54c489d1d75b0df4314e94cdc25e283434e72cbc.zip
vecmathlib-54c489d1d75b0df4314e94cdc25e283434e72cbc.tar.gz
Implement atan2
-rw-r--r--test.cc2
-rw-r--r--vec_base.h7
-rw-r--r--vec_builtin.h8
-rw-r--r--vec_double_avx.h1
-rw-r--r--vec_double_qpx.h1
-rw-r--r--vec_double_sse2.h1
-rw-r--r--vec_double_sse2_scalar.h1
-rw-r--r--vec_double_vsx.h1
-rw-r--r--vec_float_altivec.h1
-rw-r--r--vec_float_avx.h1
-rw-r--r--vec_float_sse2.h1
-rw-r--r--vec_float_sse2_scalar.h1
-rw-r--r--vec_pseudo.h11
-rw-r--r--vec_test.h8
14 files changed, 45 insertions, 0 deletions
diff --git a/test.cc b/test.cc
index 281215c..91a444b 100644
--- a/test.cc
+++ b/test.cc
@@ -1096,7 +1096,9 @@ struct vecmathlib_test {
}
for (int i=0; i<imax; ++i) {
const realvec_t x = random(R(-100.0), R(+100.0));
+ const realvec_t y = random(R(-100.0), R(+100.0));
check_real("atan", std::atan, vecmathlib::atan, x, accuracy());
+ check_real("atan2", std::atan2, vecmathlib::atan2, x, y, accuracy());
}
}
diff --git a/vec_base.h b/vec_base.h
index 9e4db15..eb6ae04 100644
--- a/vec_base.h
+++ b/vec_base.h
@@ -236,6 +236,13 @@ namespace vecmathlib {
}
template<typename real_t, int size>
+ inline realvec<real_t, size> atan2(realvec<real_t, size> x,
+ realvec<real_t, size> y)
+ {
+ return x.atan2(y);
+ }
+
+ template<typename real_t, int size>
inline realvec<real_t, size> atanh(realvec<real_t, size> x)
{
return x.atanh();
diff --git a/vec_builtin.h b/vec_builtin.h
index 003b94f..a240a6d 100644
--- a/vec_builtin.h
+++ b/vec_builtin.h
@@ -511,6 +511,7 @@ namespace vecmathlib {
realvec_t asin() const { return MF::vml_asin(*this); }
realvec_t asinh() const { return MF::vml_asinh(*this); }
realvec_t atan() const { return MF::vml_atan(*this); }
+ realvec_t atan2(realvec_t y) const { return MF::vml_atan(*this, y); }
realvec_t atanh() const { return MF::vml_atanh(*this); }
realvec_t cbrt() const { return MF::vml_cbrt(*this); }
realvec_t ceil() const { return MF::vml_ceil(*this); }
@@ -837,6 +838,13 @@ namespace vecmathlib {
}
template<typename real_t, int size>
+ inline realbuiltinvec<real_t, size> atan2(realbuiltinvec<real_t, size> x,
+ realbuiltinvec<real_t, size> y)
+ {
+ return x.atan2(y);
+ }
+
+ template<typename real_t, int size>
inline realbuiltinvec<real_t, size> atanh(realbuiltinvec<real_t, size> x)
{
return x.atanh();
diff --git a/vec_double_avx.h b/vec_double_avx.h
index 1be0627..011f4ff 100644
--- a/vec_double_avx.h
+++ b/vec_double_avx.h
@@ -549,6 +549,7 @@ namespace vecmathlib {
realvec asin() const { return MF::vml_asin(*this); }
realvec asinh() const { return MF::vml_asinh(*this); }
realvec atan() const { return MF::vml_atan(*this); }
+ realvec atan2(realvec y) const { return MF::vml_atan2(*this, y); }
realvec atanh() const { return MF::vml_atanh(*this); }
realvec cbrt() const { return MF::vml_cbrt(*this); }
realvec ceil() const { return _mm256_ceil_pd(v); }
diff --git a/vec_double_qpx.h b/vec_double_qpx.h
index cc1612e..b8c72a2 100644
--- a/vec_double_qpx.h
+++ b/vec_double_qpx.h
@@ -533,6 +533,7 @@ namespace vecmathlib {
realvec asin() const { return asind4(v); }
realvec asinh() const { return asinhd4(v); }
realvec atan() const { return atand4(v); }
+ realvec atan2(realvec y) const { return atan2d4(v, y.v); }
realvec atanh() const { return atanhd4(v); }
realvec cbrt() const { return cbrtd4(v); }
realvec ceil() const { return vec_ceil(v); }
diff --git a/vec_double_sse2.h b/vec_double_sse2.h
index 1cb444c..0dd2251 100644
--- a/vec_double_sse2.h
+++ b/vec_double_sse2.h
@@ -506,6 +506,7 @@ namespace vecmathlib {
realvec asin() const { return MF::vml_asin(*this); }
realvec asinh() const { return MF::vml_asinh(*this); }
realvec atan() const { return MF::vml_atan(*this); }
+ realvec atan2(realvec y) const { return MF::vml_atan2(*this, y); }
realvec atanh() const { return MF::vml_atanh(*this); }
realvec cbrt() const { return MF::vml_cbrt(*this); }
realvec ceil() const
diff --git a/vec_double_sse2_scalar.h b/vec_double_sse2_scalar.h
index 948f242..b4b0a46 100644
--- a/vec_double_sse2_scalar.h
+++ b/vec_double_sse2_scalar.h
@@ -381,6 +381,7 @@ namespace vecmathlib {
realvec asin() const { return MF::vml_asin(*this); }
realvec asinh() const { return MF::vml_asinh(*this); }
realvec atan() const { return MF::vml_atan(*this); }
+ realvec atan2(realvec y) const { return MF::vml_atan2(*this, y); }
realvec atanh() const { return MF::vml_atanh(*this); }
realvec cbrt() const { return MF::vml_cbrt(*this); }
realvec ceil() const
diff --git a/vec_double_vsx.h b/vec_double_vsx.h
index 08ce5af..085ceb9 100644
--- a/vec_double_vsx.h
+++ b/vec_double_vsx.h
@@ -537,6 +537,7 @@ namespace vecmathlib {
realvec asin() const { return MF::vml_asin(*this); }
realvec asinh() const { return MF::vml_asinh(*this); }
realvec atan() const { return MF::vml_atan(*this); }
+ realvec atan2(realvec y) const { return MF::vml_atan2(*this, y); }
realvec atanh() const { return MF::vml_atanh(*this); }
realvec cbrt() const { return MF::vml_cbrt(*this); }
realvec ceil() const { return vec_ceil(v); }
diff --git a/vec_float_altivec.h b/vec_float_altivec.h
index 43f0ea8..df9d332 100644
--- a/vec_float_altivec.h
+++ b/vec_float_altivec.h
@@ -422,6 +422,7 @@ namespace vecmathlib {
realvec asin() const { return MF::vml_asin(*this); }
realvec asinh() const { return MF::vml_asinh(*this); }
realvec atan() const { return MF::vml_atan(*this); }
+ realvec atan2(realvec y) const { return MF::vml_atan2(*this, y); }
realvec atanh() const { return MF::vml_atanh(*this); }
realvec cbrt() const { return MF::vml_cbrt(*this); }
realvec ceil() const { return vec_ceil(v); }
diff --git a/vec_float_avx.h b/vec_float_avx.h
index 190d066..6305e77 100644
--- a/vec_float_avx.h
+++ b/vec_float_avx.h
@@ -543,6 +543,7 @@ namespace vecmathlib {
realvec asin() const { return MF::vml_asin(*this); }
realvec asinh() const { return MF::vml_asinh(*this); }
realvec atan() const { return MF::vml_atan(*this); }
+ realvec atan2(realvec y) const { return MF::vml_atan2(*this, y); }
realvec atanh() const { return MF::vml_atanh(*this); }
realvec cbrt() const { return MF::vml_cbrt(*this); }
realvec ceil() const { return _mm256_ceil_ps(v); }
diff --git a/vec_float_sse2.h b/vec_float_sse2.h
index 78bf1f5..bd75529 100644
--- a/vec_float_sse2.h
+++ b/vec_float_sse2.h
@@ -500,6 +500,7 @@ namespace vecmathlib {
realvec asin() const { return MF::vml_asin(*this); }
realvec asinh() const { return MF::vml_asinh(*this); }
realvec atan() const { return MF::vml_atan(*this); }
+ realvec atan2(realvec y) const { return MF::vml_atan2(*this, y); }
realvec atanh() const { return MF::vml_atanh(*this); }
realvec cbrt() const { return MF::vml_cbrt(*this); }
realvec ceil() const
diff --git a/vec_float_sse2_scalar.h b/vec_float_sse2_scalar.h
index e939c50..49d46b4 100644
--- a/vec_float_sse2_scalar.h
+++ b/vec_float_sse2_scalar.h
@@ -378,6 +378,7 @@ namespace vecmathlib {
realvec asin() const { return MF::vml_asin(*this); }
realvec asinh() const { return MF::vml_asinh(*this); }
realvec atan() const { return MF::vml_atan(*this); }
+ realvec atan2(realvec y) const { return MF::vml_atan2(*this, y); }
realvec atanh() const { return MF::vml_atanh(*this); }
realvec cbrt() const { return MF::vml_cbrt(*this); }
realvec ceil() const
diff --git a/vec_pseudo.h b/vec_pseudo.h
index 57fd4f9..9965ee9 100644
--- a/vec_pseudo.h
+++ b/vec_pseudo.h
@@ -680,6 +680,10 @@ namespace vecmathlib {
realpseudovec asin() const { return map(std::asin); }
realpseudovec asinh() const { return map(std::asinh); }
realpseudovec atan() const { return map(std::atan); }
+ realpseudovec atan2(realpseudovec y) const
+ {
+ return MF::vml_atan2(*this, y);
+ }
realpseudovec atanh() const { return map(std::atanh); }
realpseudovec cbrt() const { return map(std::cbrt); }
realpseudovec ceil() const { return map(std::ceil); }
@@ -1041,6 +1045,13 @@ namespace vecmathlib {
}
template<typename real_t, int size>
+ inline realpseudovec<real_t, size> atan2(realpseudovec<real_t, size> x,
+ realpseudovec<real_t, size> y)
+ {
+ return x.atan2(y);
+ }
+
+ template<typename real_t, int size>
inline realpseudovec<real_t, size> atanh(realpseudovec<real_t, size> x)
{
return x.atanh();
diff --git a/vec_test.h b/vec_test.h
index 61a0f0b..da25ce3 100644
--- a/vec_test.h
+++ b/vec_test.h
@@ -649,6 +649,7 @@ namespace vecmathlib {
realtestvec asin() const { return MF::vml_asin(*this); }
realtestvec asinh() const { return MF::vml_asinh(*this); }
realtestvec atan() const { return MF::vml_atan(*this); }
+ realtestvec atan2(realtestvec y) const { return MF::vml_atan2(*this, y); }
realtestvec atanh() const { return MF::vml_atanh(*this); }
realtestvec cbrt() const { return MF::vml_cbrt(*this); }
realtestvec ceil() const { return MF::vml_ceil(*this); }
@@ -978,6 +979,13 @@ namespace vecmathlib {
}
template<typename real_t, int size>
+ inline realtestvec<real_t, size> atan2(realtestvec<real_t, size> x,
+ realtestvec<real_t, size> y)
+ {
+ return x.atan2(y);
+ }
+
+ template<typename real_t, int size>
inline realtestvec<real_t, size> atanh(realtestvec<real_t, size> x)
{
return x.atanh();
OpenPOWER on IntegriCloud