cuElim/test/test_gf256_elim.cu
2024-09-14 15:57:00 +08:00

31 lines
910 B
Plaintext

#include <gtest/gtest.h>
#include "test_header.cuh"
bool test_gf256_elim(size_t rank, size_t rank_col, size_t nrows, size_t ncols, const GF256 &gf256, uint_fast32_t seed)
{
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;
}
TEST(TestGF256Elim, Small)
{
uint_fast32_t seed = 41921095;
GF256 gf256(0b100011101);
EXPECT_TRUE(test_gf256_elim(5, 7, 6, 8, gf256, seed));
}
TEST(TestGF256Elim, Mediem)
{
uint_fast32_t seed = 41921095;
GF256 gf256(0b100011101);
EXPECT_TRUE(test_gf256_elim(50, 70, 60, 80, gf256, seed));
EXPECT_TRUE(test_gf256_elim(500, 700, 600, 800, gf256, seed));
}