MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / testMod

Function testMod

code/mathematics/berlekamp_massey.test.cpp:32–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32void testMod() {
33 for (int it = 0; it < 10000; it++) {
34 int K = rng() % 20 + 1,
35 S = rng() % 1000 + 1;
36
37 int k = rng() % K + 1;
38 vector<Mod> init(k);
39 rep(i,0,k) init[i] = (int)(rng() % (2*S)) - S;
40
41 vector<Mod> c(k);
42 rep(i,0,k) c[i] = (int)(rng() % (2*S)) - S;
43 rep(i,0,k) {
44 Mod cur = 0;
45 rep(j,0,k) {
46 cur = cur + init[(int)init.size()-1 - j] * c[j];
47 }
48 init.push_back(cur);
49 }
50
51 vector<Mod> res = berlekamp_massey<Mod>(init);
52 assert(res.size() <= k);
53 for (int i = k; i < init.size(); i++) {
54 Mod cur = 0;
55 rep(j,0,res.size()) {
56 cur = cur + init[i-1 - j] * res[j];
57 }
58 assert_equal(init[i], cur, true);
59 }
60 }
61}
62
63void testDouble() {
64 for (int it = 0; it < 10000; it++) {

Callers 1

testFunction · 0.85

Calls 3

push_backMethod · 0.80
assert_equalFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected