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

Function testDouble

code/mathematics/berlekamp_massey.test.cpp:63–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63void testDouble() {
64 for (int it = 0; it < 10000; it++) {
65 int K = rng() % 5 + 1,
66 S = rng() % 10 + 1;
67
68 int k = rng() % K + 1;
69 vector<long double> init(k);
70 rep(i,0,k) init[i] = (int)(rng() % (2*S)) - S;
71
72 vector<long double> c(k);
73 rep(i,0,k) c[i] = (int)(rng() % (2*S)) - S;
74 rep(i,0,k) {
75 long double cur = 0;
76 rep(j,0,k) {
77 cur = cur + init[(int)init.size()-1 - j] * c[j];
78 }
79 init.push_back(cur);
80 }
81
82 vector<long double> res = berlekamp_massey<long double>(init);
83 assert(res.size() <= k);
84 for (int i = k; i < init.size(); i++) {
85 long double cur = 0;
86 rep(j,0,res.size()) {
87 cur = cur + init[i-1 - j] * res[j];
88 }
89 assert_almost_equal(init[i], cur, 1e-6, true);
90 }
91 }
92}
93
94void test() {
95 testMod();

Callers 1

testFunction · 0.85

Calls 3

assert_almost_equalFunction · 0.85
push_backMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected