From 7fb2e9c0ee126efc5628d063677e1980c20e701e Mon Sep 17 00:00:00 2001 From: jtlap Date: Mon, 18 Dec 2023 08:14:12 +0100 Subject: [PATCH] Missing doc tests --- include/eve/module/core/regular/core.hpp | 6 ++++ test/doc/core/masked/bit-reverse.cpp | 21 +++++++++++++ test/doc/core/masked/bit_reverse.cpp | 21 +++++++++++++ test/doc/core/masked/byte_reverse.cpp | 15 +++++++++ test/doc/core/masked/is_unit.cpp | 15 +++++++++ test/doc/core/regular/dot.cpp | 25 +++++++++++++++ test/doc/core/regular/is_unit.cpp | 15 +++++++++ test/doc/core/regular/quick_two_add.cpp | 17 +++++++++++ test/doc/core/regular/quick_two_sub.cpp | 17 +++++++++++ test/doc/core/regular/reldist.cpp | 25 +++++++++++++++ test/doc/core/regular/two_add.cpp | 17 +++++++++++ test/doc/core/regular/two_prod.cpp | 17 +++++++++++ test/doc/core/regular/two_sqr.cpp | 16 ++++++++++ test/doc/core/regular/two_sub.cpp | 17 +++++++++++ test/doc/math/regular/quarter.cpp | 39 ++++++++++++++++++++++++ 15 files changed, 283 insertions(+) create mode 100644 test/doc/core/masked/bit-reverse.cpp create mode 100644 test/doc/core/masked/bit_reverse.cpp create mode 100644 test/doc/core/masked/byte_reverse.cpp create mode 100644 test/doc/core/masked/is_unit.cpp create mode 100644 test/doc/core/regular/dot.cpp create mode 100644 test/doc/core/regular/is_unit.cpp create mode 100644 test/doc/core/regular/quick_two_add.cpp create mode 100644 test/doc/core/regular/quick_two_sub.cpp create mode 100644 test/doc/core/regular/reldist.cpp create mode 100644 test/doc/core/regular/two_add.cpp create mode 100644 test/doc/core/regular/two_prod.cpp create mode 100644 test/doc/core/regular/two_sqr.cpp create mode 100644 test/doc/core/regular/two_sub.cpp create mode 100644 test/doc/math/regular/quarter.cpp diff --git a/include/eve/module/core/regular/core.hpp b/include/eve/module/core/regular/core.hpp index 2b51d602cb..43f101b9c9 100644 --- a/include/eve/module/core/regular/core.hpp +++ b/include/eve/module/core/regular/core.hpp @@ -174,6 +174,8 @@ #include #include #include +#include +#include #include #include #include @@ -214,6 +216,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include diff --git a/test/doc/core/masked/bit-reverse.cpp b/test/doc/core/masked/bit-reverse.cpp new file mode 100644 index 0000000000..117a69fb03 --- /dev/null +++ b/test/doc/core/masked/bit-reverse.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + + +using wide_it = eve::wide>; + +int main() +{ + wide_it pi = {-14, 1, 3, 0}; + + std::cout << "---- simd" << '\n' + << "<- pi = " << pi << '\n' + << "-> bit_reverse[pi>0](pi) = " << eve::bit_reverse[pi>0](pi) << '\n' + << "-> bit_reverse[pi>0](pi, 4) = " << eve::bit_reverse[pi>0](pi, 4)<< '\n' + << "-> bit_reverse[pi>0][pi>2](pi) = " << eve::bit_reverse[pi>0](pi)<< '\n' + << "-> bit_reverse[pi>0][pi > 2](pi, 4) = " << eve::bit_reverse[pi>0](pi, 4)<< '\n' + ; + + return 0; +} diff --git a/test/doc/core/masked/bit_reverse.cpp b/test/doc/core/masked/bit_reverse.cpp new file mode 100644 index 0000000000..4d1171c730 --- /dev/null +++ b/test/doc/core/masked/bit_reverse.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + + +using wide_it = eve::wide>; + +int main() +{ + wide_it pi = {-14, 1, 3, 0}; + + std::cout << "---- simd" << '\n' + << "<- pi = " << pi << '\n' + << "-> bit_reverse[pi>0](pi) = " << eve::bit_reverse[pi>0](pi) << '\n' + << "-> bit_reverse[pi>0](pi, 4) = " << eve::bit_reverse[pi>0](pi, 4)<< '\n' + << "-> bit_reverse[pi>0](pi) = " << eve::bit_reverse[pi>0](pi)<< '\n' + << "-> bit_reverse[pi>0][pi > 2](pi, 4) = " << eve::bit_reverse[pi>0](pi, 4)<< '\n' + ; + + return 0; +} diff --git a/test/doc/core/masked/byte_reverse.cpp b/test/doc/core/masked/byte_reverse.cpp new file mode 100644 index 0000000000..ad24ec7ed0 --- /dev/null +++ b/test/doc/core/masked/byte_reverse.cpp @@ -0,0 +1,15 @@ +#include +#include + +using wide_it = eve::wide>; + +int main() +{ + wide_it pi = {257, 1, 3, 0}; + + std::cout << "---- simd" << '\n' + << "<- pi = " << pi << '\n' + << "-> byte_reverse[pi<2](pi) = " << eve::byte_reverse[pi<2](pi) << '\n'; + + return 0; +} diff --git a/test/doc/core/masked/is_unit.cpp b/test/doc/core/masked/is_unit.cpp new file mode 100644 index 0000000000..a053ae85ac --- /dev/null +++ b/test/doc/core/masked/is_unit.cpp @@ -0,0 +1,15 @@ +#include +#include +#include + +using wide_ft = eve::wide>; + +int main() +{ + wide_ft pf = {4.0f, 1.0f, -1.0f, -0.0f}; + + std::cout << "---- simd" << '\n' + << "<- pf = " << pf << '\n' + << "-> is_unit[pf < 3](pf) = " << eve::is_unit[pf < 3](pf) << '\n'; + return 0; +} diff --git a/test/doc/core/regular/dot.cpp b/test/doc/core/regular/dot.cpp new file mode 100644 index 0000000000..c107a1749e --- /dev/null +++ b/test/doc/core/regular/dot.cpp @@ -0,0 +1,25 @@ +#include +#include +#include + +using wide_it = eve::wide>; + +int main() +{ + wide_it pf = {0, 1, -1, -eve::valmax(eve::as())}; + wide_it qf = {1, -1, 0, eve::valmax(eve::as())}; + + std::cout << "---- simd" << '\n' + << "<- pf = " << pf << '\n' + << "<- qf = " << qf << '\n' + << "-> dot(pf, qf) = " << eve::dot(pf, qf) << '\n'; + + int16_t xf = -eve::valmax(eve::as()); + int16_t yf = eve::valmax(eve::as()); + + std::cout << "---- scalar" << '\n' + << "<- xf = " << xf << '\n' + << "<- yf = " << yf << '\n' + << "-> dot(xf, yf) = " << eve::dot(xf, yf) << '\n'; + return 0; +} diff --git a/test/doc/core/regular/is_unit.cpp b/test/doc/core/regular/is_unit.cpp new file mode 100644 index 0000000000..e9dfdc6161 --- /dev/null +++ b/test/doc/core/regular/is_unit.cpp @@ -0,0 +1,15 @@ +#include +#include +#include + +using wide_ft = eve::wide>; + +int main() +{ + wide_ft pf = {0.0f, 1.0f, -1.0f, -0.0f}; + + std::cout << "---- simd" << '\n' + << "<- pf = " << pf << '\n' + << "-> is_unit(pf) = " << eve::is_unit(pf) << '\n'; + return 0; +} diff --git a/test/doc/core/regular/quick_two_add.cpp b/test/doc/core/regular/quick_two_add.cpp new file mode 100644 index 0000000000..49cdb5e5bb --- /dev/null +++ b/test/doc/core/regular/quick_two_add.cpp @@ -0,0 +1,17 @@ +#include +#include +#include + +int main() +{ + using wf_t = eve::wide>; + wf_t pf = {6, 2.5, -320.7, 1.0}, qf = {4.2, 1.5, -100.834, eve::eps(eve::as())/2}; + auto [s, eps] = eve::quick_two_add(pf, qf); + std::cout << "---- simd" << '\n' + << " <- pf = " << pf << '\n' + << " <- qf = " << qf << '\n' + << " -> {s, eps] = quick_two_add(pf, qf)\n" + << " -> s = " << s << '\n' + << " -> eps = " << eps << '\n'; + return 0; +} diff --git a/test/doc/core/regular/quick_two_sub.cpp b/test/doc/core/regular/quick_two_sub.cpp new file mode 100644 index 0000000000..d52b727a05 --- /dev/null +++ b/test/doc/core/regular/quick_two_sub.cpp @@ -0,0 +1,17 @@ +#include +#include +#include + +int main() +{ + using wf_t = eve::wide>; + wf_t pf = {6, 2.5, -320.7, 1.0}, qf = {4.2, 1.5, -100.834, eve::eps(eve::as())/2}; + auto [s, eps] = eve::quick_two_sub(pf, qf); + std::cout << "---- simd" << '\n' + << " <- pf = " << pf << '\n' + << " <- qf = " << qf << '\n' + << " -> {s, eps] = quick_two_sub(pf, qf)\n" + << " -> s = " << s << '\n' + << " -> eps = " << eps << '\n'; + return 0; +} diff --git a/test/doc/core/regular/reldist.cpp b/test/doc/core/regular/reldist.cpp new file mode 100644 index 0000000000..2a39211916 --- /dev/null +++ b/test/doc/core/regular/reldist.cpp @@ -0,0 +1,25 @@ +#include +#include +#include + +using wide_it = eve::wide>; + +int main() +{ + wide_it pf = {0, 1, -1, -eve::valmax(eve::as())/10}; + wide_it qf = {1, -1, 0, eve::valmax(eve::as())/10}; + + std::cout << "---- simd" << '\n' + << "<- pf = " << pf << '\n' + << "<- qf = " << qf << '\n' + << "-> reldist(pf, qf) = " << eve::reldist(pf, qf) << '\n'; + + float xf = -eve::valmax(eve::as())/10; + float yf = eve::valmax(eve::as())/10; + + std::cout << "---- scalar" << '\n' + << "<- xf = " << xf << '\n' + << "<- yf = " << yf << '\n' + << "-> reldist(xf, yf) = " << eve::reldist(xf, yf) << '\n'; + return 0; +} diff --git a/test/doc/core/regular/two_add.cpp b/test/doc/core/regular/two_add.cpp new file mode 100644 index 0000000000..42ef670c37 --- /dev/null +++ b/test/doc/core/regular/two_add.cpp @@ -0,0 +1,17 @@ +#include +#include +#include + +int main() +{ + using wf_t = eve::wide>; + wf_t pf = {3, 2.5, -32.7, 1.0}, qf = {4.2, 1.5, -100.834, eve::eps(eve::as())/2}; + auto [s, eps] = eve::two_add(pf, qf); + std::cout << "---- simd" << '\n' + << " <- pf = " << pf << '\n' + << " <- qf = " << qf << '\n' + << " -> {s, eps] = two_add(pf, qf)\n" + << " -> s = " << s << '\n' + << " -> eps = " << eps << '\n'; + return 0; +} diff --git a/test/doc/core/regular/two_prod.cpp b/test/doc/core/regular/two_prod.cpp new file mode 100644 index 0000000000..769d234a3a --- /dev/null +++ b/test/doc/core/regular/two_prod.cpp @@ -0,0 +1,17 @@ +#include +#include +#include + +int main() +{ + using wf_t = eve::wide>; + wf_t pf = {3, 2.5, -32.7, 1.0}, qf = {4.2, 1.5, -100.834, eve::eps(eve::as())/2}; + auto [s, eps] = eve::two_prod(pf, qf); + std::cout << "---- simd" << '\n' + << " <- pf = " << pf << '\n' + << " <- qf = " << qf << '\n' + << " -> {s, eps] = two_prod(pf, qf)\n" + << " -> s = " << s << '\n' + << " -> eps = " << eps << '\n'; + return 0; +} diff --git a/test/doc/core/regular/two_sqr.cpp b/test/doc/core/regular/two_sqr.cpp new file mode 100644 index 0000000000..401886d483 --- /dev/null +++ b/test/doc/core/regular/two_sqr.cpp @@ -0,0 +1,16 @@ +#include +#include +#include + +int main() +{ + using wf_t = eve::wide>; + wf_t pf = {3, 2.5, -32.7, eve::eps(eve::as())}; + auto [s, eps] = eve::two_sqr(pf); + std::cout << "---- simd" << '\n' + << " <- pf = " << pf << '\n' + << " -> {s, eps] = two_sqr(pf)\n" + << " -> s = " << s << '\n' + << " -> eps = " << eps << '\n'; + return 0; +} diff --git a/test/doc/core/regular/two_sub.cpp b/test/doc/core/regular/two_sub.cpp new file mode 100644 index 0000000000..6fa4349b87 --- /dev/null +++ b/test/doc/core/regular/two_sub.cpp @@ -0,0 +1,17 @@ +#include +#include +#include + +int main() +{ + using wf_t = eve::wide>; + wf_t pf = {6, 2.5, -320.7, 1.0}, qf = {4.2, 1.5, -100.834, eve::eps(eve::as())/2}; + auto [s, eps] = eve::two_sub(pf, qf); + std::cout << "---- simd" << '\n' + << " <- pf = " << pf << '\n' + << " <- qf = " << qf << '\n' + << " -> {s, eps] = two_sub(pf, qf)\n" + << " -> s = " << s << '\n' + << " -> eps = " << eps << '\n'; + return 0; +} diff --git a/test/doc/math/regular/quarter.cpp b/test/doc/math/regular/quarter.cpp new file mode 100644 index 0000000000..41a8895df6 --- /dev/null +++ b/test/doc/math/regular/quarter.cpp @@ -0,0 +1,39 @@ +#include +#include +#include +#include + +using wide_ft = eve::wide; +using wide_dt = eve::wide; + +int main() +{ + wide_ft wxf; + wide_dt wxd; + + std::cout << "---- simd" << std::setprecision(9) << std::endl + << "-> quarter(as()) = " << eve::quarter(eve::as()) << std::endl + << "-> quarter(as(wxf)) = " << eve::quarter(eve::as(wxf)) << std::endl + << "-> upward(quarter)(as()) = " << eve::upward(eve::quarter)(eve::as()) << std::endl + << "-> upward(quarter)(as(wxf)) = " << eve::upward(eve::quarter)(eve::as(wxf)) << std::endl + << "-> downward(quarter)(as()) = " << eve::downward(eve::quarter)(eve::as()) << std::endl + << "-> downward(quarter)(as(wxf)) = " << eve::downward(eve::quarter)(eve::as(wxf)) << std::endl + << std::setprecision(17) + << "-> quarter(as()) = " << eve::quarter(eve::as()) << std::endl + << "-> quarter(as(wxd)) = " << eve::quarter(eve::as(wxd)) << std::endl + << "-> upward(quarter)(as()) = " << eve::upward(eve::quarter)(eve::as()) << std::endl + << "-> upward(quarter)(as(wxd)) = " << eve::upward(eve::quarter)(eve::as(wxd)) << std::endl + << "-> downward(quarter)(as()) = " << eve::downward(eve::quarter)(eve::as()) << std::endl + << "-> downward(quarter)(as(wxd)) = " << eve::downward(eve::quarter)(eve::as(wxd)) << std::endl; + + float xf; + double xd; + + std::cout << "---- scalar" << std::endl + << "-> quarter(as()) = " << eve::quarter(eve::as(float())) << std::endl + << "-> quarter(as quarter(as()) = " << eve::quarter(eve::as(double()))<< std::endl + << "-> quarter(as