cuElim/test/test_gf256_elim.cu

33 lines
934 B
Plaintext
Raw Normal View History

2024-09-12 18:53:59 +08:00
#include <gtest/gtest.h>
#include "test_header.cuh"
2024-09-14 16:15:13 +08:00
using namespace gf256;
2024-09-14 15:57:00 +08:00
bool test_gf256_elim(size_t rank, size_t rank_col, size_t nrows, size_t ncols, const GF256 &gf256, uint_fast32_t seed)
2024-09-12 18:53:59 +08:00
{
assert(rank <= nrows && rank <= rank_col && rank_col <= ncols);
MatGF256 rdc(rank, ncols);
rdc.randomize(rank_col, seed);
MatGF256 mix(nrows, rank);
mix.randomize(seed);
MatGF256 src = gpu_mul(mix, rdc, gf256);
ElimResult res = src.gpu_elim(gf256);
MatGF256 win(src, 0, 0, res.rank, src.width);
return rdc == win;
}
2024-09-14 15:57:00 +08:00
TEST(TestGF256Elim, Small)
2024-09-12 18:53:59 +08:00
{
uint_fast32_t seed = 41921095;
GF256 gf256(0b100011101);
2024-09-14 15:57:00 +08:00
EXPECT_TRUE(test_gf256_elim(5, 7, 6, 8, gf256, seed));
2024-09-12 18:53:59 +08:00
}
2024-09-14 15:57:00 +08:00
TEST(TestGF256Elim, Mediem)
2024-09-12 18:53:59 +08:00
{
uint_fast32_t seed = 41921095;
GF256 gf256(0b100011101);
2024-09-14 15:57:00 +08:00
EXPECT_TRUE(test_gf256_elim(50, 70, 60, 80, gf256, seed));
EXPECT_TRUE(test_gf256_elim(500, 700, 600, 800, gf256, seed));
2024-09-12 18:53:59 +08:00
}