41 lines
1.3 KiB
Plaintext
41 lines
1.3 KiB
Plaintext
#include <gtest/gtest.h>
|
|
#include "test_header.cuh"
|
|
#include "cuelim_m4rie.cuh"
|
|
|
|
using namespace gf256;
|
|
|
|
bool test_gf256_elim_interface(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);
|
|
|
|
gf2e *ff_m4rie = gf2e_init(gf256.poly());
|
|
mzed_t *A_m4rie = mzed_init(ff_m4rie, src.nrows, src.ncols);
|
|
mzedwrite(src, A_m4rie);
|
|
mzed_t *A_m4rie_copy = mzed_copy(NULL, A_m4rie);
|
|
|
|
base_t rank_interface = gpu_mzed_elim(A_m4rie);
|
|
rci_t rank_m4rie = mzed_echelonize_newton_john(A_m4rie_copy, 1);
|
|
|
|
return (rank_interface == rank_m4rie) && (mzed_cmp(A_m4rie, A_m4rie_copy) == 0);
|
|
}
|
|
|
|
TEST(TestM4rieInterface, Small)
|
|
{
|
|
uint_fast32_t seed = 41921095;
|
|
GF256 gf256(0b100011101);
|
|
EXPECT_TRUE(test_gf256_elim_interface(5, 7, 6, 8, gf256, seed));
|
|
}
|
|
|
|
TEST(TestM4rieInterface, Mediem)
|
|
{
|
|
uint_fast32_t seed = 41921095;
|
|
GF256 gf256(0b100011101);
|
|
EXPECT_TRUE(test_gf256_elim_interface(50, 70, 60, 80, gf256, seed));
|
|
EXPECT_TRUE(test_gf256_elim_interface(500, 700, 600, 800, gf256, seed));
|
|
}
|