Skip to content

Commit

Permalink
Missing doc tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jtlap authored Dec 18, 2023
1 parent 23db0f2 commit 7fb2e9c
Show file tree
Hide file tree
Showing 15 changed files with 283 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/eve/module/core/regular/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@
#include <eve/module/core/regular/plus.hpp>
#include <eve/module/core/regular/popcount.hpp>
#include <eve/module/core/regular/prev.hpp>
#include <eve/module/core/regular/quick_two_add.hpp>
#include <eve/module/core/regular/quick_two_sub.hpp>
#include <eve/module/core/regular/rat.hpp>
#include <eve/module/core/regular/read.hpp>
#include <eve/module/core/regular/rec.hpp>
Expand Down Expand Up @@ -214,6 +216,10 @@
#include <eve/module/core/regular/swap_pairs.hpp>
#include <eve/module/core/regular/trunc.hpp>
#include <eve/module/core/regular/try_each_group_position.hpp>
#include <eve/module/core/regular/two_add.hpp>
#include <eve/module/core/regular/two_prod.hpp>
#include <eve/module/core/regular/two_sqr.hpp>
#include <eve/module/core/regular/two_sub.hpp>
#include <eve/module/core/regular/ulpdist.hpp>
#include <eve/module/core/regular/unalign.hpp>
#include <eve/module/core/regular/unsafe.hpp>
Expand Down
21 changes: 21 additions & 0 deletions test/doc/core/masked/bit-reverse.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <eve/module/core.hpp>
#include <iostream>
#include <bit>


using wide_it = eve::wide<std::uint16_t, eve::fixed<4>>;

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;
}
21 changes: 21 additions & 0 deletions test/doc/core/masked/bit_reverse.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <eve/module/core.hpp>
#include <iostream>
#include <bit>


using wide_it = eve::wide<std::uint16_t, eve::fixed<4>>;

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;
}
15 changes: 15 additions & 0 deletions test/doc/core/masked/byte_reverse.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <eve/module/core.hpp>
#include <iostream>

using wide_it = eve::wide<std::uint32_t, eve::fixed<4>>;

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;
}
15 changes: 15 additions & 0 deletions test/doc/core/masked/is_unit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>

using wide_ft = eve::wide<float, eve::fixed<4>>;

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;
}
25 changes: 25 additions & 0 deletions test/doc/core/regular/dot.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>

using wide_it = eve::wide<int16_t, eve::fixed<4>>;

int main()
{
wide_it pf = {0, 1, -1, -eve::valmax(eve::as<int16_t>())};
wide_it qf = {1, -1, 0, eve::valmax(eve::as<int16_t>())};

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>());
int16_t yf = eve::valmax(eve::as<int16_t>());

std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yf = " << yf << '\n'
<< "-> dot(xf, yf) = " << eve::dot(xf, yf) << '\n';
return 0;
}
15 changes: 15 additions & 0 deletions test/doc/core/regular/is_unit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>

using wide_ft = eve::wide<float, eve::fixed<4>>;

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;
}
17 changes: 17 additions & 0 deletions test/doc/core/regular/quick_two_add.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>

int main()
{
using wf_t = eve::wide<float, eve::fixed<4>>;
wf_t pf = {6, 2.5, -320.7, 1.0}, qf = {4.2, 1.5, -100.834, eve::eps(eve::as<float>())/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;
}
17 changes: 17 additions & 0 deletions test/doc/core/regular/quick_two_sub.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>

int main()
{
using wf_t = eve::wide<float, eve::fixed<4>>;
wf_t pf = {6, 2.5, -320.7, 1.0}, qf = {4.2, 1.5, -100.834, eve::eps(eve::as<float>())/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;
}
25 changes: 25 additions & 0 deletions test/doc/core/regular/reldist.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>

using wide_it = eve::wide<float, eve::fixed<4>>;

int main()
{
wide_it pf = {0, 1, -1, -eve::valmax(eve::as<float>())/10};
wide_it qf = {1, -1, 0, eve::valmax(eve::as<float>())/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<float>())/10;
float yf = eve::valmax(eve::as<float>())/10;

std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yf = " << yf << '\n'
<< "-> reldist(xf, yf) = " << eve::reldist(xf, yf) << '\n';
return 0;
}
17 changes: 17 additions & 0 deletions test/doc/core/regular/two_add.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>

int main()
{
using wf_t = eve::wide<float, eve::fixed<4>>;
wf_t pf = {3, 2.5, -32.7, 1.0}, qf = {4.2, 1.5, -100.834, eve::eps(eve::as<float>())/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;
}
17 changes: 17 additions & 0 deletions test/doc/core/regular/two_prod.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>

int main()
{
using wf_t = eve::wide<float, eve::fixed<4>>;
wf_t pf = {3, 2.5, -32.7, 1.0}, qf = {4.2, 1.5, -100.834, eve::eps(eve::as<float>())/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;
}
16 changes: 16 additions & 0 deletions test/doc/core/regular/two_sqr.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>

int main()
{
using wf_t = eve::wide<float, eve::fixed<4>>;
wf_t pf = {3, 2.5, -32.7, eve::eps(eve::as<float>())};
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;
}
17 changes: 17 additions & 0 deletions test/doc/core/regular/two_sub.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>

int main()
{
using wf_t = eve::wide<float, eve::fixed<4>>;
wf_t pf = {6, 2.5, -320.7, 1.0}, qf = {4.2, 1.5, -100.834, eve::eps(eve::as<float>())/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;
}
39 changes: 39 additions & 0 deletions test/doc/math/regular/quarter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <eve/module/math.hpp>
#include <eve/wide.hpp>
#include <iostream>
#include <iomanip>

using wide_ft = eve::wide<float>;
using wide_dt = eve::wide<double>;

int main()
{
wide_ft wxf;
wide_dt wxd;

std::cout << "---- simd" << std::setprecision(9) << std::endl
<< "-> quarter(as<wide_ft>()) = " << eve::quarter(eve::as<wide_ft>()) << std::endl
<< "-> quarter(as(wxf)) = " << eve::quarter(eve::as(wxf)) << std::endl
<< "-> upward(quarter)(as<wide_ft>()) = " << eve::upward(eve::quarter)(eve::as<wide_ft>()) << std::endl
<< "-> upward(quarter)(as(wxf)) = " << eve::upward(eve::quarter)(eve::as(wxf)) << std::endl
<< "-> downward(quarter)(as<wide_ft>()) = " << eve::downward(eve::quarter)(eve::as<wide_ft>()) << std::endl
<< "-> downward(quarter)(as(wxf)) = " << eve::downward(eve::quarter)(eve::as(wxf)) << std::endl
<< std::setprecision(17)
<< "-> quarter(as<wide_dt>()) = " << eve::quarter(eve::as<wide_dt>()) << std::endl
<< "-> quarter(as(wxd)) = " << eve::quarter(eve::as(wxd)) << std::endl
<< "-> upward(quarter)(as<wide_dt>()) = " << eve::upward(eve::quarter)(eve::as<wide_dt>()) << std::endl
<< "-> upward(quarter)(as(wxd)) = " << eve::upward(eve::quarter)(eve::as(wxd)) << std::endl
<< "-> downward(quarter)(as<wide_dt>()) = " << eve::downward(eve::quarter)(eve::as<wide_dt>()) << 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<float>()) = " << eve::quarter(eve::as(float())) << std::endl
<< "-> quarter(as<xf)) = " << eve::quarter(eve::as(xf)) << std::endl
<< "-> quarter(as<double>()) = " << eve::quarter(eve::as(double()))<< std::endl
<< "-> quarter(as<xd)) = " << eve::quarter(eve::as(xd)) << std::endl;

return 0;
}

0 comments on commit 7fb2e9c

Please sign in to comment.